r77176 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77175‎ | r77176 | r77177 >
Date:19:26, 23 November 2010
Author:vyznev
Status:ok
Tags:
Comment:
bug 9675: sitemap-index doesn't include full location path
Modified paths:
  • /trunk/phase3/maintenance/generateSitemap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/generateSitemap.php
@@ -57,11 +57,11 @@
5858 var $fspath;
5959
6060 /**
61 - * The path to append to the domain name
 61+ * The URL path to prepend to filenames in the index; should resolve to the same directory as $fspath
6262 *
6363 * @var string
6464 */
65 - var $path;
 65+ var $urlpath;
6666
6767 /**
6868 * Whether or not to use compression
@@ -126,8 +126,8 @@
127127 public function __construct() {
128128 parent::__construct();
129129 $this->mDescription = "Creates a sitemap for the site";
130 - $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap' .
131 - "\n\t\tdefaults to current directory", false, true );
 130+ $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap; defaults to current directory', false, true );
 131+ $this->addOption( 'urlpath', 'The URL path corresponding to --fspath, prepended to filenames in the index; defaults to an empty string', false, true );
132132 $this->addOption( 'compress', 'Compress the sitemap files, can take value yes|no, default yes', false, true );
133133 }
134134
@@ -139,6 +139,8 @@
140140 $this->url_limit = 50000;
141141 $this->size_limit = pow( 2, 20 ) * 10;
142142 $this->fspath = self::init_path( $this->getOption( 'fspath', getcwd() ) );
 143+ $this->urlpath = $this->getOption( 'urlpath', "" );
 144+ if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) $this->urlpath .= '/';
143145 $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no';
144146 $this->dbr = wfGetDB( DB_SLAVE );
145147 $this->generateNamespaces();
@@ -384,7 +386,7 @@
385387 function indexEntry( $filename ) {
386388 return
387389 "\t<sitemap>\n" .
388 - "\t\t<loc>$filename</loc>\n" .
 390+ "\t\t<loc>{$this->urlpath}$filename</loc>\n" .
389391 "\t\t<lastmod>{$this->timestamp}</lastmod>\n" .
390392 "\t</sitemap>\n";
391393 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r77612followup to r77176: code style, release notesvyznev22:40, 2 December 2010
r77666* (bug 26219) Show API limits for multi values in description...reedy16:24, 3 December 2010

Status & tagging log