Make WordPress Core

Opened 4 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.7.1 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 (8)

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


4 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
4 months ago

  • Milestone changed from Awaiting Review to 6.7

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


3 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
3 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.

Last edited 3 months ago by snehapatil02 (previous) (diff)

#6 @sabernhardt
3 months ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

@tillkruess commented on PR #7048:


4 weeks ago
#7

@spacedmonkey Can we get this merged?

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

Note: See TracTickets for help on using tickets.