Index: branches/REL1_6/phase3/maintenance/userDupes.inc |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | $fname = 'UserDupes::hasUniqueIndex'; |
41 | 41 | $info = $this->db->indexInfo( 'user', 'user_name', $fname ); |
42 | 42 | if( !$info ) { |
43 | | - echo "WARNING: doesn't seem to have user_name index at all!\n"; |
| 43 | + wfOut( "WARNING: doesn't seem to have user_name index at all!\n" ); |
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
— | — | @@ -88,11 +88,11 @@ |
89 | 89 | |
90 | 90 | $this->lock(); |
91 | 91 | |
92 | | - echo "Checking for duplicate accounts...\n"; |
| 92 | + wfOut( "Checking for duplicate accounts...\n" ); |
93 | 93 | $dupes = $this->getDupes(); |
94 | 94 | $count = count( $dupes ); |
95 | 95 | |
96 | | - echo "Found $count accounts with duplicate records on $wgDBname.\n"; |
| 96 | + wfOut( "Found $count accounts with duplicate records on $wgDBname.\n" ); |
97 | 97 | $this->trimmed = 0; |
98 | 98 | $this->reassigned = 0; |
99 | 99 | $this->failed = 0; |
— | — | @@ -102,34 +102,34 @@ |
103 | 103 | |
104 | 104 | $this->unlock(); |
105 | 105 | |
106 | | - echo "\n"; |
| 106 | + wfOut( "\n" ); |
107 | 107 | |
108 | 108 | if( $this->reassigned > 0 ) { |
109 | 109 | if( $doDelete ) { |
110 | | - echo "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n"; |
| 110 | + wfOut( "$this->reassigned duplicate accounts had edits reassigned to a canonical record id.\n" ); |
111 | 111 | } else { |
112 | | - echo "$this->reassigned duplicate accounts need to have edits reassigned.\n"; |
| 112 | + wfOut( "$this->reassigned duplicate accounts need to have edits reassigned.\n" ); |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | if( $this->trimmed > 0 ) { |
117 | 117 | if( $doDelete ) { |
118 | | - echo "$this->trimmed duplicate user records were deleted from $wgDBname.\n"; |
| 118 | + wfOut( "$this->trimmed duplicate user records were deleted from $wgDBname.\n" ); |
119 | 119 | } else { |
120 | | - echo "$this->trimmed duplicate user accounts were found on $wgDBname which can be removed safely.\n"; |
| 120 | + wfOut( "$this->trimmed duplicate user accounts were found on $wgDBname which can be removed safely.\n" ); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | 124 | if( $this->failed > 0 ) { |
125 | | - echo "Something terribly awry; $this->failed duplicate accounts were not removed.\n"; |
| 125 | + wfOut( "Something terribly awry; $this->failed duplicate accounts were not removed.\n" ); |
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
129 | 129 | if( $this->trimmed == 0 || $doDelete ) { |
130 | | - echo "It is now safe to apply the unique index on user_name.\n"; |
| 130 | + wfOut( "It is now safe to apply the unique index on user_name.\n" ); |
131 | 131 | return true; |
132 | 132 | } else { |
133 | | - echo "Run this script again with the --fix option to automatically delete them.\n"; |
| 133 | + wfOut( "Run this script again with the --fix option to automatically delete them.\n" ); |
134 | 134 | return false; |
135 | 135 | } |
136 | 136 | } |
— | — | @@ -211,36 +211,36 @@ |
212 | 212 | |
213 | 213 | $firstRow = $this->db->fetchObject( $result ); |
214 | 214 | $firstId = $firstRow->user_id; |
215 | | - echo "Record that will be used for '$name' is user_id=$firstId\n"; |
| 215 | + wfOut( "Record that will be used for '$name' is user_id=$firstId\n" ); |
216 | 216 | |
217 | 217 | while( $row = $this->db->fetchObject( $result ) ) { |
218 | 218 | $dupeId = $row->user_id; |
219 | | - echo "... dupe id $dupeId: "; |
| 219 | + wfOut( "... dupe id $dupeId: " ); |
220 | 220 | $edits = $this->editCount( $dupeId ); |
221 | 221 | if( $edits > 0 ) { |
222 | 222 | $this->reassigned++; |
223 | | - echo "has $edits edits! "; |
| 223 | + wfOut( "has $edits edits! " ); |
224 | 224 | if( $doDelete ) { |
225 | 225 | $this->reassignEdits( $dupeId, $firstId ); |
226 | 226 | $newEdits = $this->editCount( $dupeId ); |
227 | 227 | if( $newEdits == 0 ) { |
228 | | - echo "confirmed cleaned. "; |
| 228 | + wfOut( "confirmed cleaned. " ); |
229 | 229 | } else { |
230 | 230 | $this->failed++; |
231 | | - echo "WARNING! $newEdits remaining edits for $dupeId; NOT deleting user.\n"; |
| 231 | + wfOut( "WARNING! $newEdits remaining edits for $dupeId; NOT deleting user.\n" ); |
232 | 232 | continue; |
233 | 233 | } |
234 | 234 | } else { |
235 | | - echo "(will need to reassign edits on fix)"; |
| 235 | + wfOut( "(will need to reassign edits on fix)" ); |
236 | 236 | } |
237 | 237 | } else { |
238 | | - echo "ok, no edits. "; |
| 238 | + wfOut( "ok, no edits. " ); |
239 | 239 | } |
240 | 240 | $this->trimmed++; |
241 | 241 | if( $doDelete ) { |
242 | 242 | $this->trimAccount( $dupeId ); |
243 | 243 | } |
244 | | - echo "\n"; |
| 244 | + wfOut( "\n" ); |
245 | 245 | } |
246 | 246 | $this->db->freeResult( $result ); |
247 | 247 | } |
— | — | @@ -302,12 +302,12 @@ |
303 | 303 | */ |
304 | 304 | function reassignEditsOn( $table, $field, $from, $to ) { |
305 | 305 | $fname = 'UserDupes::reassignEditsOn'; |
306 | | - echo "reassigning on $table... "; |
| 306 | + wfOut( "reassigning on $table... " ); |
307 | 307 | $result = $this->db->update( $table, |
308 | 308 | array( $field => $to ), |
309 | 309 | array( $field => $from ), |
310 | 310 | $fname ); |
311 | | - echo "ok. "; |
| 311 | + wfOut( "ok. " ); |
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
— | — | @@ -317,12 +317,12 @@ |
318 | 318 | */ |
319 | 319 | function trimAccount( $userid ) { |
320 | 320 | $fname = 'UserDupes::trimAccount'; |
321 | | - echo "deleting..."; |
| 321 | + wfOut( "deleting..." ); |
322 | 322 | $this->db->delete( 'user', array( 'user_id' => $userid ), $fname ); |
323 | | - echo " ok"; |
| 323 | + wfOut( " ok" ); |
324 | 324 | } |
325 | 325 | |
326 | 326 | } |
327 | 327 | |
328 | 328 | |
329 | | -?> |
\ No newline at end of file |
| 329 | +?> |
Index: branches/REL1_6/phase3/maintenance/convertLinks.inc |
— | — | @@ -9,11 +9,11 @@ |
10 | 10 | function convertLinks() { |
11 | 11 | global $wgDBtype; |
12 | 12 | if( $wgDBtype == 'PostgreSQL' ) { |
13 | | - print "Links table already ok on PostgreSQL.\n"; |
| 13 | + wfOut( "Links table already ok on PostgreSQL.\n" ); |
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | | - print "Converting links table to ID-ID...\n"; |
| 17 | + wfOut( "Converting links table to ID-ID...\n" ); |
18 | 18 | |
19 | 19 | global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
20 | 20 | global $noKeys, $logPerformance, $fh; |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | |
50 | 50 | $res = $dbw->query( "SELECT l_from FROM $links LIMIT 1" ); |
51 | 51 | if ( $dbw->fieldType( $res, 0 ) == "int" ) { |
52 | | - print "Schema already converted\n"; |
| 52 | + wfOut( "Schema already converted\n" ); |
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
— | — | @@ -58,13 +58,13 @@ |
59 | 59 | $dbw->freeResult( $res ); |
60 | 60 | |
61 | 61 | if ( $numRows == 0 ) { |
62 | | - print "Updating schema (no rows to convert)...\n"; |
| 62 | + wfOut( "Updating schema (no rows to convert)...\n" ); |
63 | 63 | createTempTable(); |
64 | 64 | } else { |
65 | 65 | if ( $logPerformance ) { $fh = fopen ( $perfLogFilename, "w" ); } |
66 | 66 | $baseTime = $startTime = getMicroTime(); |
67 | 67 | # Create a title -> cur_id map |
68 | | - print "Loading IDs from $cur table...\n"; |
| 68 | + wfOut( "Loading IDs from $cur table...\n" ); |
69 | 69 | performanceLog ( "Reading $numRows rows from cur table...\n" ); |
70 | 70 | performanceLog ( "rows read vs seconds elapsed:\n" ); |
71 | 71 | |
— | — | @@ -82,13 +82,13 @@ |
83 | 83 | if ($reportCurReadProgress) { |
84 | 84 | if (($curRowsRead % $curReadReportInterval) == 0) { |
85 | 85 | performanceLog( $curRowsRead . " " . (getMicroTime() - $baseTime) . "\n" ); |
86 | | - print "\t$curRowsRead rows of $cur table read.\n"; |
| 86 | + wfOut( "\t$curRowsRead rows of $cur table read.\n" ); |
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
90 | 90 | $dbw->freeResult( $res ); |
91 | 91 | $dbw->bufferResults( true ); |
92 | | - print "Finished loading IDs.\n\n"; |
| 92 | + wfOut( "Finished loading IDs.\n\n" ); |
93 | 93 | performanceLog( "Took " . (getMicroTime() - $baseTime) . " seconds to load IDs.\n\n" ); |
94 | 94 | #-------------------------------------------------------------------- |
95 | 95 | |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | createTempTable(); |
99 | 99 | performanceLog( "Resetting timer.\n\n" ); |
100 | 100 | $baseTime = getMicroTime(); |
101 | | - print "Processing $numRows rows from $links table...\n"; |
| 101 | + wfOut( "Processing $numRows rows from $links table...\n" ); |
102 | 102 | performanceLog( "Processing $numRows rows from $links table...\n" ); |
103 | 103 | performanceLog( "rows inserted vs seconds elapsed:\n" ); |
104 | 104 | |
— | — | @@ -127,19 +127,19 @@ |
128 | 128 | } |
129 | 129 | } |
130 | 130 | $dbw->freeResult($res); |
131 | | - #print "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n"; |
| 131 | + #wfOut( "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n" ); |
132 | 132 | if ( $tuplesAdded != 0 ) { |
133 | 133 | if ($reportLinksConvProgress) { |
134 | | - print "Inserting $tuplesAdded tuples into $links_temp..."; |
| 134 | + wfOut( "Inserting $tuplesAdded tuples into $links_temp..." ); |
135 | 135 | } |
136 | 136 | $dbw->query( implode("",$sqlWrite) ); |
137 | 137 | $totalTuplesInserted += $tuplesAdded; |
138 | 138 | if ($reportLinksConvProgress) |
139 | | - print " done. Total $totalTuplesInserted tuples inserted.\n"; |
| 139 | + wfOut( " done. Total $totalTuplesInserted tuples inserted.\n" ); |
140 | 140 | performanceLog( $totalTuplesInserted . " " . (getMicroTime() - $baseTime) . "\n" ); |
141 | 141 | } |
142 | 142 | } |
143 | | - print "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n"; |
| 143 | + wfOut( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n" ); |
144 | 144 | performanceLog( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n" ); |
145 | 145 | performanceLog( "Total execution time: " . (getMicroTime() - $startTime) . " seconds.\n" ); |
146 | 146 | if ( $logPerformance ) { fclose ( $fh ); } |
— | — | @@ -149,25 +149,25 @@ |
150 | 150 | if ( $overwriteLinksTable ) { |
151 | 151 | $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
152 | 152 | if (!($dbConn->isOpen())) { |
153 | | - print "Opening connection to database failed.\n"; |
| 153 | + wfOut( "Opening connection to database failed.\n" ); |
154 | 154 | return; |
155 | 155 | } |
156 | 156 | # Check for existing links_backup, and delete it if it exists. |
157 | | - print "Dropping backup links table if it exists..."; |
| 157 | + wfOut( "Dropping backup links table if it exists..." ); |
158 | 158 | $dbConn->query( "DROP TABLE IF EXISTS $links_backup", DB_MASTER); |
159 | | - print " done.\n"; |
| 159 | + wfOut( " done.\n" ); |
160 | 160 | |
161 | 161 | # Swap in the new table, and move old links table to links_backup |
162 | | - print "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'..."; |
| 162 | + wfOut( "Swapping tables '$links' to '$links_backup'; '$links_temp' to '$links'..." ); |
163 | 163 | $dbConn->query( "RENAME TABLE links TO $links_backup, $links_temp TO $links", DB_MASTER ); |
164 | | - print " done.\n\n"; |
| 164 | + wfOut( " done.\n\n" ); |
165 | 165 | |
166 | 166 | $dbConn->close(); |
167 | | - print "Conversion complete. The old table remains at $links_backup;\n"; |
168 | | - print "delete at your leisure.\n"; |
| 167 | + wfOut( "Conversion complete. The old table remains at $links_backup;\n" ); |
| 168 | + wfOut( "delete at your leisure.\n" ); |
169 | 169 | } else { |
170 | | - print "Conversion complete. The converted table is at $links_temp;\n"; |
171 | | - print "the original links table is unchanged.\n"; |
| 170 | + wfOut( "Conversion complete. The converted table is at $links_temp;\n" ); |
| 171 | + wfOut( "the original links table is unchanged.\n" ); |
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
— | — | @@ -179,16 +179,16 @@ |
180 | 180 | $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
181 | 181 | |
182 | 182 | if (!($dbConn->isOpen())) { |
183 | | - print "Opening connection to database failed.\n"; |
| 183 | + wfOut( "Opening connection to database failed.\n" ); |
184 | 184 | return; |
185 | 185 | } |
186 | 186 | $links_temp = $dbConn->tableName( 'links_temp' ); |
187 | 187 | |
188 | | - print "Dropping temporary links table if it exists..."; |
| 188 | + wfOut( "Dropping temporary links table if it exists..." ); |
189 | 189 | $dbConn->query( "DROP TABLE IF EXISTS $links_temp"); |
190 | | - print " done.\n"; |
| 190 | + wfOut( " done.\n" ); |
191 | 191 | |
192 | | - print "Creating temporary links table..."; |
| 192 | + wfOut( "Creating temporary links table..." ); |
193 | 193 | if ( $noKeys ) { |
194 | 194 | $dbConn->query( "CREATE TABLE $links_temp ( " . |
195 | 195 | "l_from int(8) unsigned NOT NULL default '0', " . |
— | — | @@ -200,7 +200,7 @@ |
201 | 201 | "UNIQUE KEY l_from(l_from,l_to), " . |
202 | 202 | "KEY (l_to))"); |
203 | 203 | } |
204 | | - print " done.\n\n"; |
| 204 | + wfOut( " done.\n\n" ); |
205 | 205 | } |
206 | 206 | |
207 | 207 | function performanceLog( $text ) { |
Index: branches/REL1_6/phase3/maintenance/updaters.inc |
— | — | @@ -61,11 +61,11 @@ |
62 | 62 | global $wgDatabase; |
63 | 63 | if ( $wgDatabase->tableExists( $from ) ) { |
64 | 64 | if ( $wgDatabase->tableExists( $to ) ) { |
65 | | - echo "...can't move table $from to $to, $to already exists.\n"; |
| 65 | + wfOut( "...can't move table $from to $to, $to already exists.\n" ); |
66 | 66 | } else { |
67 | | - echo "Moving table $from to $to..."; |
| 67 | + wfOut( "Moving table $from to $to..." ); |
68 | 68 | dbsource( archive($patch), $wgDatabase ); |
69 | | - echo "ok\n"; |
| 69 | + wfOut( "ok\n" ); |
70 | 70 | } |
71 | 71 | } else { |
72 | 72 | // Source table does not exist |
— | — | @@ -77,24 +77,24 @@ |
78 | 78 | function add_table( $name, $patch ) { |
79 | 79 | global $wgDatabase; |
80 | 80 | if ( $wgDatabase->tableExists( $name ) ) { |
81 | | - echo "...$name table already exists.\n"; |
| 81 | + wfOut( "...$name table already exists.\n" ); |
82 | 82 | } else { |
83 | | - echo "Creating $name table..."; |
| 83 | + wfOut( "Creating $name table..." ); |
84 | 84 | dbsource( archive($patch), $wgDatabase ); |
85 | | - echo "ok\n"; |
| 85 | + wfOut( "ok\n" ); |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | 89 | function add_field( $table, $field, $patch ) { |
90 | 90 | global $wgDatabase; |
91 | 91 | if ( !$wgDatabase->tableExists( $table ) ) { |
92 | | - echo "...$table table does not exist, skipping new field patch\n"; |
| 92 | + wfOut( "...$table table does not exist, skipping new field patch\n" ); |
93 | 93 | } elseif ( $wgDatabase->fieldExists( $table, $field ) ) { |
94 | | - echo "...have $field field in $table table.\n"; |
| 94 | + wfOut( "...have $field field in $table table.\n" ); |
95 | 95 | } else { |
96 | | - echo "Adding $field field to table $table..."; |
| 96 | + wfOut( "Adding $field field to table $table..." ); |
97 | 97 | dbsource( archive($patch) , $wgDatabase ); |
98 | | - echo "ok\n"; |
| 98 | + wfOut( "ok\n" ); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
— | — | @@ -110,11 +110,11 @@ |
111 | 111 | |
112 | 112 | global $wgDatabase; |
113 | 113 | $fname = "Update script: update_passwords()"; |
114 | | - print "\nIt appears that you need to update the user passwords in your\n" . |
| 114 | + wfOut( "\nIt appears that you need to update the user passwords in your\n" . |
115 | 115 | "database. If you have already done this (if you've run this update\n" . |
116 | 116 | "script once before, for example), doing so again will make all your\n" . |
117 | 117 | "user accounts inaccessible, so be sure you only do this once.\n" . |
118 | | - "Update user passwords? (yes/no)"; |
| 118 | + "Update user passwords? (yes/no)" ); |
119 | 119 | |
120 | 120 | $resp = readconsole(); |
121 | 121 | if ( ! ( "Y" == $resp{0} || "y" == $resp{0} ) ) { return; } |
— | — | @@ -137,15 +137,15 @@ |
138 | 138 | # Check that interwiki table exists; if it doesn't source it |
139 | 139 | global $wgDatabase, $IP; |
140 | 140 | if( $wgDatabase->tableExists( "interwiki" ) ) { |
141 | | - echo "...already have interwiki table\n"; |
| 141 | + wfOut( "...already have interwiki table\n" ); |
142 | 142 | return true; |
143 | 143 | } |
144 | | - echo "Creating interwiki table: "; |
| 144 | + wfOut( "Creating interwiki table: " ); |
145 | 145 | dbsource( archive("patch-interwiki.sql") ); |
146 | | - echo "ok\n"; |
147 | | - echo "Adding default interwiki definitions: "; |
| 146 | + wfOut( "ok\n" ); |
| 147 | + wfOut( "Adding default interwiki definitions: " ); |
148 | 148 | dbsource( "$IP/maintenance/interwiki.sql" ); |
149 | | - echo "ok\n"; |
| 149 | + wfOut( "ok\n" ); |
150 | 150 | } |
151 | 151 | |
152 | 152 | function do_index_update() { |
— | — | @@ -153,12 +153,12 @@ |
154 | 154 | global $wgDatabase; |
155 | 155 | $meta = $wgDatabase->fieldInfo( "recentchanges", "rc_timestamp" ); |
156 | 156 | if( $meta->multiple_key == 0 ) { |
157 | | - echo "Updating indexes to 20031107: "; |
| 157 | + wfOut( "Updating indexes to 20031107: " ); |
158 | 158 | dbsource( archive("patch-indexes.sql") ); |
159 | | - echo "ok\n"; |
| 159 | + wfOut( "ok\n" ); |
160 | 160 | return true; |
161 | 161 | } |
162 | | - echo "...indexes seem up to 20031107 standards\n"; |
| 162 | + wfOut( "...indexes seem up to 20031107 standards\n" ); |
163 | 163 | return false; |
164 | 164 | } |
165 | 165 | |
— | — | @@ -167,34 +167,34 @@ |
168 | 168 | |
169 | 169 | $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" ); |
170 | 170 | if( $meta->multiple_key == 0 ) { |
171 | | - echo "Updating indexes to 20050912: "; |
| 171 | + wfOut( "Updating indexes to 20050912: " ); |
172 | 172 | dbsource( archive("patch-mimesearch-indexes.sql") ); |
173 | | - echo "ok\n"; |
| 173 | + wfOut( "ok\n" ); |
174 | 174 | return true; |
175 | 175 | } |
176 | | - echo "...indexes seem up to 20050912 standards\n"; |
| 176 | + wfOut( "...indexes seem up to 20050912 standards\n" ); |
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | 180 | function do_image_name_unique_update() { |
181 | 181 | global $wgDatabase; |
182 | 182 | if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) { |
183 | | - echo "...image primary key already set.\n"; |
| 183 | + wfOut( "...image primary key already set.\n" ); |
184 | 184 | } else { |
185 | | - echo "Making img_name the primary key... "; |
| 185 | + wfOut( "Making img_name the primary key... " ); |
186 | 186 | dbsource( archive("patch-image_name_primary.sql"), $wgDatabase ); |
187 | | - echo "ok\n"; |
| 187 | + wfOut( "ok\n" ); |
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | 191 | function do_logging_timestamp_index() { |
192 | 192 | global $wgDatabase; |
193 | 193 | if( $wgDatabase->indexExists( 'logging', 'times' ) ) { |
194 | | - echo "...timestamp key on logging already exists.\n"; |
| 194 | + wfOut( "...timestamp key on logging already exists.\n" ); |
195 | 195 | } else { |
196 | | - echo "Adding timestamp key on logging table... "; |
| 196 | + wfOut( "Adding timestamp key on logging table... " ); |
197 | 197 | dbsource( archive("patch-logging-times-index.sql"), $wgDatabase ); |
198 | | - echo "ok\n"; |
| 198 | + wfOut( "ok\n" ); |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
— | — | @@ -203,18 +203,18 @@ |
204 | 204 | global $wgDatabase; |
205 | 205 | $fname = 'do_watchlist_update'; |
206 | 206 | if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) { |
207 | | - echo "The watchlist table is already set up for email notification.\n"; |
| 207 | + wfOut( "The watchlist table is already set up for email notification.\n" ); |
208 | 208 | } else { |
209 | | - echo "Adding wl_notificationtimestamp field for email notification management."; |
| 209 | + wfOut( "Adding wl_notificationtimestamp field for email notification management." ); |
210 | 210 | /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */ |
211 | 211 | dbsource( archive( 'patch-email-notification.sql' ), $wgDatabase ); |
212 | | - echo "ok\n"; |
| 212 | + wfOut( "ok\n" ); |
213 | 213 | } |
214 | 214 | # Check if we need to add talk page rows to the watchlist |
215 | 215 | $talk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', $fname ); |
216 | 216 | $nontalk = $wgDatabase->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', $fname ); |
217 | 217 | if ( $talk != $nontalk ) { |
218 | | - echo "Adding missing watchlist talk page rows... "; |
| 218 | + wfOut( "Adding missing watchlist talk page rows... " ); |
219 | 219 | flush(); |
220 | 220 | |
221 | 221 | $wgDatabase->insertSelect( 'watchlist', 'watchlist', |
— | — | @@ -224,9 +224,9 @@ |
225 | 225 | 'wl_title' => 'wl_title', |
226 | 226 | 'wl_notificationtimestamp' => 'wl_notificationtimestamp' |
227 | 227 | ), array( 'NOT (wl_namespace & 1)' ), $fname, 'IGNORE' ); |
228 | | - echo "ok\n"; |
| 228 | + wfOut( "ok\n" ); |
229 | 229 | } else { |
230 | | - echo "...watchlist talk page rows already present\n"; |
| 230 | + wfOut( "...watchlist talk page rows already present\n" ); |
231 | 231 | } |
232 | 232 | } |
233 | 233 | |
— | — | @@ -237,7 +237,7 @@ |
238 | 238 | $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !', |
239 | 239 | $wgDatabase->tableName( 'user_newtalk' ) ); |
240 | 240 | $num_newtalks=$wgDatabase->numRows($res); |
241 | | - echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n"; |
| 241 | + wfOut( "Now converting $num_newtalks user_newtalk entries to watchlist table entries ... \n" ); |
242 | 242 | |
243 | 243 | $user = new User(); |
244 | 244 | for ( $i = 1; $i <= $num_newtalks; $i++ ) { |
— | — | @@ -265,18 +265,18 @@ |
266 | 266 | ); |
267 | 267 | } |
268 | 268 | } |
269 | | - echo "Done.\n"; |
| 269 | + wfOut( "Done.\n" ); |
270 | 270 | } |
271 | 271 | |
272 | 272 | |
273 | 273 | function do_user_update() { |
274 | 274 | global $wgDatabase; |
275 | 275 | if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) { |
276 | | - echo "User table contains old email authentication field. Dropping... "; |
| 276 | + wfOut( "User table contains old email authentication field. Dropping... " ); |
277 | 277 | dbsource( archive( 'patch-email-authentication.sql' ), $wgDatabase ); |
278 | | - echo "ok\n"; |
| 278 | + wfOut( "ok\n" ); |
279 | 279 | } else { |
280 | | - echo "...user table does not contain old email authentication field.\n"; |
| 280 | + wfOut( "...user table does not contain old email authentication field.\n" ); |
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
— | — | @@ -294,11 +294,11 @@ |
295 | 295 | $wgDatabase->freeResult( $res ); |
296 | 296 | |
297 | 297 | if( in_array( 'binary', $flags ) ) { |
298 | | - echo "Logging table has correct title encoding.\n"; |
| 298 | + wfOut( "Logging table has correct title encoding.\n" ); |
299 | 299 | } else { |
300 | | - echo "Fixing title encoding on logging table... "; |
| 300 | + wfOut( "Fixing title encoding on logging table... " ); |
301 | 301 | dbsource( archive( 'patch-logging-title.sql' ), $wgDatabase ); |
302 | | - echo "ok\n"; |
| 302 | + wfOut( "ok\n" ); |
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
— | — | @@ -306,11 +306,11 @@ |
307 | 307 | global $wgDatabase; |
308 | 308 | $fname="do_schema_restructuring"; |
309 | 309 | if ( $wgDatabase->tableExists( 'page' ) ) { |
310 | | - echo "...page table already exists.\n"; |
| 310 | + wfOut( "...page table already exists.\n" ); |
311 | 311 | } else { |
312 | | - echo "...converting from cur/old to page/revision/text DB structure.\n"; flush(); |
313 | | - echo wfTimestamp(); |
314 | | - echo "......checking for duplicate entries.\n"; flush(); |
| 312 | + wfOut( "...converting from cur/old to page/revision/text DB structure.\n" ); |
| 313 | + wfOut( wfTimestamp() ); |
| 314 | + wfOut( "......checking for duplicate entries.\n" ); |
315 | 315 | |
316 | 316 | extract( $wgDatabase->tableNames( 'cur', 'old', 'page', 'revision', 'text' ) ); |
317 | 317 | |
— | — | @@ -318,15 +318,15 @@ |
319 | 319 | FROM $cur GROUP BY cur_title, cur_namespace HAVING c>1", $fname ); |
320 | 320 | |
321 | 321 | if ( $wgDatabase->numRows( $rows ) > 0 ) { |
322 | | - echo wfTimestamp(); |
323 | | - echo "......<b>Found duplicate entries</b>\n"; |
324 | | - echo ( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
| 322 | + wfOut( wfTimestamp() ); |
| 323 | + wfOut( "......<b>Found duplicate entries</b>\n" ); |
| 324 | + wfOut( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) ); |
325 | 325 | while ( $row = $wgDatabase->fetchObject( $rows ) ) { |
326 | 326 | if ( ! isset( $duplicate[$row->cur_namespace] ) ) { |
327 | 327 | $duplicate[$row->cur_namespace] = array(); |
328 | 328 | } |
329 | 329 | $duplicate[$row->cur_namespace][] = $row->cur_title; |
330 | | - echo ( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
| 330 | + wfOut( sprintf( " %-60s %3s %5s\n", $row->cur_title, $row->cur_namespace, $row->c ) ); |
331 | 331 | } |
332 | 332 | $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE "; |
333 | 333 | $firstCond = true; |
— | — | @@ -366,13 +366,13 @@ |
367 | 367 | } |
368 | 368 | $sql = "DELETE FROM $cur WHERE cur_id IN ( " . join( ',', $deleteId ) . ')'; |
369 | 369 | $rows = $wgDatabase->query( $sql, $fname ); |
370 | | - echo wfTimestamp(); |
371 | | - echo "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n"; |
| 370 | + wfOut( wfTimestamp() ); |
| 371 | + wfOut( "......<b>Deleted</b> ".$wgDatabase->affectedRows()." records.\n" ); |
372 | 372 | } |
373 | 373 | |
374 | 374 | |
375 | | - echo wfTimestamp(); |
376 | | - echo "......Creating tables.\n"; |
| 375 | + wfOut( wfTimestamp() ); |
| 376 | + wfOut( "......Creating tables.\n" ); |
377 | 377 | $wgDatabase->query("CREATE TABLE $page ( |
378 | 378 | page_id int(8) unsigned NOT NULL auto_increment, |
379 | 379 | page_namespace int NOT NULL, |
— | — | @@ -409,26 +409,26 @@ |
410 | 410 | INDEX usertext_timestamp (rev_user_text,rev_timestamp) |
411 | 411 | ) TYPE=InnoDB", $fname ); |
412 | 412 | |
413 | | - echo wfTimestamp(); |
414 | | - echo "......Locking tables.\n"; |
| 413 | + wfOut( wfTimestamp() ); |
| 414 | + wfOut( "......Locking tables.\n" ); |
415 | 415 | $wgDatabase->query( "LOCK TABLES $page WRITE, $revision WRITE, $old WRITE, $cur WRITE", $fname ); |
416 | 416 | |
417 | 417 | $maxold = intval( $wgDatabase->selectField( 'old', 'max(old_id)', '', $fname ) ); |
418 | | - echo wfTimestamp(); |
419 | | - echo "......maxold is {$maxold}\n"; |
| 418 | + wfOut( wfTimestamp() ); |
| 419 | + wfOut( "......maxold is {$maxold}\n" ); |
420 | 420 | |
421 | | - echo wfTimestamp(); |
| 421 | + wfOut( wfTimestamp() ); |
422 | 422 | global $wgLegacySchemaConversion; |
423 | 423 | if( $wgLegacySchemaConversion ) { |
424 | 424 | // Create HistoryBlobCurStub entries. |
425 | 425 | // Text will be pulled from the leftover 'cur' table at runtime. |
426 | | - echo "......Moving metadata from cur; using blob references to text in cur table.\n"; |
| 426 | + wfOut( "......Moving metadata from cur; using blob references to text in cur table.\n" ); |
427 | 427 | $cur_text = "concat('O:18:\"historyblobcurstub\":1:{s:6:\"mCurId\";i:',cur_id,';}')"; |
428 | 428 | $cur_flags = "'object'"; |
429 | 429 | } else { |
430 | 430 | // Copy all cur text in immediately: this may take longer but avoids |
431 | 431 | // having to keep an extra table around. |
432 | | - echo "......Moving text from cur.\n"; |
| 432 | + wfOut( "......Moving text from cur.\n" ); |
433 | 433 | $cur_text = 'cur_text'; |
434 | 434 | $cur_flags = "''"; |
435 | 435 | } |
— | — | @@ -437,16 +437,16 @@ |
438 | 438 | SELECT cur_namespace, cur_title, $cur_text, cur_comment, cur_user, cur_user_text, cur_timestamp, cur_minor_edit, $cur_flags |
439 | 439 | FROM $cur", $fname ); |
440 | 440 | |
441 | | - echo wfTimestamp(); |
442 | | - echo "......Setting up revision table.\n"; |
| 441 | + wfOut( wfTimestamp() ); |
| 442 | + wfOut( "......Setting up revision table.\n" ); |
443 | 443 | $wgDatabase->query( "INSERT INTO $revision (rev_id, rev_page, rev_comment, rev_user, rev_user_text, rev_timestamp, |
444 | 444 | rev_minor_edit) |
445 | 445 | SELECT old_id, cur_id, old_comment, old_user, old_user_text, |
446 | 446 | old_timestamp, old_minor_edit |
447 | 447 | FROM $old,$cur WHERE old_namespace=cur_namespace AND old_title=cur_title", $fname ); |
448 | 448 | |
449 | | - echo wfTimestamp(); |
450 | | - echo "......Setting up page table.\n"; |
| 449 | + wfOut( wfTimestamp() ); |
| 450 | + wfOut( "......Setting up page table.\n" ); |
451 | 451 | $wgDatabase->query( "INSERT INTO $page (page_id, page_namespace, page_title, page_restrictions, page_counter, |
452 | 452 | page_is_redirect, page_is_new, page_random, page_touched, page_latest, page_len) |
453 | 453 | SELECT cur_id, cur_namespace, cur_title, cur_restrictions, cur_counter, cur_is_redirect, cur_is_new, |
— | — | @@ -454,16 +454,16 @@ |
455 | 455 | FROM $cur,$revision |
456 | 456 | WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}", $fname ); |
457 | 457 | |
458 | | - echo wfTimestamp(); |
459 | | - echo "......Unlocking tables.\n"; |
| 458 | + wfOut( wfTimestamp() ); |
| 459 | + wfOut( "......Unlocking tables.\n" ); |
460 | 460 | $wgDatabase->query( "UNLOCK TABLES", $fname ); |
461 | 461 | |
462 | | - echo wfTimestamp(); |
463 | | - echo "......Renaming old.\n"; |
| 462 | + wfOut( wfTimestamp() ); |
| 463 | + wfOut( "......Renaming old.\n" ); |
464 | 464 | $wgDatabase->query( "ALTER TABLE $old RENAME TO $text", $fname ); |
465 | 465 | |
466 | | - echo wfTimestamp(); |
467 | | - echo "...done.\n"; |
| 466 | + wfOut( wfTimestamp() ); |
| 467 | + wfOut( "...done.\n" ); |
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
— | — | @@ -471,22 +471,22 @@ |
472 | 472 | global $wgDatabase; |
473 | 473 | $fname="do_schema_restructuring"; |
474 | 474 | if( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) { |
475 | | - echo "Removing revision.inverse_timestamp and fixing indexes... "; |
| 475 | + wfOut( "Removing revision.inverse_timestamp and fixing indexes... " ); |
476 | 476 | dbsource( archive( 'patch-inverse_timestamp.sql' ), $wgDatabase ); |
477 | | - echo "ok\n"; |
| 477 | + wfOut( "ok\n" ); |
478 | 478 | } else { |
479 | | - echo "revision timestamp indexes already up to 2005-03-13\n"; |
| 479 | + wfOut( "revision timestamp indexes already up to 2005-03-13\n" ); |
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | 483 | function do_text_id() { |
484 | 484 | global $wgDatabase; |
485 | 485 | if( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) { |
486 | | - echo "...rev_text_id already in place.\n"; |
| 486 | + wfOut( "...rev_text_id already in place.\n" ); |
487 | 487 | } else { |
488 | | - echo "Adding rev_text_id field... "; |
| 488 | + wfOut( "Adding rev_text_id field... " ); |
489 | 489 | dbsource( archive( 'patch-rev_text_id.sql' ), $wgDatabase ); |
490 | | - echo "ok\n"; |
| 490 | + wfOut( "ok\n" ); |
491 | 491 | } |
492 | 492 | } |
493 | 493 | |
— | — | @@ -517,25 +517,25 @@ |
518 | 518 | $wgDatabase->freeResult( $result ); |
519 | 519 | |
520 | 520 | if( substr( $info->Type, 0, 3 ) == 'int' ) { |
521 | | - echo "...$field is already a full int ($info->Type).\n"; |
| 521 | + wfOut( "...$field is already a full int ($info->Type).\n" ); |
522 | 522 | } else { |
523 | | - echo "Promoting $field from $info->Type to int... "; |
| 523 | + wfOut( "Promoting $field from $info->Type to int... " ); |
524 | 524 | |
525 | 525 | $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL"; |
526 | 526 | $wgDatabase->query( $sql ); |
527 | 527 | |
528 | | - echo "ok\n"; |
| 528 | + wfOut( "ok\n" ); |
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | 532 | function do_pagelinks_update() { |
533 | 533 | global $wgDatabase; |
534 | 534 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
535 | | - echo "...already have pagelinks table.\n"; |
| 535 | + wfOut( "...already have pagelinks table.\n" ); |
536 | 536 | } else { |
537 | | - echo "Converting links and brokenlinks tables to pagelinks... "; |
| 537 | + wfOut( "Converting links and brokenlinks tables to pagelinks... " ); |
538 | 538 | dbsource( archive( 'patch-pagelinks.sql' ), $wgDatabase ); |
539 | | - echo "ok\n"; |
| 539 | + wfOut( "ok\n" ); |
540 | 540 | flush(); |
541 | 541 | |
542 | 542 | global $wgCanonicalNamespaceNames; |
— | — | @@ -551,7 +551,7 @@ |
552 | 552 | global $wgDatabase, $wgContLang; |
553 | 553 | |
554 | 554 | $ns = intval( $namespace ); |
555 | | - echo "Cleaning up broken links for namespace $ns... "; |
| 555 | + wfOut( "Cleaning up broken links for namespace $ns... " ); |
556 | 556 | |
557 | 557 | $pagelinks = $wgDatabase->tableName( 'pagelinks' ); |
558 | 558 | $name = $wgContLang->getNsText( $ns ); |
— | — | @@ -565,25 +565,25 @@ |
566 | 566 | AND pl_title LIKE '$likeprefix:%'"; |
567 | 567 | |
568 | 568 | $wgDatabase->query( $sql, 'do_pagelinks_namespace' ); |
569 | | - echo "ok\n"; |
| 569 | + wfOut( "ok\n" ); |
570 | 570 | } |
571 | 571 | |
572 | 572 | function do_drop_img_type() { |
573 | 573 | global $wgDatabase; |
574 | 574 | |
575 | 575 | if( $wgDatabase->fieldExists( 'image', 'img_type' ) ) { |
576 | | - echo "Dropping unused img_type field in image table... "; |
| 576 | + wfOut( "Dropping unused img_type field in image table... " ); |
577 | 577 | dbsource( archive( 'patch-drop_img_type.sql' ), $wgDatabase ); |
578 | | - echo "ok\n"; |
| 578 | + wfOut( "ok\n" ); |
579 | 579 | } else { |
580 | | - echo "No img_type field in image table; Good.\n"; |
| 580 | + wfOut( "No img_type field in image table; Good.\n" ); |
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
584 | 584 | function do_old_links_update() { |
585 | 585 | global $wgDatabase; |
586 | 586 | if( $wgDatabase->tableExists( 'pagelinks' ) ) { |
587 | | - echo "Already have pagelinks; skipping old links table updates.\n"; |
| 587 | + wfOut( "Already have pagelinks; skipping old links table updates.\n" ); |
588 | 588 | } else { |
589 | 589 | convertLinks(); flush(); |
590 | 590 | } |
— | — | @@ -593,14 +593,14 @@ |
594 | 594 | global $wgDatabase; |
595 | 595 | $duper = new UserDupes( $wgDatabase ); |
596 | 596 | if( $duper->hasUniqueIndex() ) { |
597 | | - echo "Already have unique user_name index.\n"; |
| 597 | + wfOut( "Already have unique user_name index.\n" ); |
598 | 598 | } else { |
599 | 599 | if( !$duper->clearDupes() ) { |
600 | | - echo "WARNING: This next step will probably fail due to unfixed duplicates...\n"; |
| 600 | + wfOut( "WARNING: This next step will probably fail due to unfixed duplicates...\n" ); |
601 | 601 | } |
602 | | - echo "Adding unique index on user_name... "; |
| 602 | + wfOut( "Adding unique index on user_name... " ); |
603 | 603 | dbsource( archive( 'patch-user_nameindex.sql' ), $wgDatabase ); |
604 | | - echo "ok\n"; |
| 604 | + wfOut( "ok\n" ); |
605 | 605 | } |
606 | 606 | } |
607 | 607 | |
— | — | @@ -609,28 +609,28 @@ |
610 | 610 | global $wgDatabase; |
611 | 611 | |
612 | 612 | if( $wgDatabase->tableExists( 'user_groups' ) ) { |
613 | | - echo "...user_groups table already exists.\n"; |
| 613 | + wfOut( "...user_groups table already exists.\n" ); |
614 | 614 | return do_user_groups_reformat(); |
615 | 615 | } |
616 | 616 | |
617 | | - echo "Adding user_groups table... "; |
| 617 | + wfOut( "Adding user_groups table... " ); |
618 | 618 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
619 | | - echo "ok\n"; |
| 619 | + wfOut( "ok\n" ); |
620 | 620 | |
621 | 621 | if( !$wgDatabase->tableExists( 'user_rights' ) ) { |
622 | 622 | if( $wgDatabase->fieldExists( 'user', 'user_rights' ) ) { |
623 | | - echo "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..."; |
| 623 | + wfOut( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." ); |
624 | 624 | dbsource( archive( 'patch-user_rights.sql' ), $wgDatabase ); |
625 | | - echo "ok\n"; |
| 625 | + wfOut( "ok\n" ); |
626 | 626 | } else { |
627 | | - echo "*** WARNING: couldn't locate user_rights table or field for upgrade.\n"; |
628 | | - echo "*** You may need to manually configure some sysops by manipulating\n"; |
629 | | - echo "*** the user_groups table.\n"; |
| 627 | + wfOut( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" ); |
| 628 | + wfOut( "*** You may need to manually configure some sysops by manipulating\n" ); |
| 629 | + wfOut( "*** the user_groups table.\n" ); |
630 | 630 | return; |
631 | 631 | } |
632 | 632 | } |
633 | 633 | |
634 | | - echo "Converting user_rights table to user_groups... "; |
| 634 | + wfOut( "Converting user_rights table to user_groups... " ); |
635 | 635 | $result = $wgDatabase->select( 'user_rights', |
636 | 636 | array( 'ur_user', 'ur_rights' ), |
637 | 637 | array( "ur_rights != ''" ), |
— | — | @@ -650,7 +650,7 @@ |
651 | 651 | } |
652 | 652 | } |
653 | 653 | $wgDatabase->freeResult( $result ); |
654 | | - echo "ok\n"; |
| 654 | + wfOut( "ok\n" ); |
655 | 655 | } |
656 | 656 | |
657 | 657 | function do_user_groups_reformat() { |
— | — | @@ -661,20 +661,20 @@ |
662 | 662 | if( $info->type == 'int' ) { |
663 | 663 | $oldug = $wgDatabase->tableName( 'user_groups' ); |
664 | 664 | $newug = $wgDatabase->tableName( 'user_groups_bogus' ); |
665 | | - echo "user_groups is in bogus intermediate format. Renaming to $newug... "; |
| 665 | + wfOut( "user_groups is in bogus intermediate format. Renaming to $newug... " ); |
666 | 666 | $wgDatabase->query( "ALTER TABLE $oldug RENAME TO $newug" ); |
667 | | - echo "ok\n"; |
| 667 | + wfOut( "ok\n" ); |
668 | 668 | |
669 | | - echo "Re-adding fresh user_groups table... "; |
| 669 | + wfOut( "Re-adding fresh user_groups table... " ); |
670 | 670 | dbsource( archive( 'patch-user_groups.sql' ), $wgDatabase ); |
671 | | - echo "ok\n"; |
| 671 | + wfOut( "ok\n" ); |
672 | 672 | |
673 | | - echo "***\n"; |
674 | | - echo "*** WARNING: You will need to manually fix up user permissions in the user_groups\n"; |
675 | | - echo "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n"; |
676 | | - echo "***\n"; |
| 673 | + wfOut( "***\n" ); |
| 674 | + wfOut( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" ); |
| 675 | + wfOut( "*** table. Old 1.5 alpha versions did some pretty funky stuff...\n" ); |
| 676 | + wfOut( "***\n" ); |
677 | 677 | } else { |
678 | | - echo "...user_groups is in current format.\n"; |
| 678 | + wfOut( "...user_groups is in current format.\n" ); |
679 | 679 | } |
680 | 680 | |
681 | 681 | } |
— | — | @@ -686,11 +686,11 @@ |
687 | 687 | $info = $wgDatabase->fieldInfo( 'watchlist', 'wl_notificationtimestamp' ); |
688 | 688 | |
689 | 689 | if( $info->not_null ) { |
690 | | - echo "Making wl_notificationtimestamp nullable... "; |
| 690 | + wfOut( "Making wl_notificationtimestamp nullable... " ); |
691 | 691 | dbsource( archive( 'patch-watchlist-null.sql' ), $wgDatabase ); |
692 | | - echo "ok\n"; |
| 692 | + wfOut( "ok\n" ); |
693 | 693 | } else { |
694 | | - echo "...wl_notificationtimestamp is already nullable.\n"; |
| 694 | + wfOut( "...wl_notificationtimestamp is already nullable.\n" ); |
695 | 695 | } |
696 | 696 | |
697 | 697 | } |
— | — | @@ -701,13 +701,13 @@ |
702 | 702 | function do_page_random_update() { |
703 | 703 | global $wgDatabase; |
704 | 704 | |
705 | | - echo "Setting page_random to a random value on rows where it equals 0..."; |
| 705 | + wfOut( "Setting page_random to a random value on rows where it equals 0..." ); |
706 | 706 | |
707 | 707 | $page = $wgDatabase->tableName( 'page' ); |
708 | 708 | $wgDatabase->query( "UPDATE $page SET page_random = RAND() WHERE page_random = 0", 'do_page_random_update' ); |
709 | 709 | $rows = $wgDatabase->affectedRows(); |
710 | 710 | |
711 | | - echo "changed $rows rows\n"; |
| 711 | + wfOut( "changed $rows rows\n" ); |
712 | 712 | } |
713 | 713 | |
714 | 714 | function do_templatelinks_update() { |
— | — | @@ -715,12 +715,12 @@ |
716 | 716 | $fname = 'do_templatelinks_update'; |
717 | 717 | |
718 | 718 | if ( $wgDatabase->tableExists( 'templatelinks' ) ) { |
719 | | - echo "...templatelinks table already exists\n"; |
| 719 | + wfOut( "...templatelinks table already exists\n" ); |
720 | 720 | return; |
721 | 721 | } |
722 | | - echo "Creating templatelinks table...\n"; |
| 722 | + wfOut( "Creating templatelinks table...\n" ); |
723 | 723 | dbsource( archive('patch-templatelinks.sql'), $wgDatabase ); |
724 | | - echo "Populating...\n"; |
| 724 | + wfOut( "Populating...\n" ); |
725 | 725 | if ( isset( $wgLoadBalancer ) && $wgLoadBalancer->getServerCount() > 1 ) { |
726 | 726 | // Slow, replication-friendly update |
727 | 727 | $res = $wgDatabase->select( 'pagelinks', array( 'pl_from', 'pl_namespace', 'pl_title' ), |
— | — | @@ -757,7 +757,7 @@ |
758 | 758 | ), $fname |
759 | 759 | ); |
760 | 760 | } |
761 | | - echo "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n"; |
| 761 | + wfOut( "Done. Please run maintenance/refreshLinks.php for a more thorough templatelinks update.\n" ); |
762 | 762 | } |
763 | 763 | |
764 | 764 | function do_all_updates( $doShared = false ) { |
Index: branches/REL1_6/phase3/config/index.php |
— | — | @@ -47,7 +47,8 @@ |
48 | 48 | <html> |
49 | 49 | <head> |
50 | 50 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
51 | | - <title>MediaWiki <?php echo( $wgVersion ); ?> Installation</title> |
| 51 | + <meta name="robots" content="noindex,nofollow"/> |
| 52 | + <title>MediaWiki <?php echo htmlspecialchars( $wgVersion ); ?> Installation</title> |
52 | 53 | <style type="text/css"> |
53 | 54 | |
54 | 55 | @import "../skins/monobook/main.css"; |
— | — | @@ -134,7 +135,7 @@ |
135 | 136 | <div id="content"> |
136 | 137 | <div id="bodyContent"> |
137 | 138 | |
138 | | -<h1>MediaWiki <?php print $wgVersion ?> Installation</h1> |
| 139 | +<h1>MediaWiki <?php print htmlspecialchars( $wgVersion ) ?> Installation</h1> |
139 | 140 | |
140 | 141 | <?php |
141 | 142 | |
— | — | @@ -204,7 +205,7 @@ |
205 | 206 | |
206 | 207 | install_version_checks(); |
207 | 208 | |
208 | | -print "<li>PHP " . phpversion() . " installed</li>\n"; |
| 209 | +print "<li>PHP " . htmlspecialchars( phpversion() ) . " installed</li>\n"; |
209 | 210 | |
210 | 211 | if( ini_get( "register_globals" ) ) { |
211 | 212 | ?> |
— | — | @@ -260,7 +261,7 @@ |
261 | 262 | $conf->safeMode = false; |
262 | 263 | } |
263 | 264 | |
264 | | -$sapi = php_sapi_name(); |
| 265 | +$sapi = htmlspecialchars( php_sapi_name() ); |
265 | 266 | $conf->prettyURLs = true; |
266 | 267 | print "<li>PHP server API is $sapi; "; |
267 | 268 | switch( $sapi ) { |
— | — | @@ -395,6 +396,12 @@ |
396 | 397 | : $_SERVER["SERVER_ADMIN"]; |
397 | 398 | $conf->EmergencyContact = importPost( "EmergencyContact", $defaultEmail ); |
398 | 399 | $conf->DBtype = importPost( "DBtype", "mysql" ); |
| 400 | + if ( !in_array( $conf->DBtype, array( 'mysql', 'oracle' ) ) ) { |
| 401 | + $conf->DBtype = 'mysql'; |
| 402 | + } |
| 403 | +?> |
| 404 | + |
| 405 | +<?php |
399 | 406 | $conf->DBserver = importPost( "DBserver", "localhost" ); |
400 | 407 | $conf->DBname = importPost( "DBname", "wikidb" ); |
401 | 408 | $conf->DBuser = importPost( "DBuser", "wikiuser" ); |
— | — | @@ -490,7 +497,7 @@ |
491 | 498 | $errs["DBtype"] = "Unknown database type."; |
492 | 499 | continue; |
493 | 500 | } |
494 | | - print "<li>Database type: {$conf->DBtype}</li>\n"; |
| 501 | + print "<li>Database type: " . htmlspecialchars( $conf->DBtype ) . "</li>\n"; |
495 | 502 | $dbclass = 'Database'.ucfirst($conf->DBtype); |
496 | 503 | require_once("$dbclass.php"); |
497 | 504 | $wgDBtype = $conf->DBtype; |
— | — | @@ -531,7 +538,7 @@ |
532 | 539 | } |
533 | 540 | |
534 | 541 | # Attempt to connect |
535 | | - echo( "<li>Attempting to connect to database server as $db_user..." ); |
| 542 | + echo( "<li>Attempting to connect to database server as " . htmlspecialchars( $db_user ) . "..." ); |
536 | 543 | $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); |
537 | 544 | |
538 | 545 | # Check the connection and respond to errors |
— | — | @@ -566,7 +573,7 @@ |
567 | 574 | case 2003: |
568 | 575 | default: |
569 | 576 | # General connection problem |
570 | | - echo( "failed with error [$errno] $errtx.</li>\n" ); |
| 577 | + echo( htmlspecialchars( "failed with error [$errno] $errtx." ) . "</li>\n" ); |
571 | 578 | $errs["DBserver"] = "Connection failed"; |
572 | 579 | break; |
573 | 580 | } # switch |
— | — | @@ -578,7 +585,7 @@ |
579 | 586 | print "<li>Connecting to SQL server..."; |
580 | 587 | $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); |
581 | 588 | if (!$wgDatabase->isOpen()) { |
582 | | - print " error: " . $wgDatabase->lastError() . "</li>\n"; |
| 589 | + print " error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n"; |
583 | 590 | } else { |
584 | 591 | $wgDatabase->ignoreErrors(true); |
585 | 592 | $myver = get_db_version(); |
— | — | @@ -590,7 +597,7 @@ |
591 | 598 | continue; |
592 | 599 | } |
593 | 600 | |
594 | | - print "<li>Connected to $myver"; |
| 601 | + print "<li>Connected to " . htmlspecialchars( $myver ); |
595 | 602 | if( version_compare( $myver, "4.0.14" ) < 0 ) { |
596 | 603 | die( " -- mysql 4.0.14 or later required. Aborting." ); |
597 | 604 | } |
— | — | @@ -694,10 +701,10 @@ |
695 | 702 | if( $wgDatabase2->isOpen() ) { |
696 | 703 | # Nope, just close the test connection and continue |
697 | 704 | $wgDatabase2->close(); |
698 | | - echo( "<li>User $wgDBuser exists. Skipping grants.</li>" ); |
| 705 | + echo( "<li>User " . htmlspecialchars( $wgDBuser ) . " exists. Skipping grants.</li>\n" ); |
699 | 706 | } else { |
700 | 707 | # Yes, so run the grants |
701 | | - echo( "<li>Granting user permissions to $wgDBuser on $wgDBname..." ); |
| 708 | + echo( "<li>" . htmlspecialchars( "Granting user permissions to $wgDBuser on $wgDBname..." ) ); |
702 | 709 | dbsource( "../maintenance/users.sql", $wgDatabase ); |
703 | 710 | echo( "success.</li>" ); |
704 | 711 | } |
— | — | @@ -816,7 +823,9 @@ |
817 | 824 | $list = getLanguageList(); |
818 | 825 | foreach( $list as $code => $name ) { |
819 | 826 | $sel = ($code == $conf->LanguageCode) ? 'selected="selected"' : ''; |
820 | | - echo "\t\t<option value=\"$code\" $sel>$name</option>\n"; |
| 827 | + $encCode = htmlspecialchars( $code ); |
| 828 | + $encName = htmlspecialchars( $name ); |
| 829 | + echo "\n\t\t<option value=\"$encCode\" $sel>$encName</option>"; |
821 | 830 | } |
822 | 831 | ?> |
823 | 832 | </select> |
— | — | @@ -1328,10 +1337,8 @@ |
1329 | 1338 | return importVar( $_REQUEST, $name, $default ); |
1330 | 1339 | } |
1331 | 1340 | |
1332 | | -$radioCount = 0; |
1333 | | - |
1334 | 1341 | function aField( &$conf, $field, $text, $type = "text", $value = "" ) { |
1335 | | - global $radioCount; |
| 1342 | + static $radioCount = 0; |
1336 | 1343 | if( $type != "" ) { |
1337 | 1344 | $xtype = "type=\"$type\""; |
1338 | 1345 | } else { |
— | — | @@ -1367,7 +1374,9 @@ |
1368 | 1375 | } |
1369 | 1376 | |
1370 | 1377 | global $errs; |
1371 | | - if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n"; |
| 1378 | + if(isset($errs[$field])) { |
| 1379 | + echo "<span class='error'>" . htmlspecialchars( $errs[$field] ) . "</span>\n"; |
| 1380 | + } |
1372 | 1381 | } |
1373 | 1382 | |
1374 | 1383 | function getLanguageList() { |
— | — | @@ -1469,7 +1478,7 @@ |
1470 | 1479 | fclose( $fp ); |
1471 | 1480 | } |
1472 | 1481 | if ( !$errstr ) { |
1473 | | - echo "<li>Connected to memcached on $host:$port successfully"; |
| 1482 | + echo "<li>Connected to memcached on " . htmlspecialchars( "$host:$port" ) ." successfully</li>"; |
1474 | 1483 | } |
1475 | 1484 | return $errstr; |
1476 | 1485 | } |
Index: branches/REL1_6/phase3/includes/GlobalFunctions.php |
— | — | @@ -1772,4 +1772,18 @@ |
1773 | 1773 | } |
1774 | 1774 | } |
1775 | 1775 | |
| 1776 | +/** |
| 1777 | + * Output some plain text in command-line mode or in the installer (updaters.inc). |
| 1778 | + * Do not use it in any other context, its behaviour is subject to change. |
| 1779 | + */ |
| 1780 | +function wfOut( $s ) { |
| 1781 | + static $lineStarted = false; |
| 1782 | + global $wgCommandLineMode; |
| 1783 | + if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) { |
| 1784 | + echo $s; |
| 1785 | + } else { |
| 1786 | + echo htmlspecialchars( $s ); |
| 1787 | + } |
| 1788 | + flush(); |
| 1789 | +} |
1776 | 1790 | ?> |