[wp-trac] [WordPress Trac] #61415: [PHP 8] Too few arguments to function WP_Widget::__construct()

WordPress Trac noreply at wordpress.org
Tue Jun 11 20:53:33 UTC 2024


#61415: [PHP 8] Too few arguments to function WP_Widget::__construct()
--------------------------+-------------------------------------------
 Reporter:  ai5gw         |      Owner:  (none)
     Type:  defect (bug)  |     Status:  assigned
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.5.4
 Severity:  normal        |   Keywords:  needs-patch changes-requested
  Focuses:                |
--------------------------+-------------------------------------------
 When upgrading from PHP 7.X to PHP 8.X, there might be a "Fatal error:
 Uncaught ArgumentCountError: Too few arguments to function
 WP_Widget::__construct()" error. This will prevent access to the entire
 website, including the admin area. The fix is, however, quite simple:

 In "/wp-includes/class-wp-widget-factory.php" change line 62 from

 {{{#!php
 <?php
 $this->widgets[ $widget ] = new $widget();
 }}}

 to

 {{{#!php
 <?php
 $this->widgets[ $widget ] = new $widget( $widget, $widget );
 }}}

 Disovered and tested in WordPress version 6.5.4 when upgrading from PHP
 7.4 to 8.2.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61415>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list