summaryrefslogtreecommitdiff
path: root/maintenance/generateSitemap.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/generateSitemap.php')
-rw-r--r--maintenance/generateSitemap.php31
1 files changed, 29 insertions, 2 deletions
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