-1

I have a problem with an old plugin installed on my Wordpress site. Since I updated my php to php 7.4, I am getting the message saying: "Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior". The error is detected on line 454 of UpdateChecker.php file, which is the following:

$cachedResult = (strpos($pluginPath, $muPluginDir) === 0);

Could anyone please help me to solve the issue? I would really appreciate!

Thanks in advance

Cheers

  • Make sure WP is at the latest version as well as the plugin that is throwing the error. Otherwise the error is pretty specific about what the problem is and how you can fix it. – Dave Jan 02 '21 at 12:08
  • Hello @Dave, everything is at the latest version but the plugin giving this error! Unfortunately this is an old but needed plugin which has not been updated from the developer :(.... – Enrico Trevisan Jan 02 '21 at 12:17

1 Answers1

0

As you mention the plugin has not been updated you'll need to update it yourself - the line you reference would need to be something like:

$cachedResult = (strpos($pluginPath, (string)$muPluginDir) === 0);

You may also need to search the plugin for any other instances, or at least keep an eye on your error logs for any other updates required.

If the plugin you're using is open source you may wish to submit the fix once you've tested to the package maintainers (if indeed they're still maintaining it at all).

steve
  • 2,469
  • 1
  • 23
  • 30
  • Hello @steve, thanks for your help. I tried to add your fix which is unfortunately leading tom a new error: Fatal error: Cannot declare class Puc_v4p2_Plugin_UpdateChecker, because the name is already in use in /volume1/web/brazilonheels/wp-content/plugins/rewardstyle-widgets (10)/plugin-update-checker/Puc/v4p2/UpdateChecker.php on line 11 Line 11 has this code: class Puc_v4p2_Plugin_UpdateChecker extends Puc_v4p2_UpdateChecker { Any other suggestion? Thanks again :) – Enrico Trevisan Jan 02 '21 at 12:59
  • That sounds like an unrelated error that's been hidden until now by the previous issue with strpos. The error message is suggesting that perhaps the module is being included twice or the same class is declared twice. If not obviously seeing two instances of the module enabled I'd suggest searching the source code for multiple declarations of 'Puc_v4p2_Plugin_UpdateChecker' – steve Jan 02 '21 at 18:24
  • Thanks @steve, I took a look at it and the initial part of the file is where there's this code: `if ( !class_exists('Puc_v4p2_Plugin_UpdateChecker', false) ): /** * A custom plugin update checker. * * @author Janis Elsts * @copyright 2016 * @access public */ class Puc_v4p2_Plugin_UpdateChecker extends Puc_v4p2_UpdateChecker { protected $updateTransient = 'update_plugins'; protected $translationType = 'plugin';` etc – Enrico Trevisan Jan 02 '21 at 19:07