From ff52013a33617c76e8ea9f87233c6d620e53f5ed Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 19 May 2007 22:56:42 +0000 Subject: [PATCH] API: fixed Bug 9969: SQL error when an improper title is given to API a bit better debugging facilities --- includes/api/ApiBase.php | 6 ++++-- includes/api/ApiQueryLinks.php | 15 +++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index b2e5345450..34eeb8ab63 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -578,9 +578,11 @@ abstract class ApiBase { return $this->mDBTime; } - public static function debugPrint($value, $name = 'unknown') { - print "\n\n
Debuging value '$location':\n\n";
+	public static function debugPrint($value, $name = 'unknown', $backtrace = false) {
+		print "\n\n
Debuging value '$name':\n\n";
 		var_export($value);
+		if ($backtrace)
+			print "\n" . wfBacktrace();
 		print "\n
\n"; } diff --git a/includes/api/ApiQueryLinks.php b/includes/api/ApiQueryLinks.php index ff216de0e4..9119a0f0e9 100644 --- a/includes/api/ApiQueryLinks.php +++ b/includes/api/ApiQueryLinks.php @@ -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); } -- 2.20.1