Make WordPress Core

#63521 closed defect (bug) (duplicate)

fix: Avoid deprecated warnings on WP_Term

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

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.


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

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → 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.