Making WordPress.org


Ignore:
Timestamp:
07/04/2024 03:08:32 AM (2 years ago)
Author:
dd32
Message:

Plugin Directory: Always add the release metadata for plugin releases from tags.

See #7696.

File:
1 edited

Legend:

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

    r13869 r13874  
    9595                $assets             = $data['assets'];
    9696                $headers            = $data['plugin_headers'];
     97                $version            = $headers->Version ?? '';
    9798                $stable_tag         = $data['stable_tag'];
    9899                $last_committer     = $data['last_committer'];
     
    168169                                if ( ! $release ) {
    169170                                        // Use the actual version for stable releases, otherwise fallback to the tag name, as we don't have the actual header data.
    170                                         $version = ( $svn_changed_tag === $stable_tag ) ? $headers->Version : $svn_changed_tag;
     171                                        $version = ( $svn_changed_tag === $stable_tag ) ? $version : $svn_changed_tag;
    171172
    172173                                        Plugin_Directory::add_release(
     
    298299                 */
    299300                if (
    300                         ( ! isset( $headers->Version ) || $headers->Version != get_post_meta( $plugin->ID, 'version', true ) ) ||
     301                        ( ! $version || $version != get_post_meta( $plugin->ID, 'version', true ) ) ||
    301302                        $plugin->post_modified == '0000-00-00 00:00:00' ||
    302303                        ( $svn_changed_tags && in_array( ( $stable_tag ?: 'trunk' ), $svn_changed_tags, true ) )
     
    437438                }
    438439
     440                // Add the release to storage.
     441                if ( 'trunk' != $stable_tag ) {
     442                        Plugin_Directory::add_release(
     443                                $plugin,
     444                                [
     445                                        'tag'       => $stable_tag,
     446                                        'version'   => $version,
     447                                        'committer' => [ $last_committer ],
     448                                        'revision'  => [ $last_revision ]
     449                                ]
     450                        );
     451                }
     452
    439453                $this->rebuild_affected_zips( $plugin_slug, $stable_tag, $current_stable_tag, $svn_changed_tags, $svn_revision_triggered );
    440454
    441455                // Finally, set the new version live.
    442456                update_post_meta( $plugin->ID, 'stable_tag', wp_slash( $stable_tag ) );
    443                 update_post_meta( $plugin->ID, 'version',    wp_slash( $headers->Version ) );
     457                update_post_meta( $plugin->ID, 'version',    wp_slash( $version ) );
    444458                // Update the list of tags last, as it controls which ZIPs are present in the 'Previous versions' section and info API.
    445459                update_post_meta( $plugin->ID, 'tags',       wp_slash( $tagged_versions ) );
     
    512526                                ) {
    513527                                        unset( $versions_to_build[ $i ] );
    514                                 } else {
    515                                         $release['zips_built'] = true;
    516                                         Plugin_Directory::add_release( $plugin, $release );
    517528                                }
    518529                        }
     
    541552                } catch ( Exception $e ) {
    542553                        return false;
     554                }
     555
     556                // Mark the ZIPs as being built.
     557                foreach ( $versions_to_build as $tag ) {
     558                        if ( 'trunk' === $tag ) {
     559                                continue;
     560                        }
     561
     562                        Plugin_Directory::add_release(
     563                                $plugin,
     564                                [
     565                                        'tag'        => $tag,
     566                                        'zips_built' => true
     567                                ]
     568                        );
    543569                }
    544570
Note: See TracChangeset for help on using the changeset viewer.