[wp-trac] [WordPress Trac] #61415: [PHP 8] Too few arguments to function WP_Widget::__construct()
WordPress Trac
noreply at wordpress.org
Tue Jun 11 22:16: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:
Component: Widgets | Version: 6.5.4
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+-----------------------
Changes (by sabernhardt):
* keywords: changes-requested has-patch => has-patch
* component: General => Widgets
* milestone: Awaiting Review =>
Old description:
> 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.
New description:
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 );
}}}
Discovered and tested in WordPress version 6.5.4 when upgrading from PHP
7.4 to 8.2.
--
Comment:
Hi, and welcome to WordPress Core Trac!
Thanks for the report. We're already tracking this issue in #56127.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61415#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list