Skip to content

Commit

Permalink
Fixed open_basedir restriction warning in Query Monitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Nov 6, 2024
1 parent 3f8c7ad commit af2613b
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ Instructions for popular native integrations are below:
* Fixed inability to deactivate Avada theme right after activation.
* Fixed inability to deactivate Divi theme right after activation.
* Fixed error on plugin activation when plugin makes redirect on activation.
* Fixed open_basedir restriction warning in Query Monitor.
* Tested with WordPress 6.7.
* Tested with WooCommerce 9.3.

Expand Down
4 changes: 2 additions & 2 deletions src/php/Helpers/HCaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace HCaptcha\Helpers;

use HCaptcha\Vendors\MatthiasMullie\Minify\CSS;
use HCaptcha\Vendors\MatthiasMullie\Minify\JS;
use HCaptcha\Helpers\Minify\CSS;
use HCaptcha\Helpers\Minify\JS;
use WP_Error;

/**
Expand Down
36 changes: 36 additions & 0 deletions src/php/Helpers/Minify/CSS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* CSS class file.
*
* @package hcaptcha-wp
*/

namespace HCaptcha\Helpers\Minify;

use HCaptcha\Vendors\MatthiasMullie\Minify\CSS as MinifyCSS;

/**
* Class CSS.
*/
class CSS extends MinifyCSS {

/**
* Check if the path is a regular file and can be read.
*
* @param string $path A path.
*
* @return bool
* @noinspection PhpMissingReturnTypeInspection
* @noinspection ReturnTypeCanBeDeclaredInspection
*/
protected function canImportFile( $path ) {
// It is the fix of the library code.
// The realpath() function does not throw warning when file does not exist.
// In the parent method, is_file is silenced, but with the Query Monitor plugin, it becomes visible.
if ( ! realpath( $path ) ) {
return \false;
}

return parent::canImportFile( $path );
}
}
36 changes: 36 additions & 0 deletions src/php/Helpers/Minify/JS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* JS class file.
*
* @package hcaptcha-wp
*/

namespace HCaptcha\Helpers\Minify;

use HCaptcha\Vendors\MatthiasMullie\Minify\JS as MinifyJS;

/**
* Class JS.
*/
class JS extends MinifyJS {

/**
* Check if the path is a regular file and can be read.
*
* @param string $path A path.
*
* @return bool
* @noinspection PhpMissingReturnTypeInspection
* @noinspection ReturnTypeCanBeDeclaredInspection
*/
protected function canImportFile( $path ) {
// It is the fix of the library code.
// The realpath() function does not throw warning when file does not exist.
// In the parent method, is_file is silenced, but with the Query Monitor plugin, it becomes visible.
if ( ! realpath( $path ) ) {
return \false;
}

return parent::canImportFile( $path );
}
}

0 comments on commit af2613b

Please sign in to comment.