* @see http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd
*/
+use MediaWiki\MediaWikiServices;
+
require_once __DIR__ . '/Maintenance.php';
/**
public function execute() {
$this->setNamespacePriorities();
$this->url_limit = 50000;
- $this->size_limit = pow( 2, 20 ) * 10;
+ $this->size_limit = ( 2 ** 20 ) * 10;
# Create directory if needed
$fspath = $this->getOption( 'fspath', getcwd() );
* @return string
*/
function priority( $namespace ) {
- return isset( $this->priorities[$namespace] )
- ? $this->priorities[$namespace]
- : $this->guessPriority( $namespace );
+ return $this->priorities[$namespace] ?? $this->guessPriority( $namespace );
}
/**
* Main loop
*/
public function main() {
- global $wgContLang;
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
fwrite( $this->findex, $this->openIndex() );
$length = $this->limit[0];
$i = $smcount = 0;
- $fns = $wgContLang->getFormattedNsText( $namespace );
+ $fns = $contLang->getFormattedNsText( $namespace );
$this->output( "$namespace ($fns)\n" );
$skippedRedirects = 0; // Number of redirects skipped for that namespace
foreach ( $res as $row ) {
$length += strlen( $entry );
$this->write( $this->file, $entry );
// generate pages for language variants
- if ( $wgContLang->hasVariants() ) {
- $variants = $wgContLang->getVariants();
+ if ( $contLang->hasVariants() ) {
+ $variants = $contLang->getVariants();
foreach ( $variants as $vCode ) {
- if ( $vCode == $wgContLang->getCode() ) {
+ if ( $vCode == $contLang->getCode() ) {
continue; // we don't want default variant
}
$entry = $this->fileEntry(
*/
function generateLimit( $namespace ) {
// T19961: make a title with the longest possible URL in this namespace
- $title = Title::makeTitle( $namespace, str_repeat( "\xf0\xa8\xae\x81", 63 ) . "\xe5\x96\x83" );
+ $title = Title::makeTitle( $namespace, str_repeat( "\u{28B81}", 63 ) . "\u{5583}" );
$this->limit = [
strlen( $this->openFile() ),
}
}
-$maintClass = "GenerateSitemap";
+$maintClass = GenerateSitemap::class;
require_once RUN_MAINTENANCE_IF_MAIN;