Skip to content

Commit

Permalink
Fix: issue on PHP extension loaded checks (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadNateqi authored Dec 17, 2024
1 parent a86d3f4 commit 55d9e17
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions includes/Settings/SettingsDebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,11 @@ public function get_server_config(): array {
$apc = extension_loaded( 'apc' );
$zop = extension_loaded( 'Zend OPcache' );
$op = extension_loaded( 'opcache' );
$dom = extension_loaded( 'DOM' );
$mbstring = extension_loaded( 'mbstring' );
$gd = extension_loaded( 'gd' );
$zlib = extension_loaded( 'zlib' );
$fileinfo = extension_loaded( 'fileinfo' );

$server_configs = array(
'PHP version' => array(
Expand All @@ -961,18 +966,18 @@ public function get_server_config(): array {
'DOMDocument extension' => array(
'required' => true,
'value' => phpversion( 'DOM' ),
'result' => class_exists( 'DOMDocument' ),
'result' => $dom,
),
'MBString extension' => array(
'required' => true,
'value' => phpversion( 'mbstring' ),
'result' => function_exists( 'mb_send_mail' ),
'result' => $mbstring,
'fallback' => __( 'Recommended, will use fallback functions', 'woocommerce-pdf-invoices-packing-slips' ),
),
'GD' => array(
'required' => true,
'value' => phpversion( 'gd' ),
'result' => function_exists( 'imagecreate' ),
'result' => $gd,
'fallback' => __( 'Required if you have images in your documents', 'woocommerce-pdf-invoices-packing-slips' ),
),
'WebP Support' => array(
Expand All @@ -984,7 +989,7 @@ public function get_server_config(): array {
'Zlib' => array(
'required' => __( 'To compress PDF documents', 'woocommerce-pdf-invoices-packing-slips' ),
'value' => phpversion( 'zlib' ),
'result' => function_exists( 'gzcompress' ),
'result' => $zlib,
'fallback' => __( 'Recommended to compress PDF documents', 'woocommerce-pdf-invoices-packing-slips' ),
),
'opcache' => array(
Expand All @@ -1007,7 +1012,12 @@ public function get_server_config(): array {
),
'WP Memory Limit' => array(
/* translators: <a> tags */
'required' => sprintf( __( 'Recommended: 128MB (more for plugin-heavy setups<br/>See: %1$sIncreasing the WordPress Memory Limit%2$s', 'woocommerce-pdf-invoices-packing-slips' ), '<a href="https://docs.woocommerce.com/document/increasing-the-wordpress-memory-limit/" target="_blank">', '</a>' ),
'required' => __( 'Recommended: 128MB (especially for plugin-heavy setups)', 'woocommerce-pdf-invoices-packing-slips' ) . '<br/>' . sprintf(
/* translators: 1: opening anchor tag, 2: closing anchor tag */
__( 'See: %1$sIncreasing the WordPress Memory Limit%2$s', 'woocommerce-pdf-invoices-packing-slips' ),
'<a href="https://docs.woocommerce.com/document/increasing-the-wordpress-memory-limit/" target="_blank">',
'</a>'
),
'value' => sprintf( 'WordPress: %s, PHP: %s', WP_MEMORY_LIMIT, $php_mem_limit ),
'result' => $memory_limit > 67108864,
),
Expand All @@ -1020,7 +1030,7 @@ public function get_server_config(): array {
'fileinfo' => array (
'required' => __( 'Necessary to verify the MIME type of local images.', 'woocommerce-pdf-invoices-packing-slips' ),
'value' => null,
'result' => extension_loaded( 'fileinfo' ),
'result' => $fileinfo,
'fallback' => __( 'fileinfo disabled', 'woocommerce-pdf-invoices-packing-slips' ),
),
'base64_decode' => array (
Expand Down Expand Up @@ -1089,7 +1099,7 @@ public function handle_server_requirement_notice(): void {
$server_configs = $this->get_server_config();

foreach ( $server_configs as $config_name => $config ) {
if ( in_array( $config_name, array( 'opcache', 'GMagick or IMagick' ), true ) ) {
if ( in_array( $config_name, array( 'opcache', 'GMagick or IMagick', 'WP Memory Limit' ), true ) ) {
continue;
}

Expand Down

0 comments on commit 55d9e17

Please sign in to comment.