Make WordPress Core

Opened 7 weeks ago

Closed 7 weeks ago

#61415 closed defect (bug) (duplicate)

[PHP 8] Too few arguments to function WP_Widget::__construct()

Reported by: ai5gw's profile ai5gw Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.5.4
Component: Widgets Keywords: has-patch
Focuses: Cc:

Description (last modified by sabernhardt)

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
$this->widgets[ $widget ] = new $widget();

to

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

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

Change History (4)

This ticket was mentioned in PR #6783 on WordPress/wordpress-develop by @ai5gw.


7 weeks ago
#1

  • Keywords has-patch added; needs-patch removed

Fixing a persistent Error that occurs when upgrading to PHP 8.X from a PHP 7.X version. If this fix is not deployed, the error message "Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::construct()" will appear and the entire WordPress site, including the admin area, is not accessible.

Trac ticket: https://core.trac.wordpress.org/ticket/61415

This ticket was mentioned in PR #6784 on WordPress/wordpress-develop by @ai5gw.


7 weeks ago
#2

Fixing a persistent Error that occurs when upgrading to PHP 8.X from a PHP 7.X version. If this fix is not deployed, the error message "Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::construct()" will appear and the entire WordPress site, including the admin area, is not accessible.

#3 @sabernhardt
7 weeks ago

  • Component changed from General to Widgets
  • Description modified (diff)
  • Keywords changes-requested removed
  • Milestone Awaiting Review deleted

Hi, and welcome to WordPress Core Trac!

Thanks for the report. We're already tracking this issue in #56127.

#4 @sabernhardt
7 weeks ago

  • Resolution set to duplicate
  • Status changed from assigned to closed

Duplicate of #56127.

Note: See TracTickets for help on using tickets.