[wp-trac] [WordPress Trac] #52728: Widgets: Uncaught TypeError in PHP 8 when using objects for settings

WordPress Trac noreply at wordpress.org
Mon Nov 15 23:29:53 UTC 2021


#52728: Widgets: Uncaught TypeError in PHP 8 when using objects for settings
-------------------------------------------+-----------------------------
 Reporter:  dlh                            |       Owner:  hellofromTonya
     Type:  defect (bug)                   |      Status:  reviewing
 Priority:  normal                         |   Milestone:  5.9
Component:  Widgets                        |     Version:  4.3
 Severity:  normal                         |  Resolution:
 Keywords:  has-patch php8 has-unit-tests  |     Focuses:
-------------------------------------------+-----------------------------

Comment (by dlh):

 @hellofromTonya I've updated the last patch and submitted it as a Pull
 Request: https://github.com/WordPress/wordpress-develop/pull/1895

 I've also checked locally that:

 - The test passes with and without the patch in PHP 7.3.
 - The test fails without the patch in PHP 7.4 because of the deprecation
 notice and passes with the patch.

 The problem in my last patch was that I saved the `ArrayObject` instance
 directly to the options table. In PHP 7.3 and earlier, this object is
 serialized in such a way that core's `is_serialized()` doesn't detect it,
 so it's never unserialized on retrieval (see #17375). Because the object
 was never unserialized, it was never used for the widget's options during
 the test, and so the `Test Title` didn't render.

 After re-reading #32474 and my own prior implementations of widget
 objects, I saw that the expected approach is to use the `pre_option_*` or
 `option_*` filters to supply the objects, so that's what happens now in
 the test.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52728#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list