Opened 2 months ago
Last modified 2 months ago
#62570 new defect (bug)
Fatal error: call to undefined function wp_cache_get() (in option.php)
Reported by: | dugwood | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | major | Version: | 6.7.1 |
Component: | Upgrade/Install | Keywords: | |
Focuses: | Cc: |
Description
Hello,
I've read a lot of issues about the missing wp_cache_get()
function in some cases. And I think I've found some clues.
First, the website must be in Maintenance mode. I've seen a lot of reports on StackOverflow or the like with « upgrading », which is done after enabling the maintenance mode. When this happens, the wp-settings.php
will stop early, avoiding the cache to be loaded.
But plugins, notably the translation plugins, are loaded. And many rely on cache to be present.
One way to deal with this, as we are in maintenance, so degraded status, is to load the default cache functions.
Using WordPress 6.7.1 it should be around line 383 in wp-includes/load.php
:
<?php require_once ABSPATH . WPINC . '/functions.php'; wp_load_translations_early();
Which may be changed as:
<?php require_once ABSPATH . WPINC . '/functions.php'; require_once ABSPATH . WPINC . '/cache.php'; wp_load_translations_early();
This way the translation plugins called in wp_load_translations_early()
would work as expected.
Change History (2)
#2
@
2 months ago
Hey @dugwood, Welcome to Trac, and thanks for bringing this up.
Reproduction Report
Description
This report validates that the issue can be reproduced.
Environment
- WordPress: 6.7.1
- PHP: 8.2.25
- Server: nginx/1.27.2
- Database: mysqli (Server: 8.0.40 / Client: mysqlnd 8.2.25)
- Browser: Chrome 131.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.0
Actual Results
A fatal occurs because wp_cache_get()
is undefined, as cache.php
is not loaded during maintenance mode.
Fatal error: Uncaught Error: Call to undefined function wp_cache_get()
Additional Notes
This issue occurs specifically during WordPress maintenance mode (e.g., during upgrades)
To build up on this: it's one of my patches that calls for
get_locale()
which in turn calls forget_option()
which will call forwp_cache_get()
. So maybe it's not related directly to plugins. But cache should be loaded anyway IMHO.