r47622 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47621‎ | r47622 | r47623 >
Date:17:30, 21 February 2009
Author:ialex
Status:ok
Tags:
Comment:
(bug 14414) maintenance/updateSpecialPages.php no longer throws error with PostgreSQL:
* forced intval() for the "value" field in QueryPage::recache() since some pages select page_title for it, which is incompatible with "integer"
* changed Special:Unusedimages' query to return the UNIX timestamp rather than raw img_timestamp for the "value" field, the latter has the TS_POSTGRES format on PostgreSQL and is also incompatible with "integer", code taken from Special:Ancientpages
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/QueryPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUnusedimages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUnusedimages.php
@@ -22,13 +22,17 @@
2323 function isSyndicated() { return false; }
2424
2525 function getSQL() {
26 - global $wgCountCategorizedImagesAsUsed;
 26+ global $wgCountCategorizedImagesAsUsed, $wgDBtype;
2727 $dbr = wfGetDB( DB_SLAVE );
2828
 29+ $epoch = $wgDBtype == 'mysql' ?
 30+ 'UNIX_TIMESTAMP(img_timestamp)' :
 31+ 'EXTRACT(epoch FROM img_timestamp)';
 32+
2933 if ( $wgCountCategorizedImagesAsUsed ) {
3034 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
3135
32 - return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, img_timestamp as value,
 36+ return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
3337 img_user, img_user_text, img_description
3438 FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from)
3539 LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to)
@@ -37,14 +41,14 @@
3842 } else {
3943 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
4044
41 - return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, img_timestamp as value,
 45+ return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
4246 img_user, img_user_text, img_description
4347 FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL ";
4448 }
4549 }
4650
4751 function getPageHeader() {
48 - return wfMsgExt( 'unusedimagestext', array( 'parse') );
 52+ return wfMsgExt( 'unusedimagestext', array( 'parse' ) );
4953 }
5054
5155 }
Index: trunk/phase3/includes/QueryPage.php
@@ -204,7 +204,7 @@
205205 * Clear the cache and save new results
206206 */
207207 function recache( $limit, $ignoreErrors = true ) {
208 - $fname = get_class($this) . '::recache';
 208+ $fname = get_class( $this ) . '::recache';
209209 $dbw = wfGetDB( DB_MASTER );
210210 $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) );
211211 if ( !$dbw || !$dbr ) {
@@ -222,9 +222,9 @@
223223 $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
224224 # Do query
225225 $sql = $this->getSQL() . $this->getOrder();
226 - if ($limit !== false)
227 - $sql = $dbr->limitResult($sql, $limit, 0);
228 - $res = $dbr->query($sql, $fname);
 226+ if ( $limit !== false )
 227+ $sql = $dbr->limitResult( $sql, $limit, 0 );
 228+ $res = $dbr->query( $sql, $fname );
229229 $num = false;
230230 if ( $res ) {
231231 $num = $dbr->numRows( $res );
@@ -238,7 +238,7 @@
239239 $insertSql .= ',';
240240 }
241241 if ( isset( $row->value ) ) {
242 - $value = $row->value;
 242+ $value = intval( $row->value ); // @bug 14414
243243 } else {
244244 $value = 0;
245245 }
Index: trunk/phase3/RELEASE-NOTES
@@ -117,6 +117,7 @@
118118 other users.
119119 * Add an ID if 'missingsummary' is triggered to allow styling of the summary
120120 line
 121+
121122 === Bug fixes in 1.15 ===
122123 * (bug 16968) Special:Upload no longer throws useless warnings.
123124 * (bug 17000) Special:RevisionDelete now checks if the database is locked
@@ -213,6 +214,8 @@
214215 * (bug 1061) CSS-added icons next to links display through the text and makes
215216 it unreadable in RTL
216217 * Special:Wantedtemplates now works on PostgreSQL
 218+* (bug 14414) maintenance/updateSpecialPages.php no longer throws error with
 219+ PostgreSQL
217220
218221 == API changes in 1.15 ==
219222 * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions

Status & tagging log