WPIntell

Source evidence

PHP Warnings on every update

Easy Theme and Plugin Upgrades · support · 2019-10-19T02:37:00+00:00

mixedsentiment
highseverity
0.95relevance
5replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 34 rows with source links

11.8% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

30 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Stilian resolved
Hi, I get the following PHP error every time I update a plugin (not from WordPress repository) using your plugin: PHP Warning: php_uname() has been disabled for security reasons in /var/www/wptbox/wp-admin/includes/class-pclzip.php on line 5677 Also, this error is reported hundreds of times on each update! I have to scroll all the way down to click the “Activate” button. Here’s the section of the file’s referenced line: // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilTranslateWinPath() // Description : // Translate windows path by replacing '\' by '/' and optionally removing // drive letter. // Parameters : // $p_path : path to translate. // $p_remove_disk_letter : true | false // Return Values : // The path translated. // -------------------------------------------------------------------------------- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) { if (stristr(php_uname(), 'windows')) { // ----- Look for potential disk letter if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { $p_path = substr($p_path, $v_position+1); } // ----- Change potential windows directory separator if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } // -------------------------------------------------------------------------------- Do you know why this happens? It’s quite annoying, could you do something about it? Thanks. The warning occurs because the site’s hosting config disabled the php_uname function. Some hosting companies do this for various reasons. (Typically because it’s thought to improve security. I disagree that disabling the function does anything to improve security, but I digress.) Unfortunately, there isn’t anything I can change in the plugin to fix the problem. You would get the same warnings if this plugin was deactivated and you installed a new plugin on the site. The problem would remain because all the unzipping is done using code in WordPress and not from this plugin. You have the following options: Disable WP_DEBUG mode on the site so that warnings do not render in the page output. Have your host install the PHP ZipArchive library. This is typically listed as the php-zip library in operating system package managers. WordPress only uses the PclZip library if ZipArchive isn’t present. So, having ZipArchive present would bypass the issue. I wouldn’t expect the host to do this, but it is an option. I should note that most quality hosts provide this library. Have your host enable use of the php_uname function. As with #2, I wouldn’t expect the host to do this and most quality hosts do not disable this function. Change hosts. This reply was modified 6 years, 7 months ago by Chris Jean . This reply was modified 6 years, 7 months ago by Chris Jean . Hi, thanks for your detailed answer! I contacted my host’s support and they confirmed that they have php-zip enabled. They suggested that maybe some specific setting should be turned on (in your plugin?) for using php-zip library instead of PclZip library. Is that an option? All the unzipping logic is from WordPress and not the plugin, so there isn’t anything that I can control from the plugin. The logic in WP is fairly simple: /** * Filters whether to use ZipArchive to unzip archives. * * @since 3.0.0 * * @param bool $ziparchive Whether to use ZipArchive. Default true. */ if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) { $result = _unzip_file_ziparchive( $file, $to, $needed_dirs ); if ( true === $result ) { return $result; } elseif ( is_wp_error( $result ) ) { if ( 'incompatible_archive' != $result->get_error_code() ) { return $result; } } } // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file. return _unzip_file_pclzip( $file, $to, $needed_dirs ); Given the logic and how PclZip is being used, the possible explanations are: The ZipArchive class is not present which would indicate that the php-zip library is not installed or properly configured. Something is disabling ZipArchive using the unzip_file_use_ziparchive filter. This plugin does not touch that filter. If this filter is the cause, it would be from a different plugin, the theme, or some other config such as an mu-plugin. The ZipArchive class is having problems unzipping archives. In the event that ZipArchive is available and not disabled by the filter, PclZip will be tried if unzipping using ZipArchive failed with an error code other than incompatible_archive . The code doesn’t log or display the specific error, so if this is happening, someone with access to the system would have to debug the code to find out what the error is. Perhaps with those specific error details, the problem with ZipArchive could be found and corrected. This reply was modified 6 years, 7 months ago by Chris Jean . I contacted my host again, and the issue is indeed on their end. They said that the function is disabled on the server for security reasons. So there’s nothing I can do. Thank you Chris for responding with such professionalism and knowledge. I hope you’re rewarded for your work as much as you deserve. Cheers! Glad to help. Sorry to hear that your host disables so much functionality. I find that a bad sign when looking at a host, but that’s just me editorializing.

Comments

5 shown
Chris Jean 2019-10-21T21:47:00+00:00

The warning occurs because the site’s hosting config disabled the php_uname function. Some hosting companies do this for various reasons. (Typically because it’s thought to improve security. I disagree that disabling the function does anything to improve security, but I digress.) Unfortunately, there isn’t anything I can change in the plugin to fix the problem. You would get the same warnings if this plugin was deactivated and you installed a new plugin on the site. The problem would remain because all the unzipping is done using code in WordPress and not from this plugin. You have the following options: Disable WP_DEBUG mode on the site so that warnings do not render in the page output. Have your host install the PHP ZipArchive library. This is typically listed as the php-zip library in operating system package managers. WordPress only uses the PclZip library if ZipArchive isn’t present. So, having ZipArchive present would bypass the issue. I wouldn’t expect the host to do this, but it is an option. I should note that most quality hosts provide this library. Have your host enable use of the php_uname function. As with #2, I wouldn’t expect the host to do this and most quality hosts do not disable this function. Change hosts. This reply was modified 6 years, 7 months ago by Chris Jean . This reply was modified 6 years, 7 months ago by Chris Jean .

Stilian 2019-10-22T13:50:00+00:00

Hi, thanks for your detailed answer! I contacted my host’s support and they confirmed that they have php-zip enabled. They suggested that maybe some specific setting should be turned on (in your plugin?) for using php-zip library instead of PclZip library. Is that an option?

Chris Jean 2019-10-22T15:09:00+00:00

All the unzipping logic is from WordPress and not the plugin, so there isn’t anything that I can control from the plugin. The logic in WP is fairly simple: /** * Filters whether to use ZipArchive to unzip archives. * * @since 3.0.0 * * @param bool $ziparchive Whether to use ZipArchive. Default true. */ if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) { $result = _unzip_file_ziparchive( $file, $to, $needed_dirs ); if ( true === $result ) { return $result; } elseif ( is_wp_error( $result ) ) { if ( 'incompatible_archive' != $result->get_error_code() ) { return $result; } } } // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file. return _unzip_file_pclzip( $file, $to, $needed_dirs ); Given the logic and how PclZip is being used, the possible explanations are: The ZipArchive class is not present which would indicate that the php-zip library is not installed or properly configured. Something is disabling ZipArchive using the unzip_file_use_ziparchive filter. This plugin does not touch that filter. If this filter is the cause, it would be from a different plugin, the theme, or some other config such as an mu-plugin. The ZipArchive class is having problems unzipping archives. In the event that ZipArchive is available and not disabled by the filter, PclZip will be tried if unzipping using ZipArchive failed with an error code other than incompatible_archive . The code doesn’t log or display the specific error, so if this is happening, someone with access to the system would have to debug the code to find out what the error is. Perhaps with those specific error details, the problem with ZipArchive could be found and corrected. This reply was modified 6 years, 7 months ago by Chris Jean .

Stilian 2019-10-22T17:49:00+00:00

I contacted my host again, and the issue is indeed on their end. They said that the function is disabled on the server for security reasons. So there’s nothing I can do. Thank you Chris for responding with such professionalism and knowledge. I hope you’re rewarded for your work as much as you deserve. Cheers!

Chris Jean 2019-10-22T19:00:00+00:00

Glad to help. Sorry to hear that your host disables so much functionality. I find that a bad sign when looking at a host, but that’s just me editorializing.