Skip to content

PHP warnings for use of __SELF__ #9

@mikky-cecil

Description

@mikky-cecil

First off, this plugin checks so many boxes for us, so thanks for sharing it!

IP whitelisting is working great for the most part, but our logs are full of warnings. I found a fix and thought I'd contribute it in case it could help someone. Of course fixes should be attached to issues, so I'll describe the problem first.

Version information

  • Plugin version : 1.0.5
  • PHP : 7.3
  • WordPress : 5.3.2

Steps to reproduce

  1. Add IP addresses to the whitelist as shown here (Ours is basically this file with different IPs in the mu-plugins directory)
  2. Activate plugin on a WP site with a recent version of PHP (not sure how recent but ours is 7.3)
  3. Visit site logged-out
  4. See wp-content/error.log to see PHP warnings

What was expected

The plugin would determine whether or not your IP was on the whitelist and act accordingly, without warnings.

What happened instead

This functionality does work for now, but the error log warns that it may not work in a future version of PHP:

[04-Mar-2020 00:04:19 UTC] PHP Warning:  Use of undefined constant __SELF__ - assumed '__SELF__' (this will throw an Error in a future version of PHP) in /wp-content/plugins/beapi-maintenance-mode/classes/helpers.php on line 55
[04-Mar-2020 00:04:19 UTC] PHP Warning:  preg_replace_callback(): Requires argument 2, '__SELF__::maintenance_replace_ip', to be a valid callback in /wp-content/plugins/beapi-maintenance-mode/classes/helpers.php on line 55
[04-Mar-2020 00:04:19 UTC] PHP Warning:  Use of undefined constant __SELF__ - assumed '__SELF__' (this will throw an Error in a future version of PHP) in /wp-content/plugins/beapi-maintenance-mode/classes/helpers.php on line 59
[04-Mar-2020 00:04:19 UTC] PHP Warning:  preg_replace_callback(): Requires argument 2, '__SELF__::maintenance_replace_ip', to be a valid callback in /wp-content/plugins/beapi-maintenance-mode/classes/helpers.php on line 59

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions