Preparations for Oracle database abstraction update.
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Mon, 11 May 2009 12:38:45 +0000 (12:38 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Mon, 11 May 2009 12:38:45 +0000 (12:38 +0000)
Replaced a few hardcoded LIMIT clauses with database function.
Wrapped UNION statement in SpecialRecentchangeslinked for Oracle compatibility.

includes/Article.php
includes/specials/SpecialNewimages.php
includes/specials/SpecialRecentchangeslinked.php

index 6046cf5..6b67e83 100644 (file)
@@ -707,8 +707,8 @@ class Article {
                        GROUP BY rev_user, rev_user_text, user_real_name
                        ORDER BY timestamp DESC";
 
-               if($limit > 0) { $sql .= ' LIMIT '.$limit; }
-               if($offset > 0) { $sql .= ' OFFSET '.$offset; }
+               if($limit > 0)
+                       $sql = $dbr->limitResult($sql, $limit, $offset);
 
                $sql .= ' '. $this->getSelectOptions();
 
index 88e34f4..3922712 100644 (file)
@@ -40,7 +40,8 @@ function wfSpecialNewimages( $par, $specialPage ) {
        if ($hidebotsql) {
                $sql .= "$hidebotsql WHERE ug_group IS NULL";
        }
-       $sql .= ' ORDER BY img_timestamp DESC LIMIT 1';
+       $sql .= ' ORDER BY img_timestamp DESC';
+       $sql = $dbr->limitResult($sql, 1, false);
        $res = $dbr->query( $sql, __FUNCTION__ );
        $row = $dbr->fetchRow( $res );
        if( $row !== false ) {
@@ -93,7 +94,7 @@ function wfSpecialNewimages( $par, $specialPage ) {
                $sql .= ' WHERE ' . $dbr->makeList( $where, LIST_AND );
        }
        $sql.=' ORDER BY img_timestamp '. ( $invertSort ? '' : ' DESC' );
-       $sql.=' LIMIT ' . ( $limit + 1 );
+       $sql = $dbr->limitResult($sql, ( $limit + 1 ), false);
        $res = $dbr->query( $sql, __FUNCTION__ );
 
        /**
index 82aa5b9..e1b5ae4 100644 (file)
@@ -155,7 +155,9 @@ class SpecialRecentchangeslinked extends SpecialRecentchanges {
                        $sql = $subsql[0];
                else {
                        // need to resort and relimit after union
-                       $sql = "(" . implode( ") UNION (", $subsql ) . ") ORDER BY rc_timestamp DESC LIMIT {$limit}";
+                       // unwrapped UNION block will not work in Oracle. Wrapper aded.
+                       $sql = "SELECT * FROM ((" . implode( ") UNION (", $subsql ) . ")) ORDER BY rc_timestamp DESC";
+                       $sql = $dbr->limitResult($sql, $limit, false);
                }
 
                $res = $dbr->query( $sql, __METHOD__ );