Make WordPress Core

Opened 14 months ago

Closed 11 days ago

Last modified 11 days ago

#62542 closed defect (bug) (fixed)

TypeError in class-wp-plugins-list-table.php due to invalid $time value.

Reported by: azora's profile azora Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.0 Priority: normal
Severity: critical Version: 6.7.1
Component: Plugins Keywords: has-patch
Focuses: administration Cc:

Description (last modified by sabernhardt)

A fatal error occurred due to the latest update and is causing problems in the database. Even after I disabled all plugins and installed older wordpress versions, the problem remains due to the cron.

[22-Nov-2024 22:43:55 UTC] PHP Notice:  Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>astra</code> domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the <code>init</code> action or later. Please see <a href="https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0.) in /.../wp-includes/functions.php on line 6114
[22-Nov-2024 22:43:55 UTC] PHP Notice:  Function _load_textdomain_just_in_time was called <strong>incorrectly</strong>. Translation loading for the <code>astra</code> domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the <code>init</code> action or later. Please see <a href="https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.7.0.) in /.../wp-includes/functions.php on line 6114

[22-Nov-2024 22:43:55 UTC] PHP Fatal error:  Uncaught TypeError: Unsupported operand types: string + int in /.../wp-admin/includes/class-wp-plugins-list-table.php:189
Stack trace:
#0 /.../wp-admin/plugins.php(553): WP_Plugins_List_Table->prepare_items()
#1 {main}
  thrown in /.../wp-admin/includes/class-wp-plugins-list-table.php on line 189

The error comes from this function:

foreach ( $recently_activated as $key => $time ) {
    if ( $time + WEEK_IN_SECONDS < time() ) {
        unset( $recently_activated[ $key ] );
    }
}

My correction:

foreach ( $recently_activated as $key => $time ) {
    if ( (int) $time + WEEK_IN_SECONDS < time() ) {
        unset( $recently_activated[ $key ] );
    }
}

The problem has been fixed for me.

Change History (7)

#1 @sabernhardt
14 months ago

  • Component changed from General to Plugins
  • Description modified (diff)
  • Focuses administration added

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


14 months ago
#2

  • Keywords has-patch added; needs-patch removed

#3 @umeshsinghin
14 months ago

Hi @azora, the suggested changes have been implemented.

#4 @deepakrohilla
14 months ago

@umeshsinghin The PR looks good to me.

@narenin commented on PR #7875:


14 months ago
#5

@umeshsinghin Good catch!
The PR looks good to me.

#6 @SergeyBiryukov
11 days ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 61481:

Plugins: Remove incorrect entries from the recently_activated option array.

This aims to avoid a fatal error if the array was somehow corrupted and contains non-numeric values.

Follow-up to [8049].

Props umeshsinghin, azora, sabernhardt, deepakrohilla, narenin, SergeyBiryukov.
Fixes #62542.

#7 @SergeyBiryukov
11 days ago

  • Milestone changed from Awaiting Review to 7.0

Hi there, thanks for the ticket!

$time appears to always be an integer in this code in my testing, so the type casting might seem redundant.

I think we can remove any non-integer values from the recently_activated array instead, see [61481].

Note: See TracTickets for help on using tickets.