2005-09-18 18:59:14 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2012-06-16 20:35:13 +00:00
|
|
|
* Check that database usernames are actually valid.
|
2009-08-02 19:35:17 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-09-05 13:15:48 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
|
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|
2005-09-18 18:59:14 +00:00
|
|
|
|
2012-06-16 20:35:13 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script to check that database usernames are actually valid.
|
|
|
|
|
*
|
2020-08-05 20:23:22 +00:00
|
|
|
* An existing usernames can become invalid if UserNameUtils::isValid()
|
2012-06-16 20:35:13 +00:00
|
|
|
* is altered or if we change the $wgMaxNameChars
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2009-08-02 19:35:17 +00:00
|
|
|
class CheckUsernames extends Maintenance {
|
|
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( 'Verify that database usernames are actually valid' );
|
2013-05-17 00:32:13 +00:00
|
|
|
$this->setBatchSize( 1000 );
|
2005-09-18 18:59:14 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2019-10-09 18:41:33 +00:00
|
|
|
public function execute() {
|
2024-01-17 18:53:40 +00:00
|
|
|
$dbr = $this->getReplicaDB();
|
2023-08-31 09:21:12 +00:00
|
|
|
$userNameUtils = $this->getServiceContainer()->getUserNameUtils();
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2013-05-17 00:32:13 +00:00
|
|
|
$maxUserId = 0;
|
|
|
|
|
do {
|
2022-07-11 13:51:08 +00:00
|
|
|
$res = $dbr->newSelectQueryBuilder()
|
|
|
|
|
->select( [ 'user_id', 'user_name' ] )
|
|
|
|
|
->from( 'user' )
|
2024-07-22 20:29:20 +00:00
|
|
|
->where( $dbr->expr( 'user_id', '>', $maxUserId ) )
|
2022-07-11 13:51:08 +00:00
|
|
|
->orderBy( 'user_id' )
|
|
|
|
|
->limit( $this->getBatchSize() )
|
2024-05-31 17:17:36 +00:00
|
|
|
->caller( __METHOD__ )
|
2022-07-11 13:51:08 +00:00
|
|
|
->fetchResultSet();
|
2005-09-18 18:59:14 +00:00
|
|
|
|
2013-05-17 00:32:13 +00:00
|
|
|
foreach ( $res as $row ) {
|
2020-08-05 20:23:22 +00:00
|
|
|
if ( !$userNameUtils->isValid( $row->user_name ) ) {
|
2015-04-21 06:26:49 +00:00
|
|
|
$this->output( sprintf( "Found: %6d: '%s'\n", $row->user_id, $row->user_name ) );
|
2013-05-17 00:32:13 +00:00
|
|
|
wfDebugLog( 'checkUsernames', $row->user_name );
|
|
|
|
|
}
|
2005-09-18 20:19:16 +00:00
|
|
|
}
|
2022-03-29 18:11:06 +00:00
|
|
|
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable $res has at at least one item
|
2013-05-17 00:32:13 +00:00
|
|
|
$maxUserId = $row->user_id;
|
2013-08-24 15:06:25 +00:00
|
|
|
} while ( $res->numRows() );
|
2005-09-18 18:59:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreStart
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = CheckUsernames::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|
2024-08-27 12:00:25 +00:00
|
|
|
// @codeCoverageIgnoreEnd
|