Make WordPress Core

Ticket #56513: 56513-update-for-new-classes.patch

File 56513-update-for-new-classes.patch, 4.5 KB (added by jrf, 2 years ago)

Patch to add teh attribute to new classes introduced in WP 6.1

  • src/wp-includes/class-wp-theme-json-data.php

    From 619b5ec26cfb0914ad6badd9f9368b3b67503e8c Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Sun, 9 Oct 2022 20:00:30 +0200
    Subject: [PATCH] Code Modernization: Add `AllowDynamicProperties` attribute to
     all (parent) classes.
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.
    
    To reduce “noise” in the meantime, both in the error logs of WP users moving onto PHP 8.2, in the test run logs of WP itself, in test runs of plugins and themes, as well as to prevent duplicate tickets from being opened for the same issue, this commit adds the `#[AllowDynamicProperties]` attribute to all “parent” classes in WP.
    
    This commit is an update to the prior patch as committed in [54133].
    
    This commit only affects classes in the `src` directory of WordPress core.
    * Tests should not get this attribute, but should be fixed to not use dynamic properties instead. Patches for this are already being committed under ticket #56033.
    * While a number bundled themes (2014, 2019, 2020, 2021) contain classes, they are not a part of this commit and may be updated separately.
    
    Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].
    
    Follow-up to [53922], [54133].
    
    See #56513, #56034.
    ---
     src/wp-includes/class-wp-theme-json-data.php                     | 1 +
     .../style-engine/class-wp-style-engine-css-declarations.php      | 1 +
     src/wp-includes/style-engine/class-wp-style-engine-css-rule.php  | 1 +
     .../style-engine/class-wp-style-engine-css-rules-store.php       | 1 +
     src/wp-includes/style-engine/class-wp-style-engine-processor.php | 1 +
     src/wp-includes/style-engine/class-wp-style-engine.php           | 1 +
     6 files changed, 6 insertions(+)
    
    diff --git a/src/wp-includes/class-wp-theme-json-data.php b/src/wp-includes/class-wp-theme-json-data.php
    index 089e65eddb..9ffa2f3585 100644
    a b  
    1010/**
    1111 * Class to provide access to update a theme.json structure.
    1212 */
     13#[AllowDynamicProperties]
    1314class WP_Theme_JSON_Data {
    1415
    1516        /**
  • src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php

    diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php b/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php
    index 0b9eb59a15..23efd6a40c 100644
    a b  
    1616 *
    1717 * @since 6.1.0
    1818 */
     19#[AllowDynamicProperties]
    1920class WP_Style_Engine_CSS_Declarations {
    2021
    2122        /**
  • src/wp-includes/style-engine/class-wp-style-engine-css-rule.php

    diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php b/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php
    index 6e53418121..53225d7d65 100644
    a b  
    1616 *
    1717 * @since 6.1.0
    1818 */
     19#[AllowDynamicProperties]
    1920class WP_Style_Engine_CSS_Rule {
    2021
    2122        /**
  • src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php

    diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php b/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php
    index 9b1ed7e706..235fe53e92 100644
    a b  
    1616 *
    1717 * @since 6.1.0
    1818 */
     19#[AllowDynamicProperties]
    1920class WP_Style_Engine_CSS_Rules_Store {
    2021
    2122        /**
  • src/wp-includes/style-engine/class-wp-style-engine-processor.php

    diff --git a/src/wp-includes/style-engine/class-wp-style-engine-processor.php b/src/wp-includes/style-engine/class-wp-style-engine-processor.php
    index 8e035b59ee..241437b204 100644
    a b  
    1616 *
    1717 * @since 6.1.0
    1818 */
     19#[AllowDynamicProperties]
    1920class WP_Style_Engine_Processor {
    2021
    2122        /**
  • src/wp-includes/style-engine/class-wp-style-engine.php

    diff --git a/src/wp-includes/style-engine/class-wp-style-engine.php b/src/wp-includes/style-engine/class-wp-style-engine.php
    index c6554c5dd9..951dac4b54 100644
    a b  
    2121 * @access private
    2222 * @since 6.1.0
    2323 */
     24#[AllowDynamicProperties]
    2425final class WP_Style_Engine {
    2526        /**
    2627         * Style definitions that contain the instructions to