From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- maintenance/generateSitemap.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'maintenance/generateSitemap.php') diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 403e5a24..80d31f97 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -162,6 +162,8 @@ class GenerateSitemap extends Maintenance { } private function setNamespacePriorities() { + global $wgSitemapNamespacesPriorities; + // Custom main namespaces $this->priorities[self::GS_MAIN] = '0.5'; // Custom talk namesspaces @@ -183,10 +185,28 @@ class GenerateSitemap extends Maintenance { $this->priorities[NS_HELP_TALK] = '0.1'; $this->priorities[NS_CATEGORY] = '0.5'; $this->priorities[NS_CATEGORY_TALK] = '0.1'; + + // Custom priorities + if ( $wgSitemapNamespacesPriorities !== false ) { + /** + * @var $wgSitemapNamespacesPriorities array + */ + foreach ( $wgSitemapNamespacesPriorities as $namespace => $priority ) { + $float = floatval( $priority ); + if ( $float > 1.0 ) { + $priority = '1.0'; + } elseif ( $float < 0.0 ) { + $priority = '0.0'; + } + $this->priorities[$namespace] = $priority; + } + } } /** * Create directory if it does not exist and return pathname with a trailing slash + * @param $fspath string + * @return null|string */ private static function init_path( $fspath ) { if ( !isset( $fspath ) ) { @@ -194,7 +214,7 @@ class GenerateSitemap extends Maintenance { } # Create directory if needed if ( $fspath && !is_dir( $fspath ) ) { - wfMkdirParents( $fspath ) or die( "Can not create directory $fspath.\n" ); + wfMkdirParents( $fspath, null, __METHOD__ ) or die( "Can not create directory $fspath.\n" ); } return realpath( $fspath ) . DIRECTORY_SEPARATOR ; @@ -327,13 +347,20 @@ class GenerateSitemap extends Maintenance { * @return Resource */ function open( $file, $flags ) { - return $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags ); + $resource = $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags ); + if( $resource === false ) { + wfDebugDieBacktrace( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" ); + } + return $resource; } /** * gzwrite() / fwrite() wrapper */ function write( &$handle, $str ) { + if( $handle === true || $handle === false ) { + wfDebugDieBacktrace( __METHOD__ . " was passed a boolean as a file handle.\n" ); + } if ( $this->compress ) gzwrite( $handle, $str ); else -- cgit v1.2.2