Make WordPress Core

Opened 8 months ago

Closed 8 months ago

#63521 closed defect (bug) (duplicate)

fix: Avoid deprecated warnings on WP_Term

Reported by: jose-lazo's profile Jose Lazo Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.8
Component: Taxonomy Keywords: dev-feedback has-patch
Focuses: php-compatibility Cc:

Description

WP version: 6.8
PHP version: 8.2
Environment: Official Docker image with WP_UnitTest

Adding a unit test environment using WP_UnitTests, xdebug throws several
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated warnings.

The issue points to the _make_cat_compat function because it tries to assign values ​​to object properties that are not defined in WP_Term.

I suggest defining the old properties on WP_Terms

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 383
 ✔ Exclude ab test from query method

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 381

After the fix:

AB_Test_Post_ (ThemeName\Tests\Theme\Growth\AB_Test_Post_)
 ✔ Alter post query method
 ✔ Add ab test post meta
 ✔ Maybe add no index meta tag method
 ✔ Render ab test settings meta box method
 ✔ Exclude ab test from query method
 ✔ Save ab test settings
 ✔ Add canonical url

Change History (2)

This ticket was mentioned in PR #8889 on WordPress/wordpress-develop by @Jose Lazo.


8 months ago
#1

  • Keywords has-patch added

WP version: 6.8
PHP version: 8.2
Environment: Official Docker image with WP_UnitTest

Adding a unit test environment using WP_UnitTests, xdebug throws several
Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated warnings.

The issue points to the _make_cat_compat function because it tries to assign values ​​to object properties that are not defined in WP_Term.

I suggest defining the old properties on WP_Terms

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 383
 ✔ Exclude ab test from query method

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /var/www/html/wp-content/themes/themename/tests/wordpress-develop/src/wp-includes/category.php on line 381

After the fix:

AB_Test_Post_ (ThemeName\Tests\Theme\Growth\AB_Test_Post_)
 ✔ Alter post query method
 ✔ Add ab test post meta
 ✔ Maybe add no index meta tag method
 ✔ Render ab test settings meta box method
 ✔ Exclude ab test from query method
 ✔ Save ab test settings
 ✔ Add canonical url

#2 @SergeyBiryukov
8 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome back to WordPress Trac!

Thanks for the ticket, we're already tracking this issue in #61890.

Note: See TracTickets for help on using tickets.