API: fixed Bug 9969: SQL error when an improper title is given to API
authorYuri Astrakhan <yurik@users.mediawiki.org>
Sat, 19 May 2007 22:56:42 +0000 (22:56 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Sat, 19 May 2007 22:56:42 +0000 (22:56 +0000)
a bit better debugging facilities

includes/api/ApiBase.php
includes/api/ApiQueryLinks.php

index b2e5345..34eeb8a 100644 (file)
@@ -578,9 +578,11 @@ abstract class ApiBase {
                return $this->mDBTime;
        }
        
-       public static function debugPrint($value, $name = 'unknown') {
-               print "\n\n<pre><b>Debuging value '$location':</b>\n\n";
+       public static function debugPrint($value, $name = 'unknown', $backtrace = false) {
+               print "\n\n<pre><b>Debuging value '$name':</b>\n\n";
                var_export($value);
+               if ($backtrace)
+                       print "\n" . wfBacktrace();
                print "\n</pre>\n";
        }
 
index ff216de..9119a0f 100644 (file)
@@ -68,6 +68,9 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
 
        private function run($resultPageSet = null) {
 
+               if ($this->getPageSet()->getGoodTitleCount() == 0)
+                       return; // nothing to do
+
                $this->addFields(array (
                        $this->prefix . '_from pl_from',
                        $this->prefix . '_namespace pl_namespace',
@@ -93,9 +96,11 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                                        }
                                        $lastId = $row->pl_from;
                                }
-                               $vals = $this->addRowInfo('pl', $row);
-                               if ($vals)
-                                       $data[] = $vals;
+
+                               $title = Title :: makeTitle($row->pl_namespace, $row->pl_title);
+                               $vals = array();
+                               ApiQueryBase :: addTitleInfo($vals, $title);
+                               $data[] = $vals;
                        }
 
                        if($lastId != 0) {
@@ -106,7 +111,9 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
 
                        $titles = array();
                        while ($row = $db->fetchObject($res)) {
-                               $titles[] = Title :: makeTitle($row->pl_namespace, $row->pl_title);
+                               $title = Title :: makeTitle($row->pl_namespace, $row->pl_title);
+                               if($title->userCanRead())
+                                       $titles[] = $title;
                        }
                        $resultPageSet->populateFromTitles($titles);
                }