WordPress.org

Making WordPress.org

Changeset 8918


Ignore:
Timestamp:
06/05/2019 04:34:52 AM (3 months ago)
Author:
dd32
Message:

Plugin Directory: Jobs: Update the Tested-up-to version in the API update-check endpoints when the plugin directory automatically bumps the tested-up-to value for plugins.

This also runs the 'Meta Sync' cron task whenever a new WordPress release is made, to help speed up the rate at which Plugins show the latest version in their 'tested' fields.

Fixes #4468.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
3 edited

Legend:

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

    r8902 r8918  
    885885            }
    886886
    887             // Trim off special characters, only allowing wordy characters at the end of searches.s
     887            // Trim off special characters, only allowing wordy characters at the end of searches.
    888888            $s = preg_replace( '!(\W+)$!i', '', $s );
    889889            // ..and whitespace
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-manager.php

    r8461 r8918  
    234234     *
    235235     * The jobs are queued for 1 minutes time to avoid recurring job failures from repeating too soon.
     236     *
     237     * This method is called on wp-admin pageviews and on a two-minutely cron task.
    236238     */
    237239    public function register_cron_tasks() {
     
    249251        }
    250252        if ( ! wp_next_scheduled( 'plugin_directory_check_cronjobs' ) ) {
     253            // This function
    251254            wp_schedule_event( time() + 60, 'every_120s', 'plugin_directory_check_cronjobs' );
    252255        }
    253256        if ( ! wp_next_scheduled ( 'plugin_directory_translation_sync' ) ) {
    254257            wp_schedule_event( time() + 60, 'daily', 'plugin_directory_translation_sync' );
     258        }
     259
     260        // Check to see if `WP_CORE_LATEST_RELEASE` has changed since we last ran.
     261        if ( defined( 'WP_CORE_LATEST_RELEASE' ) && get_option( 'plugins_last_core_release_seen' ) !== WP_CORE_LATEST_RELEASE ) {
     262            update_option( 'plugins_last_core_release_seen', WP_CORE_LATEST_RELEASE );
     263
     264            // If the next "Meta Sync" is more than 5 minutes away, perform one ASAP.
     265            if ( wp_next_scheduled( 'plugin_directory_meta_sync' ) > ( time() + 5 * MINUTE_IN_SECONDS ) ) {
     266                wp_schedule_single_event( time() + 10, 'plugin_directory_meta_sync' );
     267            }
    255268        }
    256269    }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-meta-sync.php

    r6642 r8918  
    107107        }
    108108
    109         $equivs     = wporg_get_version_equivalents();
    110         $equivs_key = md5( serialize( $equivs ) );
    111         if ( $equivs_key === get_option( 'plugin_last_tested_sync' ) ) {
    112             return;
    113         }
     109        $equivs = wporg_get_version_equivalents();
    114110
    115111        $latest_equiv = array();
     
    121117
    122118        $tested_meta_value_esc_sql = '"' . implode( '", "', array_map( 'esc_sql', array_keys( $latest_equiv ) ) ) . '"';
    123         $tested_values             = $wpdb->get_results( "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'tested' AND meta_value IN( {$tested_meta_value_esc_sql} )" );
     119        $tested_values             = $wpdb->get_results( "SELECT post_id, post_name, meta_value FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE meta_key = 'tested' AND meta_value IN( {$tested_meta_value_esc_sql} )" );
    124120
    125121        foreach ( $tested_values as $row ) {
     
    129125                $latest_equiv[ $row->meta_value ]
    130126            );
     127
     128            // Update the API endpoints with the new data
     129            API_Update_Updater::update_single_plugin( $row->post_name );
    131130        }
    132 
    133         update_option( 'plugin_last_tested_sync', $equivs_key );
    134131    }
    135132}
Note: See TracChangeset for help on using the changeset viewer.