1

I have a crazy bug I cannot figure out. I recently upgraded to PHP 8.2 and Wordpress 6.3. At about the same time, I was trying to prevent spam registrations, so I added reCaptcha to the login and registration page via WordFence plugin (and later disabled that). Somewhere amidst my insufficent testing, our site lost the ability to let new users regisiter, and I am not sure what change it happened after, because I made a ton of changes all at once (I know... bad habit.)

I have looked through all of the code, and if I write wp query for the users_can_register option, I get the correct value, but the get_option() function returns an empty string, so registration is disabled and I cannot reenable it. I cannot get the wp-admin General Settings page to display or save the checkbox for "Anyone can Register" (and yet, the option value IS set to 1 in the database).

I can only figure some other plugin is messing with what get_option('users_can_register') returns. We added a bunch of error logging to the wordpress core files in those functions, and I still am just stumped.

Can anyone help me think of another place to look? We have tried disabling all plugins and using the Twenty Twentythree theme, and it still has the same problem. Oh, at one point I tried downgrading to WP 6.2.2 using a plugin, and that didn't fix it either. I reinstalled WP 6.3.

I should note that I may still have some deprecation errors in various plugins related to PHP 8 that need to be fixed but I don't think they have anything to do with getting the wp_option value. The get_option value returns the correct value for every other wp_option we test (e.g. blogname, etc). The problem does not happen on my local machine in my MAMP testing environment, so I think something is corrupted in production... but what?

Also, my block editor for pages and posts broke when I upgraded and I had to fix it by installing the Gutenberg plugin.

What else could it be?

Tried: -disabling plugins -2023 theme -error logging added to wp-admin/options.php and options-general.php -writing a PHP page to test the get_option calls directly for the users_can_regiter key and others

  • checked error logs
  • cleared cache
  • this is Elastic Beanstalk default nginx platform on AWS
  • deployed new code bundle on same EC2 instance
  • can provide a list of other installed plugins, including WordFence, W3TC, Event Espresso (highly customized), and more.

Thanks!

LauraSuzy
  • 11
  • 2

1 Answers1

0

Usually when get_option('users_can_register') returns "" (empty string), the value stored in the database is either NULL or false. However, some plugins may use hooks to change the value after it is retrieved from the database. So even if the value you are seeing in the database is "correct", a plugin may still be overriding it via one of these hooks:

apply_filters( "default_option_users_can_register", ...);
apply_filters( "option_users_can_register", ...);
apply_filters( "pre_option_users_can_register", ...);

Other than this, in similar issues I've encountered usually end up being:

  • One or more plugins are not compatible with PHP 8.2
  • A required PHP library missing or not available in the upgraded PHP version
  • The wp-config.php has either changed define( 'DB_CHARSET',...) or define( 'DB_COLLATE', ... ); between versions and/or is different to the database/table compared to local/dev/test environment.

Ensure all logging is on debug when you test & if you can capture an error in the log, please add it to the question to help diagnose the cause.

S.Walsh
  • 3,105
  • 1
  • 12
  • 23
  • Thank you! I am checking those things. I have searched all of the code and do not see any of those hooks being used in my plugins. We have confirmed that the value in the database is indeed correct and the get_option call returns the correct value for every other option, so that would rule out a DB config or PHP config problem, right? It must be a plugin somehow...?? – LauraSuzy Aug 21 '23 at 16:46
  • in wp-config.php, DB settings have not changed, and are: define('DB_CHARSET', 'utf8'); and define('DB_COLLATE', ''); – LauraSuzy Aug 21 '23 at 16:47
  • @LauraSuzy The next step I would take is to clone the environment and restrict access to it so you can disable all plugins. Next, test if with no plugins active the option works, then one by one enable the plugins and retest and see if you can trigger some relevant error in the log. Not ideal, I know.. but otherwise it's hard to find the cause. – S.Walsh Aug 23 '23 at 02:08