Opened 20 months ago
Closed 5 months ago
#61675 closed defect (bug) (fixed)
wp-activate.php tries to set undefined property
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Networks and Sites | Keywords: | has-patch early |
| Focuses: | multisite, php-compatibility | Cc: |
Description
wp-activate.php tries to set cache_enabled property, which doesn't exist on all object cache implementations, triggering Creation of dynamic property WP_Object_Cache::$cache_enabled is deprecated error on PHP 8.2.
<?php if ( is_object( $wp_object_cache ) ) { $wp_object_cache->cache_enabled = false; } ?>
Change History (21)
This ticket was mentioned in PR #7048 on WordPress/wordpress-develop by @skithund.
20 months ago
#1
- Keywords has-patch added
#3
@
20 months ago
- Keywords needs-patch added; has-patch removed
@skithund Thank you for reporting this. This shouldn't be possible with the WP native object cache classes as the #[AllowDynamicProperties] attribute is set.
Having said this, as the property is explicitly used and set in WP Core, I think it would be prudent to make this property an explicitly declared one on the WP_Object_Cache class anyhow (visibility: public) with documentation stating that "overload" classes should declare that property.
As for existing "overload" classes, I believe patches would be needed to explicitly declare the property on those as well.
While the patch proposed protects against the deprecation notice, it does not work with magic methods in place (which the WP_Object_Cache class has), so as things are, it would effectively disable the cache in most cases, which would break the functionality, which I don't think is your intention.
Also see: https://3v4l.org/kLAYu
This ticket was mentioned in PR #7132 on WordPress/wordpress-develop by @snehapatil02.
20 months ago
#4
- Keywords has-patch added; needs-patch removed
### Changes Made
- Added the
cache_enabledproperty to theWP_Object_Cacheclass.
Trac ticket: https://core.trac.wordpress.org/ticket/61675
#5
@
20 months ago
- Resolution set to invalid
- Status changed from new to closed
@jrf I've updated the WP_Object_Cache class to explicitly declare the cache_enable property and documented it accordingly. Please review the PR.
@tillkruess commented on PR #7048:
17 months ago
#7
@spacedmonkey Can we get this merged?
#8
@
17 months ago
- Milestone changed from 6.7 to 6.7.1
Unfortunately, this one missed the boat with 6.7 RC1 due out any moment. I'm going to punt this to 6.7.1 for consideration in the next minor release.
This ticket was mentioned in Slack in #core by desrosj. View the logs.
16 months ago
#10
@
16 months ago
- Milestone changed from 6.7.1 to 6.8
Because of a few bug reports opened since 6.7 was released, the Core team is evaluating the need for a short 6.7.1 cycle (possibly next week).
To help prepare for this scenario in case it's decided to move forward, I'm going to punt this one. This issue was not introduced in 6.7, so it now falls outside of the focus for 6.7.1 as currently defined.
Also, I'm choosing 6.8 instead of 6.7.2 because it seems this may be better suited for a major release in order to properly communicate and test.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
13 months ago
@audrasjb commented on PR #7048:
13 months ago
#12
@spacedmonkey is this ticket/PR still on your plate for 6.8?
@spacedmonkey commented on PR #7048:
13 months ago
#13
No it isn't sadly.
#14
@
13 months ago
- Keywords early added
- Milestone changed from 6.8 to 6.9
- Owner set to spacedmonkey
- Status changed from reopened to assigned
Sadly I run out of time to look at this one in this release. I assigning to myself and punting to WP 6.9 and early.
#15
@
8 months ago
I wonder if this needs a better solution than: https://github.com/WordPress/wordpress-develop/blob/54a06f8972bba2443d624372270f1ad666bcc55f/src/wp-activate.php#L67-L69
#16
follow-ups:
↓ 17
↓ 18
↓ 19
@
6 months ago
- Keywords commit added
I think the patch from @skithund looks good. Marking as ready to commit.
#17
in reply to:
↑ 16
@
5 months ago
Reproduction Report
Description
This report validates whether the issue can be reproduced.
Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.1
- Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
- Browser: Chrome 140.0.0.0
- OS: Linux
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
- Redis Object Cache 2.6.3
- Test Reports 1.2.0
Steps to reproduce
- Enable multisite & debugging
- Allow new registrations in Network Settings
- Register new site
- Check the
/wp-activate.php?key=
Actual Results
- ❌ Could not reproduce the reported issue under this environment.
- No deprecation notice or undefined property warning appeared during site activation, as well as on the debug.log.
Additional Notes
- Tested on Multisite with the Redis Object Cache plugin active.
- The issue may only be reproducible with older or custom object-cache drop-ins that omit this property.
Supplemental Artifacts
#18
in reply to:
↑ 16
@
5 months ago
Replying to spacedmonkey:
I think the patch from @skithund looks good. Marking as ready to commit.
@skithund PR on https://github.com/WordPress/wordpress-develop/pull/7048 is closed bdw, but I couldn't reproduce using 8.2.29
#19
in reply to:
↑ 16
@
5 months ago
- Keywords commit removed
Replying to spacedmonkey:
I think the patch from @skithund looks good. Marking as ready to commit.
It appears that PR 7048 would not work as expected, see comment:3:
While the patch proposed protects against the deprecation notice, it does not work with magic methods in place (which the
WP_Object_Cacheclass has), so as things are, it would effectively disable the cache in most cases, which would break the functionality, which I don't think is your intention.
Also see: https://3v4l.org/kLAYu
#20
@
5 months ago
Some history here:
- [3011] introduced the
WP_Object_Cache::$cache_enabledproperty along with the class. - [6539] removed the property when persistent cache was removed from core.
- mu:1298 introduced this check in both
wp-activate.phpandwpmu_create_blog(). - mu:1319 then removed the check (“No need for this debugging code”), but only in
wpmu_create_blog().
Older external object cache implementations, e.g. Memcached or APC, still declare the property, but it does not affect anything aside from being declared.
While the patch proposed protects against the deprecation notice, it does not work with magic methods in place (which the
WP_Object_Cacheclass has), so as things are, it would effectively disable the cache in most cases, which would break the functionality, which I don't think is your intention.
Rereading this again, it appears that attempting to disable the cache for wp-activate.php and wpmu_create_blog() was indeed the original intention here, but since it was subsequently removed from the latter, it should be safe to remove it from the former too, as this is a remnant from the WPMU merge and has not been doing anything in practice for the last 17 years or so.

Check that
cache_enabledproperty exists on object cache object.Trac ticket: https://core.trac.wordpress.org/ticket/61675