r4073 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r4072‎ | r4073 | r4074 >
Date:10:40, 14 June 2004
Author:timstarling
Status:old
Tags:
Comment:
Storing IP in RC. Off by default. Tested:
* Installation
* Edit when switched off
* Edit when switched on
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/maintenance/indexes.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/indexes.sql
@@ -51,7 +51,8 @@
5252 ADD INDEX rc_timestamp (rc_timestamp),
5353 ADD INDEX rc_namespace_title (rc_namespace, rc_title),
5454 ADD INDEX rc_cur_id (rc_cur_id),
55 - ADD INDEX new_name_timestamp(rc_new,rc_namespace,rc_timestamp);
 55+ ADD INDEX new_name_timestamp(rc_new,rc_namespace,rc_timestamp),
 56+ ADD INDEX rc_ip (rc_ip);
5657
5758 ALTER TABLE archive
5859 ADD KEY `name_title_timestamp` (`ar_namespace`,`ar_title`,`ar_timestamp`);
Index: trunk/phase3/maintenance/updaters.inc
@@ -134,6 +134,11 @@
135135 dbsource( "maintenance/archives/patch-rc_type.sql" , $wgDatabase );
136136 echo "ok\n";
137137 }
 138+ if ( !$wgDatabase->fieldExists( "recentchanges", "rc_ip" ) ) {
 139+ echo "Adding rc_ip...";
 140+ dbsource( "maintenance/archives/patch-rc_ip.sql", $wgDatabase );
 141+ echo "ok\n";
 142+ }
138143 }
139144
140145 function do_user_real_name_update() {
@@ -179,5 +184,4 @@
180185 echo "ok\n";
181186 }
182187 }
183 -
184 -?>
\ No newline at end of file
 188+?>
Index: trunk/phase3/maintenance/tables.sql
@@ -189,7 +189,8 @@
190190 rc_last_oldid int(10) unsigned NOT NULL default '0',
191191 rc_type tinyint(3) unsigned NOT NULL default '0',
192192 rc_moved_to_ns tinyint(3) unsigned NOT NULL default '0',
193 - rc_moved_to_title varchar(255) binary NOT NULL default ''
 193+ rc_moved_to_title varchar(255) binary NOT NULL default '',
 194+ rc_ip char(15) NOT NULL default ''
194195 ) PACK_KEYS=1;
195196
196197 CREATE TABLE watchlist (
Index: trunk/phase3/includes/RecentChange.php
@@ -21,6 +21,7 @@
2222 rc_this_oldid old_id associated with this entry (or zero)
2323 rc_last_oldid old_id associated with the entry before this one (or zero)
2424 rc_bot is bot, hidden
 25+ rc_ip IP address of the user in dotted quad notation
2526 rc_new obsolete, use rc_type==RC_NEW
2627
2728 mExtra:
@@ -82,7 +83,7 @@
8384 # Writes the data in this object to the database
8485 function save()
8586 {
86 - global $wgUseRCQueue, $wgRCQueueID, $wgLocalInterwiki;
 87+ global $wgUseRCQueue, $wgRCQueueID, $wgLocalInterwiki, $wgPutIPinRC;
8788 $fname = "RecentChange::save";
8889
8990 if ( !is_array($this->mExtra) ) {
@@ -90,6 +91,10 @@
9192 }
9293 $this->mExtra['lang'] = $wgLocalInterwiki;
9394
 95+ if ( !$wgPutIPinRC ) {
 96+ $this->mAttribs['rc_ip'] = '';
 97+ }
 98+
9499 # Insert new row
95100 wfInsertArray( "recentchanges", $this->mAttribs, $fname );
96101
@@ -126,12 +131,17 @@
127132
128133 # Makes an entry in the database corresponding to an edit
129134 /*static*/ function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
130 - $oldId, $lastTimestamp, $bot = "default" )
 135+ $oldId, $lastTimestamp, $bot = "default", $ip = '' )
131136 {
132137 if ( $bot == "default " ) {
133138 $bot = $user->isBot();
134139 }
135140
 141+ if ( !$ip ) {
 142+ global $wgIP;
 143+ $ip = empty( $wgIP ) ? '' : $wgIP;
 144+ }
 145+
136146 $rc = new RecentChange;
137147 $rc->mAttribs = array(
138148 'rc_timestamp' => $timestamp,
@@ -149,6 +159,7 @@
150160 'rc_bot' => $bot ? 1 : 0,
151161 'rc_moved_to_ns' => 0,
152162 'rc_moved_to_title' => '',
 163+ 'rc_ip' => $ip,
153164 'rc_new' => 0 # obsolete
154165 );
155166
@@ -161,28 +172,34 @@
162173
163174 # Makes an entry in the database corresponding to page creation
164175 # Note: the title object must be loaded with the new id using resetArticleID()
165 - /*static*/ function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = "default" )
 176+ /*static*/ function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = "default", $ip='' )
166177 {
 178+ if ( !$ip ) {
 179+ global $wgIP;
 180+ $ip = empty( $wgIP ) ? '' : $wgIP;
 181+ }
167182 if ( $bot == "default" ) {
168183 $bot = $user->isBot();
169184 }
 185+
170186 $rc = new RecentChange;
171187 $rc->mAttribs = array(
172 - 'rc_timestamp' => $timestamp,
173 - 'rc_cur_time' => $timestamp,
174 - 'rc_namespace' => $title->getNamespace(),
175 - 'rc_title' => $title->getDBkey(),
176 - 'rc_type' => RC_NEW,
177 - 'rc_minor' => $minor ? 1 : 0,
178 - 'rc_cur_id' => $title->getArticleID(),
179 - 'rc_user' => $user->getID(),
180 - 'rc_user_text' => $user->getName(),
181 - 'rc_comment' => $comment,
182 - 'rc_this_oldid' => 0,
183 - 'rc_last_oldid' => 0,
184 - 'rc_bot' => $bot ? 1 : 0,
185 - 'rc_moved_to_ns' => 0,
186 - 'rc_moved_to_title' => '',
 188+ 'rc_timestamp' => $timestamp,
 189+ 'rc_cur_time' => $timestamp,
 190+ 'rc_namespace' => $title->getNamespace(),
 191+ 'rc_title' => $title->getDBkey(),
 192+ 'rc_type' => RC_NEW,
 193+ 'rc_minor' => $minor ? 1 : 0,
 194+ 'rc_cur_id' => $title->getArticleID(),
 195+ 'rc_user' => $user->getID(),
 196+ 'rc_user_text' => $user->getName(),
 197+ 'rc_comment' => $comment,
 198+ 'rc_this_oldid' => 0,
 199+ 'rc_last_oldid' => 0,
 200+ 'rc_bot' => $bot ? 1 : 0,
 201+ 'rc_moved_to_ns' => 0,
 202+ 'rc_moved_to_title' => '',
 203+ 'rc_ip' => $ip,
187204 'rc_new' => 1 # obsolete
188205 );
189206
@@ -194,8 +211,12 @@
195212 }
196213
197214 # Makes an entry in the database corresponding to a rename
198 - /*static*/ function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment )
 215+ /*static*/ function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' )
199216 {
 217+ if ( !$ip ) {
 218+ global $wgIP;
 219+ $ip = empty( $wgIP ) ? '' : $wgIP;
 220+ }
200221 $rc = new RecentChange;
201222 $rc->mAttribs = array(
202223 'rc_timestamp' => $timestamp,
@@ -213,6 +234,7 @@
214235 'rc_bot' => $user->isBot() ? 1 : 0,
215236 'rc_moved_to_ns' => $newTitle->getNamespace(),
216237 'rc_moved_to_title' => $newTitle->getDBkey(),
 238+ 'rc_ip' => $ip,
217239 'rc_new' => 0 # obsolete
218240 );
219241
@@ -226,8 +248,12 @@
227249
228250 # A log entry is different to an edit in that previous revisions are
229251 # not kept
230 - /*static*/ function notifyLog( $timestamp, &$title, &$user, $comment )
 252+ /*static*/ function notifyLog( $timestamp, &$title, &$user, $comment, $ip='' )
231253 {
 254+ if ( !$ip ) {
 255+ global $wgIP;
 256+ $ip = empty( $wgIP ) ? '' : $wgIP;
 257+ }
232258 $rc = new RecentChange;
233259 $rc->mAttribs = array(
234260 'rc_timestamp' => $timestamp,
@@ -245,6 +271,7 @@
246272 'rc_bot' => 0,
247273 'rc_moved_to_ns' => 0,
248274 'rc_moved_to_title' => '',
 275+ 'rc_ip' => $ip,
249276 'rc_new' => 0 # obsolete
250277 );
251278 $rc->mExtra = array(
@@ -280,6 +307,7 @@
281308 'rc_bot' => 0,
282309 'rc_moved_to_ns' => 0,
283310 'rc_moved_to_title' => '',
 311+ 'rc_ip' => '',
284312 'rc_new' => $row->cur_is_new # obsolete
285313 );
286314
Index: trunk/phase3/includes/DefaultSettings.php
@@ -332,6 +332,9 @@
333333 # Show seconds in Recent Changes
334334 $wgRCSeconds = false;
335335
 336+# Log IP addresses in the recentchanges table
 337+$wgPutIPinRC = false;
 338+
336339 # RDF metadata toggles
337340 $wgEnableDublinCoreRdf = false;
338341 $wgEnableCreativeCommonsRdf = false;

Status & tagging log