From 5408e81fdf27bbc52830e7a1007f0e21df6804c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 3 Nov 2005 08:10:23 +0000 Subject: [PATCH] * Update the lastmod timestamp before writing an entry to the index * Code cleanup --- maintenance/generateSitemap.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 0eae82320a..dcd124e5a9 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -87,7 +87,7 @@ class GenerateSitemap { * * @var string */ - var $startts; + var $timestamp; /** * A database slave object @@ -133,8 +133,6 @@ class GenerateSitemap { $this->path = isset( $path ) ? $path : $wgScriptPath; $this->compress = $compress; - $this->startts = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); - $this->stderr = fopen( 'php://stderr', 'wt' ); $this->dbr =& wfGetDB( DB_SLAVE ); $this->generateNamespaces(); @@ -226,19 +224,19 @@ class GenerateSitemap { $this->debug( $namespace ); while ( $row = $this->dbr->fetchObject( $res ) ) { - if ( $i % $this->limit === 0 ) { + if ( $i++ % $this->limit === 0 ) { if ( $this->file !== false ) { $this->write( $this->file, $this->closeFile() ); $this->close( $this->file ); } $this->generateLimit( $namespace ); + $this->generateTimestamp(); $filename = $this->sitemapFilename( $namespace, $smcount++ ); $this->file = $this->open( $this->fspath . $filename, 'wb' ); $this->write( $this->file, $this->openFile() ); fwrite( $this->findex, $this->indexEntry( $filename ) ); $this->debug( "\t$filename" ); } - ++$i; $title = Title::makeTitle( $row->page_namespace, $row->page_title ); $date = wfTimestamp( TS_ISO_8601, $row->page_touched ); $this->write( $this->file, $this->fileEntry( $title->getFullURL(), $date, $this->priority( $namespace ) ) ); @@ -345,7 +343,7 @@ class GenerateSitemap { return "\t\n" . "\t\t$wgServer{$this->path}/$filename\n" . - "\t\t{$this->startts}\n" . + "\t\t{$this->timestamp}\n" . "\t\n"; } @@ -425,6 +423,13 @@ class GenerateSitemap { $this->limit = $i; } + + /** + * Update $this->timestamp to the current time + */ + function generateTimestamp() { + $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); + } } if ( in_array( '--help', $argv ) ) -- 2.20.1