Making WordPress.org

Changeset 12917


Ignore:
Timestamp:
09/25/2023 11:29:08 PM (18 months ago)
Author:
iandunn
Message:

Theme Directory: Return when published to prevent duplicate imports

wporg_themes_glotpress_mark_as_active_on_publish() was only intended to run when a suspended/delisted theme was reinstated, but it was also running when a new version of a published theme was uploaded. That caused wporg_themes_update_wpthemescom() to run a second time, after it was originally called by the import process. The second time it was called with the _previous_ version of the theme, though, because it ran before the _status value was updated in the database. That caused previews on wp-theme.com to always show the previous version instead of the current one.

Props iandunn, dufresnesteven, paulkevan
See #7213

File:
1 edited

Legend:

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

    r12916 r12917  
    724724
    725725    $trace = wp_debug_backtrace_summary();
    726     $message = __FUNCTION__ . " trace: " . $trace;
     726    $message = __FUNCTION__ .  " - slug: $theme_slug - version: $theme_version - trace: $trace";
    727727    slack_dm( $message, 'iandunn' );
    728728}
     
    11511151 * @param int  $post_id The post ID being published
    11521152 */
    1153 function wporg_themes_glotpress_mark_as_active_on_publish( $post_id ) {
    1154     $post           = get_post( $post_id );
     1153function wporg_themes_glotpress_mark_as_active_on_publish( $post_id, $post, $old_status ) {
     1154    // This is only intended to handle when a suspended/delisted theme is reinstated. Other functions handle when
     1155    // a new version of a published theme is uploaded.
     1156    if ( 'publish' === $old_status ) {
     1157        return;
     1158    }
     1159
    11551160    $latest_version = array_search( 'live', $post->_status ?: [] );
     1161
    11561162    if ( ! $latest_version ) {
    11571163        return;
     
    11591165
    11601166    wporg_themes_glotpress_import( $post, $latest_version );
     1167
    11611168    wporg_themes_update_wpthemescom( $post->post_name, $latest_version );
    11621169}
    1163 add_action( 'publish_repopackage', 'wporg_themes_glotpress_mark_as_active_on_publish', 100 );
     1170add_action( 'publish_repopackage', 'wporg_themes_glotpress_mark_as_active_on_publish', 10, 3 );
    11641171
    11651172/**
Note: See TracChangeset for help on using the changeset viewer.