From 888f5b3592e91726b8bc444b724c8e8824db7962 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 21 Feb 2009 17:30:59 +0000 Subject: [PATCH] (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 --- RELEASE-NOTES | 3 +++ includes/QueryPage.php | 10 +++++----- includes/specials/SpecialUnusedimages.php | 12 ++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7684a190d4..1c632818a5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -117,6 +117,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN other users. * Add an ID if 'missingsummary' is triggered to allow styling of the summary line + === Bug fixes in 1.15 === * (bug 16968) Special:Upload no longer throws useless warnings. * (bug 17000) Special:RevisionDelete now checks if the database is locked @@ -213,6 +214,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 1061) CSS-added icons next to links display through the text and makes it unreadable in RTL * Special:Wantedtemplates now works on PostgreSQL +* (bug 14414) maintenance/updateSpecialPages.php no longer throws error with + PostgreSQL == API changes in 1.15 == * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 0b58750803..1cef31ea56 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -204,7 +204,7 @@ class QueryPage { * Clear the cache and save new results */ function recache( $limit, $ignoreErrors = true ) { - $fname = get_class($this) . '::recache'; + $fname = get_class( $this ) . '::recache'; $dbw = wfGetDB( DB_MASTER ); $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); if ( !$dbw || !$dbr ) { @@ -222,9 +222,9 @@ class QueryPage { $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname ); # Do query $sql = $this->getSQL() . $this->getOrder(); - if ($limit !== false) - $sql = $dbr->limitResult($sql, $limit, 0); - $res = $dbr->query($sql, $fname); + if ( $limit !== false ) + $sql = $dbr->limitResult( $sql, $limit, 0 ); + $res = $dbr->query( $sql, $fname ); $num = false; if ( $res ) { $num = $dbr->numRows( $res ); @@ -238,7 +238,7 @@ class QueryPage { $insertSql .= ','; } if ( isset( $row->value ) ) { - $value = $row->value; + $value = intval( $row->value ); // @bug 14414 } else { $value = 0; } diff --git a/includes/specials/SpecialUnusedimages.php b/includes/specials/SpecialUnusedimages.php index 4adf405d3e..fa66555d47 100644 --- a/includes/specials/SpecialUnusedimages.php +++ b/includes/specials/SpecialUnusedimages.php @@ -22,13 +22,17 @@ class UnusedimagesPage extends ImageQueryPage { function isSyndicated() { return false; } function getSQL() { - global $wgCountCategorizedImagesAsUsed; + global $wgCountCategorizedImagesAsUsed, $wgDBtype; $dbr = wfGetDB( DB_SLAVE ); + $epoch = $wgDBtype == 'mysql' ? + 'UNIX_TIMESTAMP(img_timestamp)' : + 'EXTRACT(epoch FROM img_timestamp)'; + if ( $wgCountCategorizedImagesAsUsed ) { list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' ); - return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, img_timestamp as value, + return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value, img_user, img_user_text, img_description FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from) LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to) @@ -37,14 +41,14 @@ class UnusedimagesPage extends ImageQueryPage { } else { list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' ); - return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, img_timestamp as value, + return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value, img_user, img_user_text, img_description FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL "; } } function getPageHeader() { - return wfMsgExt( 'unusedimagestext', array( 'parse') ); + return wfMsgExt( 'unusedimagestext', array( 'parse' ) ); } } -- 2.20.1