(bug 14414) maintenance/updateSpecialPages.php no longer throws error with PostgreSQL:
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 21 Feb 2009 17:30:59 +0000 (17:30 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 21 Feb 2009 17:30:59 +0000 (17:30 +0000)
* 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
includes/QueryPage.php
includes/specials/SpecialUnusedimages.php

index 7684a19..1c63281 100644 (file)
@@ -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
index 0b58750..1cef31e 100644 (file)
@@ -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;
                                }
index 4adf405..fa66555 100644 (file)
@@ -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' ) );
        }
 
 }