X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FgenerateSitemap.php;h=c40d0ce706319b2a1b1b5dec8480934eca9000f9;hb=49f4f5307a195b8ee6260e7bc63d70777995fda5;hp=c43851e6f2ac5edc1d424c37e2d9615643707b33;hpb=ed945112a8640fcaefa0128456602893294aee31;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index c43851e6f2..c40d0ce706 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -181,7 +181,14 @@ class GenerateSitemap extends Maintenance { $this->setNamespacePriorities(); $this->url_limit = 50000; $this->size_limit = pow( 2, 20 ) * 10; - $this->fspath = self::init_path( $this->getOption( 'fspath', getcwd() ) ); + + # Create directory if needed + $fspath = $this->getOption( 'fspath', getcwd() ); + if ( !wfMkdirParents( $fspath, null, __METHOD__ ) ) { + $this->error( "Can not create directory $fspath.", 1 ); + } + + $this->fspath = realpath( $fspath ) . DIRECTORY_SEPARATOR; $this->urlpath = $this->getOption( 'urlpath', "" ); if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) { $this->urlpath .= '/'; @@ -189,7 +196,7 @@ class GenerateSitemap extends Maintenance { $this->identifier = $this->getOption( 'identifier', wfWikiID() ); $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no'; $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false; - $this->dbr = wfGetDB( DB_SLAVE ); + $this->dbr = $this->getDB( DB_SLAVE ); $this->generateNamespaces(); $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); $this->findex = fopen( "{$this->fspath}sitemap-index-{$this->identifier}.xml", 'wb' ); @@ -238,23 +245,6 @@ class GenerateSitemap extends Maintenance { } } - /** - * Create directory if it does not exist and return pathname with a trailing slash - * @param string $fspath - * @return null|string - */ - private static function init_path( $fspath ) { - if ( !isset( $fspath ) ) { - return null; - } - # Create directory if needed - if ( $fspath && !is_dir( $fspath ) ) { - wfMkdirParents( $fspath, null, __METHOD__ ) or die( "Can not create directory $fspath.\n" ); - } - - return realpath( $fspath ) . DIRECTORY_SEPARATOR; - } - /** * Generate a one-dimensional array of existing namespaces */