*/
private $identifier;
- /**
- * Constructor
- */
public function __construct() {
parent::__construct();
$this->addDescription( 'Creates a sitemap for the site' );
# Create directory if needed
$fspath = $this->getOption( 'fspath', getcwd() );
if ( !wfMkdirParents( $fspath, null, __METHOD__ ) ) {
- $this->error( "Can not create directory $fspath.", 1 );
+ $this->fatalError( "Can not create directory $fspath." );
}
$this->fspath = realpath( $fspath ) . DIRECTORY_SEPARATOR;
}
$this->identifier = $this->getOption( 'identifier', wfWikiID() );
$this->compress = $this->getOption( 'compress', 'yes' ) !== 'no';
- $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false;
+ $this->skipRedirects = $this->hasOption( 'skip-redirects' );
$this->dbr = $this->getDB( DB_REPLICA );
$this->generateNamespaces();
$this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() );
/**
* gzwrite() / fwrite() wrapper
*
- * @param resource $handle
+ * @param resource &$handle
* @param string $str
*/
function write( &$handle, $str ) {
/**
* gzclose() / fclose() wrapper
*
- * @param resource $handle
+ * @param resource &$handle
*/
function close( &$handle ) {
if ( $this->compress ) {
/**
* Get a sitemap filename
*
- * @param int $namespace The namespace
- * @param int $count The count
+ * @param int $namespace
+ * @param int $count
* @return string
*/
function sitemapFilename( $namespace, $count ) {
* @return string
*/
function indexEntry( $filename ) {
- return
- "\t<sitemap>\n" .
+ return "\t<sitemap>\n" .
"\t\t<loc>{$this->urlpath}$filename</loc>\n" .
"\t\t<lastmod>{$this->timestamp}</lastmod>\n" .
"\t</sitemap>\n";
* @return string
*/
function fileEntry( $url, $date, $priority ) {
- return
- "\t<url>\n" .
+ return "\t<url>\n" .
// T36666: $url may contain bad characters such as ampersands.
"\t\t<loc>" . htmlspecialchars( $url ) . "</loc>\n" .
"\t\t<lastmod>$date</lastmod>\n" .
}
}
-$maintClass = "GenerateSitemap";
+$maintClass = GenerateSitemap::class;
require_once RUN_MAINTENANCE_IF_MAIN;