Opened 8 months ago
Closed 8 months ago
#61415 closed defect (bug) (duplicate)
[PHP 8] Too few arguments to function WP_Widget::__construct()
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.5.4 |
Component: | Widgets | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
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.
8 months ago
#1
- Keywords has-patch added; needs-patch removed
This ticket was mentioned in PR #6784 on WordPress/wordpress-develop by @ai5gw.
8 months 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.
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