3 * Makes the required database updates for Special:ProtectedPages
4 * to show all protected pages, even ones before the page restrictions
5 * schema change. All remaining page_restriction column values are moved
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
23 * @ingroup Maintenance
26 require_once( dirname( __FILE__
) . '/Maintenance.php' );
28 class PopulateLogUsertext
extends Maintenance
{
29 public function __construct() {
30 parent
::__construct();
31 $this->mDescription
= "Populates the log_user_text";
32 $this->setBatchSize( 100 );
35 public function execute() {
36 $db = $this->getDB( DB_MASTER
);
37 $start = $db->selectField( 'logging', 'MIN(log_id)', false, __METHOD__
);
39 $this->output( "Nothing to do.\n" );
42 $end = $db->selectField( 'logging', 'MAX(log_id)', false, __METHOD__
);
45 $end +
= $this->mBatchSize
- 1;
47 $blockEnd = $start +
$this->mBatchSize
- 1;
48 while ( $blockEnd <= $end ) {
49 $this->output( "...doing log_id from $blockStart to $blockEnd\n" );
50 $cond = "log_id BETWEEN $blockStart AND $blockEnd AND log_user = user_id";
51 $res = $db->select( array( 'logging', 'user' ),
52 array( 'log_id', 'user_name' ), $cond, __METHOD__
);
55 foreach ( $res as $row ) {
56 $db->update( 'logging', array( 'log_user_text' => $row->user_name
),
57 array( 'log_id' => $row->log_id
), __METHOD__
);
60 $blockStart +
= $this->mBatchSize
;
61 $blockEnd +
= $this->mBatchSize
;
66 array( 'ul_key' => 'populate log_usertext' ),
71 $this->output( "log_usertext population complete.\n" );
74 $this->output( "Could not insert log_usertext population row.\n" );
80 $maintClass = "PopulateLogUsertext";
81 require_once( RUN_MAINTENANCE_IF_MAIN
);