Skip to content

Commit a91b495

Browse files
committed
Work in progress.
1 parent 325e54c commit a91b495

File tree

5 files changed

+108
-14
lines changed

5 files changed

+108
-14
lines changed

core/functions.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,35 @@ function debugpress_format_size( $size, int $decimal = 2, string $sep = ' ' ) :
8686
return round( $size, $decimal ) . $sep . $units[ $pow ];
8787
}
8888

89+
/**
90+
* Check if specified file exist even in the include paths.
91+
*
92+
* @param string $file file name to find
93+
*
94+
* @return bool true if the file is found in current path or include path.
95+
*/
96+
function debugpress_file_exists( $file ) : bool {
97+
if ( function_exists( 'stream_resolve_include_path' ) ) {
98+
return ! ( stream_resolve_include_path( $file ) === false );
99+
} else {
100+
$paths = get_include_path();
101+
102+
if ( $paths === false ) {
103+
return false;
104+
}
105+
106+
$paths = explode( PATH_SEPARATOR, $paths );
107+
108+
foreach ( $paths as $path ) {
109+
if ( file_exists( $path . DIRECTORY_SEPARATOR . $file ) ) {
110+
return true;
111+
}
112+
}
113+
114+
return false;
115+
}
116+
}
117+
89118
/**
90119
* Extract part of the string from the left, based on the position of the other string.
91120
*

core/main/Info.php

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,23 +421,45 @@ public static function php_apc() : string {
421421
}
422422

423423
public static function php_pear() : string {
424-
try {
425-
@include_once( 'System.php' );
424+
$file = 'System.php';
426425

427-
if ( class_exists( '\System' ) === true ) {
428-
return __( "loaded", "debugpress" );
426+
if ( debugpress_file_exists( $file ) ) {
427+
try {
428+
@include_once( $file );
429+
430+
if ( class_exists( '\System' ) === true ) {
431+
return __( "loaded", "debugpress" );
432+
}
433+
} catch ( Exception $exception ) {
429434
}
430-
} catch ( Exception $exception ) {
431435
}
432436

433437
return '<strong style="color: #cc0000;">' . __( "not loaded", "debugpress" ) . '</strong>';
434438
}
435439

440+
public static function php_include_path() : string {
441+
$path = get_include_path();
442+
443+
return $path === false ? '' : $path;
444+
}
445+
446+
public static function php_loaded_extensions( bool $zend = false ) : array {
447+
return get_loaded_extensions( $zend );
448+
}
449+
450+
public static function php_extension( $name ) : string {
451+
if ( extension_loaded( $name ) ) {
452+
return __( "OK", "debugpress" );
453+
} else {
454+
return '<strong style="color: #cc0000;">' . __( "not available", "debugpress" ) . '</strong>';
455+
}
456+
}
457+
436458
public static function php_function( $name ) : string {
437459
if ( function_exists( $name ) ) {
438460
return __( "OK", "debugpress" );
439461
} else {
440462
return '<strong style="color: #cc0000;">' . __( "not available", "debugpress" ) . '</strong>';
441463
}
442464
}
443-
}
465+
}

core/panel/Server.php

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
exit;
77
}
88

9+
use Dev4Press\Plugin\DebugPress\Main\DB;
910
use Dev4Press\Plugin\DebugPress\Main\Info;
1011
use Dev4Press\Plugin\DebugPress\Main\Panel;
1112

@@ -37,6 +38,15 @@ public function left() {
3738
$this->table_init_standard();
3839
$this->table_head();
3940
$this->table_row( array( __( "Version", "debugpress" ), Info::mysql_version() ) );
41+
$this->table_row( array( __( "Charset", "debugpress" ), DB::instance()->wpdb()->charset ) );
42+
$this->table_row( array( __( "Collation", "debugpress" ), DB::instance()->wpdb()->collate ) );
43+
$this->table_foot();
44+
$this->block_footer();
45+
46+
$this->title( __( "mySQL Connection", "debugpress" ) );
47+
$this->block_header();
48+
$this->table_init_standard();
49+
$this->table_head();
4050
$this->table_row( array( __( "Host", "debugpress" ), DB_HOST ) );
4151
$this->table_row( array( __( "Database", "debugpress" ), DB_NAME ) );
4252
$this->table_row( array( __( "User", "debugpress" ), DB_USER ) );
@@ -60,7 +70,8 @@ public function right() {
6070
$this->table_row( array( __( "Max POST Size", "debugpress" ), Info::php_post_size() ) );
6171
$this->table_row( array( __( "Max Upload Size", "debugpress" ), Info::php_upload_size() ) );
6272
$this->table_row( array( __( "Max Execution Time", "debugpress" ), Info::php_execution_time() ) );
63-
$this->table_row( array( __( "Allow URL fopen", "debugpress" ), Info::php_allow_url_fopen() ) );
73+
$this->table_row( array( __( "Allow URL `fopen`", "debugpress" ), Info::php_allow_url_fopen() ) );
74+
$this->table_row( array( __( "Include path", "debugpress" ), Info::php_include_path() ) );
6475
$this->table_foot();
6576
$this->block_footer();
6677

@@ -78,18 +89,42 @@ public function right() {
7889
$this->table_foot();
7990
$this->block_footer();
8091

81-
$this->title( __( "PHP Extensions", "debugpress" ) );
92+
$this->title( __( "PHP Important Extensions", "debugpress" ) );
8293
$this->block_header();
8394
$this->table_init_standard();
8495
$this->table_head();
85-
$this->table_row( array( 'Zend OPCache', Info::php_opcache() ) );
8696
$this->table_row( array( 'PDO', Info::php_pdo() ) );
8797
$this->table_row( array( 'zLib', Info::php_zlib() ) );
8898
$this->table_row( array( 'cURL', Info::php_curl() ) );
8999
$this->table_row( array( 'GD', Info::php_gd() ) );
90-
$this->table_row( array( 'APC', Info::php_apc() ) );
91100
$this->table_row( array( 'PEAR', Info::php_pear() ) );
92101
$this->table_foot();
93102
$this->block_footer();
103+
104+
$this->title( __( "PHP Cache Extensions", "debugpress" ) );
105+
$this->block_header();
106+
$this->table_init_standard();
107+
$this->table_head();
108+
$this->table_row( array( 'Zend OPCache', Info::php_opcache() ) );
109+
$this->table_row( array( 'APC', Info::php_apc() ) );
110+
$this->table_row( array( 'Memcache', Info::php_extension( 'memcache' ) ) );
111+
$this->table_row( array( 'Memcached', Info::php_extension( 'memcached' ) ) );
112+
$this->table_foot();
113+
$this->block_footer();
114+
115+
$this->title( __( "PHP Loaded Extensions", "debugpress" ) );
116+
$this->block_header();
117+
$this->table_init_standard();
118+
$this->table_head();
119+
$this->table_row( array(
120+
__( "Standard", "debugpress" ),
121+
debugpress_rx( Info::php_loaded_extensions(), false )
122+
) );
123+
$this->table_row( array(
124+
__( "ZEND", "debugpress" ),
125+
debugpress_rx( Info::php_loaded_extensions( true ), false )
126+
) );
127+
$this->table_foot();
128+
$this->block_footer();
94129
}
95-
}
130+
}

debugpress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@
6767
require_once( DEBUGPRESS_PLUGIN_PATH . 'core/admin.php' );
6868

6969
debugpress_admin();
70-
}
70+
}

readme.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,15 @@ If you have enabled debugger (for admin side and/or frontend), Debugger is activ
103103
To enable WordPress debug mode via `wp-config.php`, check out the article here: [WordPress Setup](https://debug.press/documentation/wordpress-setup/).
104104

105105
== Changelog ==
106-
= 2.2 (2023.02.01) =
107-
* New: Updated some system requirements
106+
= 2.2 (2023.02.03) =
107+
* New: Updated some plugin system requirements
108+
* New: Server panel shows PHP Include Path value
109+
* New: Server panel shows Memcache/Memcached status
110+
* New: Server panel shows all loaded extensions
111+
* New: Server panel shows expanded MySQL information
108112
* Edit: Various improvements to some panels display conditions
109113
* Fix: Several more issues related to changes in PHP 8.1 and 8.2
114+
* Fix: Issue with detection of the PEAR System.php file
110115

111116
= 2.1 (2022.12.30) =
112117
* New: Tested with PHP 8.2 and WordPress 6.1
@@ -244,6 +249,9 @@ To enable WordPress debug mode via `wp-config.php`, check out the article here:
244249
* First official release
245250

246251
== Upgrade Notice ==
252+
= 2.2 =
253+
Various updates, improvements and fixes.
254+
247255
= 2.1 =
248256
Various updates and improvements. Updated Kint Library.
249257

0 commit comments

Comments
 (0)