Make WordPress Core

Opened 5 months ago

Last modified 3 weeks ago

#61675 reopened defect (bug)

wp-activate.php tries to set undefined property

Reported by: skithund's profile skithund Owned by:
Milestone: 6.8 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-patch
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 (10)

This ticket was mentioned in PR #7048 on WordPress/wordpress-develop by @skithund.


5 months ago
#1

  • Keywords has-patch added

Check that cache_enabled property exists on object cache object.

Trac ticket: https://core.trac.wordpress.org/ticket/61675

#2 @SergeyBiryukov
5 months ago

  • Milestone changed from Awaiting Review to 6.7

#3 @jrf
5 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.


4 months ago
#4

  • Keywords has-patch added; needs-patch removed

### Changes Made

  • Added the cache_enabled property to the WP_Object_Cache class.

Trac ticket: https://core.trac.wordpress.org/ticket/61675

#5 @snehapatil02
4 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.

Version 0, edited 4 months ago by snehapatil02 (next)

#6 @sabernhardt
4 months ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

@tillkruess commented on PR #7048:


8 weeks ago
#7

@spacedmonkey Can we get this merged?

#8 @desrosj
7 weeks 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.


3 weeks ago

#10 @desrosj
3 weeks 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.

Note: See TracTickets for help on using tickets.