updatescheck.php and php 7.4
-
We are having troubles running the updatescheck.php with php 7.4 and getting a depreciation error. What is the maximum PHP version that can be run with MainWP for the cron jobs?
PHP Deprecated: Array and string offset access syntax with curly braces is deprecated in (….) wp-content/plugins/mainwp/class/class-mainwp-utility.php on line 2126
PHP Stack trace:(…)Thank you
-
Update from developer (post here for convenience of others): (we are running php 7.4.5 as well – when we had the error);
————–
As per our testing, everything works fine on our test servers where we run PHP 7.4.5Running with php 7.3 works for us, so, take it for whatever works for you.
php7.3 (…)/wp-content/plugins/mainwp/cron/updatescheck.php
(no errors emitted).
I ran PHP CodeSniffer on the mainwp/ folder on my installation. This is what I found testing for WordPress PHP 7.4 compatibility:
FILE: .../mainwp/wp-content/plugins/mainwp/class/class-mainwp-creport.php ---------------------------------------------------------------------- FOUND 6 ERRORS AND 1 WARNING AFFECTING 7 LINES ---------------------------------------------------------------------- 1246 | WARNING | Function create_function() is deprecated since PHP | | 7.2; Use an anonymous function instead 2828 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 2836 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 2844 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 2852 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 2860 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 2868 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead ---------------------------------------------------------------------- FILE: .../mainwp/wp-content/plugins/mainwp/class/class-mainwp-utility.php ---------------------------------------------------------------------- FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES ---------------------------------------------------------------------- 846 | WARNING | [ ] INI directive 'safe_mode' is deprecated since | | PHP 5.3 and removed since PHP 5.4 1121 | WARNING | [ ] INI directive 'safe_mode' is deprecated since | | PHP 5.3 and removed since PHP 5.4 1651 | WARNING | [ ] INI directive 'safe_mode' is deprecated since | | PHP 5.3 and removed since PHP 5.4 2126 | WARNING | [x] Curly brace syntax for accessing array elements | | and string offsets has been deprecated in PHP | | 7.4. Found: $Str{$i} 2163 | WARNING | [x] Curly brace syntax for accessing array elements | | and string offsets has been deprecated in PHP | | 7.4. Found: $HashStr{$i} ---------------------------------------------------------------------- FILE: ..._html/mainwp/wp-content/plugins/mainwp/class/class-mainwp-db.php ---------------------------------------------------------------------- FOUND 7 ERRORS AFFECTING 7 LINES ---------------------------------------------------------------------- 1925 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 1933 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 1945 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 1957 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 1969 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 1981 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead 1993 | ERROR | Extension 'mysql_' is deprecated since PHP 5.5 and | | removed since PHP 7.0; Use mysqli instead ---------------------------------------------------------------------- FILE: ...-content/plugins/mainwp/pages/page-mainwp-server-information.php ---------------------------------------------------------------------- FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE ---------------------------------------------------------------------- 864 | WARNING | INI directive 'safe_mode' is deprecated since PHP | | 5.3 and removed since PHP 5.4 ----------------------------------------------------------------------
The findings in class-mainwp-utility.php are warnings, and shouldn’t prevent anything from running.
Thank you linux4me2. Will take another look to see if we can get 7.4 working on our site and post back there.
You’re welcome! Good luck with it. Please post back with your results. I was planning on upgrading to PHP 7.4.x once they release a compatible version of IonCube for it.
I didn’t look at the code, but the errors PHP CodeSniffer found may be in there for backward compatibility, and not run with PHP >= 7.x, so they may not be an issue.
The lines are in wp-content/plugins/mainwp/class/class-mainwp-utility.php
Changing lines 2126 and 2163 from:
– in protected static function StrToNum( $Str, $Check, $Magic ) {$Check += ord( $Str{$i} );
to
$Check += ord( $Str[$i] );and
– in protected static function CheckHash( $Hashnum ) {$Re = $HashStr{$i};
to
$Re = $HashStr[$i];Makes it work under php 7.4 (at least not emit errors and the return code is 0). Not sure about the validity of the fix for sure though, other than the suggestion based on the error output.
Hi @hutman, since you have already opened a support ticket, we will continue there.
Hi @linux4me2, PHP Compatibility Scanner is giving false positives since it doesn’t check code context. Deprecated functions are never executed on the unsupported version.
Yes, I’ve noticed that with PHP CodeSniffer in the past. I suspected you had them in there for backward compatibility.
Code changes seem to have fixed it for us.
- The topic ‘updatescheck.php and php 7.4’ is closed to new replies.