57 if ( !$db->tableExists(
'log_search' ) ) {
58 $this->
error(
"log_search does not exist" );
62 $start = $db->selectField(
'logging',
'MIN(log_id)',
false, __FUNCTION__ );
64 $this->
output(
"Nothing to do.\n" );
68 $end = $db->selectField(
'logging',
'MAX(log_id)',
false, __FUNCTION__ );
71 $end += $this->mBatchSize - 1;
73 $blockEnd = $start + $this->mBatchSize - 1;
75 $delTypes = [
'delete',
'suppress' ];
76 while ( $blockEnd <= $end ) {
77 $this->
output(
"...doing log_id from $blockStart to $blockEnd\n" );
78 $cond =
"log_id BETWEEN $blockStart AND $blockEnd";
79 $res = $db->select(
'logging',
'*', $cond, __FUNCTION__ );
80 foreach (
$res as $row ) {
90 if ( $field ==
null ) {
93 if ( $field ==
null ) {
94 $this->
output(
"Invalid param type for {$row->log_id}\n" );
98 $db->update(
'logging',
99 [
'log_params' => implode(
',',
$params ) ],
100 [
'log_id' => $row->log_id ] );
103 $items = explode(
',',
$params[1] );
104 $log =
new LogPage( $row->log_type );
106 $log->addRelations( $field, $items, $row->log_id );
108 $prefix = substr( $field, 0, strpos( $field,
'_' ) );
109 if ( !isset( self::$tableMap[$prefix] ) ) {
112 $table = self::$tableMap[$prefix];
113 $userField = $prefix .
'_user';
114 $userTextField = $prefix .
'_user_text';
116 $userIds = $userIPs = [];
117 $sres = $db->select( $table,
118 [ $userField, $userTextField ],
121 foreach ( $sres as $srow ) {
122 if ( $srow->$userField > 0 ) {
123 $userIds[] = intval( $srow->$userField );
124 } elseif ( $srow->$userTextField !=
'' ) {
125 $userIPs[] = $srow->$userTextField;
129 $log->addRelations(
'target_author_id', $userIds, $row->log_id );
130 $log->addRelations(
'target_author_ip', $userIPs, $row->log_id );
138 $items = explode(
',',
$params[0] );
139 $log =
new LogPage( $row->log_type );
141 $log->addRelations(
'log_id', $items, $row->log_id );
143 $userIds = $userIPs = [];
144 $sres = $db->select(
'logging',
145 [
'log_user',
'log_user_text' ],
146 [
'log_id' => $items ]
148 foreach ( $sres as $srow ) {
149 if ( $srow->log_user > 0 ) {
150 $userIds[] = intval( $srow->log_user );
151 } elseif ( IP::isIPAddress( $srow->log_user_text ) ) {
152 $userIPs[] = $srow->log_user_text;
155 $log->addRelations(
'target_author_id', $userIds, $row->log_id );
156 $log->addRelations(
'target_author_ip', $userIPs, $row->log_id );
163 $this->
output(
"Done populating log_search table.\n" );