<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[10044] sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory: Plugin Directory: When importing plugins, use the last commit date to the stable tag as the `Last Updated` value for the plugin.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/10044">10044</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/10044","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-07-09 07:35:02 +0000 (Thu, 09 Jul 2020)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Plugin Directory: When importing plugins, use the last commit date to the stable tag as the `Last Updated` value for the plugin.
This allows for WordPress.org to re-import plugins/blocks without affecting the last-updated date displayed.
Props coreymckrill, dd32.
Fixes <a href="http://meta.trac.wordpress.org/ticket/5242">#5242</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorycliclassimportphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorytoolsclasssvnphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorycliclassimportphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2020-07-09 07:26:48 UTC (rev 10043)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php 2020-07-09 07:35:02 UTC (rev 10044)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,6 +74,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $headers = $data['plugin_headers'];
</span><span class="cx" style="display: block; padding: 0 10px"> $stable_tag = $data['stable_tag'];
</span><span class="cx" style="display: block; padding: 0 10px"> $tagged_versions = $data['tagged_versions'];
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $last_modified = $data['last_modified'];
</ins><span class="cx" style="display: block; padding: 0 10px"> $blocks = $data['blocks'];
</span><span class="cx" style="display: block; padding: 0 10px"> $block_files = $data['block_files'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,7 +103,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $plugin->post_modified == '0000-00-00 00:00:00' ||
</span><span class="cx" style="display: block; padding: 0 10px"> ( $svn_changed_tags && in_array( ( $stable_tag ?: 'trunk' ), $svn_changed_tags, true ) )
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $plugin->post_modified = $plugin->post_modified_gmt = current_time( 'mysql' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $last_modified ) {
+ $plugin->post_modified = $plugin->post_modified_gmt = $last_modified;
+ } else {
+ $plugin->post_modified = $plugin->post_modified_gmt = current_time( 'mysql' );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Plugins should move from 'approved' to 'publish' on first parse
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -330,6 +335,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $trunk_readme_files = preg_grep( '!^readme.(txt|md)$!i', $trunk_files );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $trunk_readme_files ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $trunk_readme_file = reset( $trunk_readme_files );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Preference readme.txt over readme.md if both exist.
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $trunk_readme_files as $f ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( '.txt' == strtolower( substr( $f, -4 ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $trunk_readme_file = $f;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -343,51 +349,54 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $stable_tag = $trunk_readme->stable_tag;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $exported = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $svn_info = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $stable_tag && 'trunk' != $stable_tag ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $svn_export = SVN::export(
- self::PLUGIN_SVN_BASE . "/{$plugin_slug}/tags/{$stable_tag}",
- $tmp_dir . '/export',
- array(
- 'ignore-externals',
- )
- );
- // Handle tags which we store as 0.blah but are in /tags/.blah
- if ( ! $svn_export['result'] && '0.' == substr( $stable_tag, 0, 2 ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $stable_url = self::PLUGIN_SVN_BASE . "/{$plugin_slug}/tags/{$stable_tag}";
+ $svn_info = SVN::info( $stable_url );
+
+ if ( ! $svn_info['result'] && '0.' === substr( $stable_tag, 0, 2 ) ) {
+ // Handle tags which we store as 0.blah but are in /tags/.blah
</ins><span class="cx" style="display: block; padding: 0 10px"> $_stable_tag = substr( $stable_tag, 1 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $svn_export = SVN::export(
- self::PLUGIN_SVN_BASE . "/{$plugin_slug}/tags/{$_stable_tag}",
- $tmp_dir . '/export',
- array(
- 'ignore-externals',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $stable_url = self::PLUGIN_SVN_BASE . "/{$plugin_slug}/tags/{$_stable_tag}";
+ $svn_info = SVN::info( $stable_url );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $svn_export['result'] && false !== $this->find_readme_file( $tmp_dir . '/export' ) ) {
- $exported = true;
- } else {
- // Clear out any files that exist in the export.
- Filesystem::rmdir( $tmp_dir . '/export' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Verify that the tag has files, falling back to trunk if not.
+ if ( ! SVN::ls( $stable_tag ) ) {
+ $svn_info = false;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $exported ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( ! $svn_info || ! $svn_info['result'] ) {
+ $stable_tag = 'trunk';
+ $stable_url = self::PLUGIN_SVN_BASE . "/{$plugin_slug}/trunk";
+ $svn_info = SVN::info( $stable_url );
+ }
+
+ if ( ! $svn_info['result'] ) {
+ throw new Exception( 'Could not find stable SVN URL: ' . implode( ' ', reset( $svn_info['errors'] ) ) );
+ }
+
+ $last_modified = false;
+ if ( preg_match( '/^([0-9]{4}\-[0-9]{2}\-[0-9]{2} [0-9]{1,2}:[0-9]{2}:[0-9]{2})/', $svn_info['result']['Last Changed Date'] ?? '', $m ) ) {
+ $last_modified = $m[0];
+ }
+
+ $svn_export = SVN::export(
+ $stable_url,
+ $tmp_dir . '/export',
+ array(
+ 'ignore-externals',
+ )
+ );
+
+ if ( ! $svn_export['result'] || empty( $svn_export['revision'] ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // Catch the case where exporting a tag finds nothing, but there was nothing in trunk either.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $trunk_files ) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new Exception( 'Plugin has no files in trunk, nor tags.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $stable_tag = 'trunk';
- // Either stable_tag = trunk, or the stable_tag tag didn't exist.
- $svn_export = SVN::export(
- self::PLUGIN_SVN_BASE . "/{$plugin_slug}/trunk",
- $tmp_dir . '/export',
- array(
- 'ignore-externals',
- )
- );
- if ( ! $svn_export['result'] || empty( $svn_export['revision'] ) ) {
- throw new Exception( 'Could not create SVN export: ' . implode( ' ', reset( $svn_export['errors'] ) ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ throw new Exception( 'Could not create SVN export: ' . implode( ' ', reset( $svn_export['errors'] ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // The readme may not actually exist, but that's okay.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,11 +410,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Now we look in the /assets/ folder for banners, screenshots, and icons.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $assets = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $assets = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'screenshot' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'banner' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'icon' => array(),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $svn_assets_folder = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/assets/", true /* verbose */ );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $svn_assets_folder ) { // /assets/ may not exist.
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $svn_assets_folder as $asset ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -556,7 +566,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return preg_match( '!\.(?:js|jsx|css)$!i', $filename );
</span><span class="cx" style="display: block; padding: 0 10px"> } ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return compact( 'readme', 'stable_tag', 'tmp_dir', 'plugin_headers', 'assets', 'tagged_versions', 'blocks', 'block_files' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return compact( 'readme', 'stable_tag', 'last_modified', 'tmp_dir', 'plugin_headers', 'assets', 'tagged_versions', 'blocks', 'block_files' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsplugindirectorytoolsclasssvnphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php 2020-07-09 07:26:48 UTC (rev 10043)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php 2020-07-09 07:35:02 UTC (rev 10044)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,56 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @package WordPressdotorg\Plugin_Directory\Tools
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class SVN {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Get SVN info about a URL.
+ *
+ * @static
+ *
+ * @param string $url The URL of the svn repo.
+ * @param array $options Optional. A list of options to pass to SVN. Default: empty array.
+ *
+ * @return array {
+ * @type bool|array $result False on failure. Otherwise an associative array.
+ * @type bool|array $errors Whether any errors or warnings were encountered.
+ * }
+ */
+ public static function info( $url, $options = array() ) {
+ $esc_url = escapeshellarg( $url );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $options[] = 'non-interactive';
+ if ( empty( $options['username'] ) ) {
+ $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
+ $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
+ }
+ $esc_options = self::parse_esc_parameters( $options );
+
+ $output = self::shell_exec( "svn info $esc_options $esc_url 2>&1" );
+ if ( preg_match( '!URL: ' . untrailingslashit( $url ) . '\n!i', $output ) ) {
+ $lines = explode( "\n", $output );
+ $result = array_filter( array_reduce(
+ $lines,
+ function( $carry, $item ) {
+ $pair = explode( ':', $item, 2 );
+ if ( isset( $pair[1] ) ) {
+ $key = trim( $pair[0] );
+ $carry[ $key ] = trim( $pair[1] );
+ } else {
+ $carry[] = trim( $pair[0] );
+ }
+
+ return $carry;
+ },
+ array()
+ ) );
+ $errors = false;
+ } else {
+ $result = false;
+ $errors = self::parse_svn_errors( $output );
+ }
+
+ return compact( 'result', 'errors' );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Import a local directory to a SVN path.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span></span></pre>
</div>
</div>
</body>
</html>