close

Making WordPress.org

Changeset 14707


Ignore:
Timestamp:
03/13/2026 06:35:07 AM (14 hours ago)
Author:
dd32
Message:

Plugin Directory: Resolve a PHP Deprecation notice in the Cron listings for creation of dynamic properties.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php

    r14606 r14707  
    424424        }
    425425
     426        // Convert to stdClass to avoid dynamic property deprecation on Job objects.
     427        $jobs = array_map( static fn( $job ) => (object) (array) $job, $jobs );
     428
    426429        // Fetch logs for the tasks.
    427430        if ( $with_logs ) {
    428431            $log_table = str_replace( 'jobs', 'logs', \HM\Cavalcade\Plugin\Job::get_table() );
    429             foreach ( $jobs as &$job ) {
    430                 // Fetch logs for the task.
     432            foreach ( $jobs as $job ) {
    431433                $job->logs = $wpdb->get_results(
    432434                    $wpdb->prepare(
     
    445447        // Sort jobs based on last run.
    446448        usort( $jobs, static function( $a, $b ) {
    447             $a_last_log = 0;
    448             $b_last_log = 0;
    449             if ( $a->logs ) {
    450                 $a_last_log = max( array_map( 'strtotime', wp_list_pluck( $a->logs, 'timestamp' ) ) );
    451             }
    452             if ( $b->logs ) {
    453                 $b_last_log = max( array_map( 'strtotime', wp_list_pluck( $b->logs, 'timestamp' ) ) );
    454             }
    455 
    456             $a_last_log = max( $a->start, $a_last_log );
    457             $b_last_log = max( $b->start, $b_last_log );
    458 
    459             return $a_last_log <=> $b_last_log;
     449            $a_last = max( $a->start, ! empty( $a->logs ) ? max( array_map( 'strtotime', wp_list_pluck( $a->logs, 'timestamp' ) ) ) : 0 );
     450            $b_last = max( $b->start, ! empty( $b->logs ) ? max( array_map( 'strtotime', wp_list_pluck( $b->logs, 'timestamp' ) ) ) : 0 );
     451
     452            return $a_last <=> $b_last;
    460453        } );
    461454
Note: See TracChangeset for help on using the changeset viewer.