34 require_once __DIR__ .
'/cleanupTable.inc';
48 parent::__construct();
50 $this->
addOption(
'namespace',
'Namespace number to run caps cleanup on',
false,
true );
56 $this->
namespace = intval( $this->
getOption( 'namespace', 0 ) );
59 MediaWikiServices::getInstance()->getNamespaceInfo()->
60 isCapitalized( $this->
namespace )
62 $this->
output(
"Will be moving pages to first letter capitalized titles" );
63 $callback =
'processRowToUppercase';
65 $this->
output(
"Will be moving pages to first letter lowercase titles" );
66 $callback =
'processRowToLowercase';
69 $this->dryrun = $this->
hasOption(
'dry-run' );
73 'conds' => [
'page_namespace' => $this->
namespace ],
75 'callback' => $callback ] );
80 $display = $current->getPrefixedText();
81 $lower = $row->page_title;
82 $upper = MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $row->page_title );
83 if ( $upper == $lower ) {
84 $this->
output(
"\"$display\" already uppercase.\n" );
90 if ( $target->exists() ) {
97 'Converting page title to first-letter uppercase',
102 if ( $row->page_namespace == $this->namespace ) {
103 $talk = $target->getTalkPage();
104 $row->page_namespace = $talk->getNamespace();
105 if ( $talk->exists() ) {
116 $display = $current->getPrefixedText();
117 $upper = $row->page_title;
118 $lower = MediaWikiServices::getInstance()->getContentLanguage()->lcfirst( $row->page_title );
119 if ( $upper == $lower ) {
120 $this->
output(
"\"$display\" already lowercase.\n" );
126 if ( $target->exists() ) {
127 $targetDisplay = $target->getPrefixedText();
128 $this->
output(
"\"$display\" skipped; \"$targetDisplay\" already exists\n" );
133 $ok = $this->
movePage( $current, $target,
'Converting page titles to lowercase',
true );
134 if ( $ok ===
true ) {
136 if ( $row->page_namespace == $this->namespace ) {
137 $talk = $target->getTalkPage();
138 $row->page_namespace = $talk->getNamespace();
139 if ( $talk->exists() ) {
159 if ( $this->dryrun ) {
160 $this->
output(
"\"$display\" -> \"$targetDisplay\": DRY RUN, NOT MOVED\n" );
163 $mp = MediaWikiServices::getInstance()->getMovePageFactory()
164 ->newMovePage( $current, $target );
165 $status = $mp->move( $this->user, $reason, $createRedirect );
166 $ok =
$status->isOK() ?
'OK' :
$status->getMessage(
false,
false,
'en' )->text();
167 $this->
output(
"\"$display\" -> \"$targetDisplay\": $ok\n" );