[wp-trac] [WordPress Trac] #57469: retrieve_widgets(): fatal error when a sidebar's widgets set to null (array is expected)

WordPress Trac noreply at wordpress.org
Tue Aug 8 14:42:32 UTC 2023


#57469: retrieve_widgets(): fatal error when a sidebar's widgets set to null (array
is expected)
--------------------------+----------------------
 Reporter:  kesselb       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Widgets       |     Version:  4.9
 Severity:  normal        |  Resolution:  invalid
 Keywords:  php80 close   |     Focuses:
--------------------------+----------------------
Changes (by hellofromTonya):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Replying to [comment:3 jrf]:
 > To be honest, this sounds like user error and something which should be
 fixed in the theme, not in WP Core.

 I agree. The error flagging `null` as the wrong data type and informing it
 should an `array` has been present for a long time. This is a case of
 doing it wrong.

 I'm all for defensive code to protect Core's source code. However,
 sometimes a native PHP error is appropriate.

 >When changing from PHP 7.4 to PHP 8.0 it's not possible to activate our
 theme.

 I think in this case, not being able to activate a theme is not severe
 enough to warrant adding defensive guard and `_doing_it_wrong()`.

 A user using the theme with the issue upgrading to PHP 8+ would experience
 a fatal error, which would require manual action to restore the site.
 Changing Core's code for this scenario is dependent upon the frequency of
 this scenario happening. But I'm not seeing other reports to `null` for
 widgets causing a fatal error.

 Thus, I tend to agree with @jrf to close this ticket as something to be
 fixed in the theme.

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


More information about the wp-trac mailing list