Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -304,7 +304,11 @@ |
305 | 305 | */ |
306 | 306 | public static function addTitleInfo( &$arr, $title, $prefix = '' ) { |
307 | 307 | $arr[$prefix . 'ns'] = intval( $title->getNamespace() ); |
308 | | - $arr[$prefix . 'pageid'] = $title->getArticleID(); |
| 308 | + // TODO: This is a workaround for bug 28901, as the Article ID isn't always loaded |
| 309 | + // Saves many DB queries, but does need cleaning up, so callers have always loaded the Article ID also |
| 310 | + if ( $title->isArticleIDLoaded() ) { |
| 311 | + $arr[$prefix . 'pageid'] = $title->getArticleID(); |
| 312 | + } |
309 | 313 | $arr[$prefix . 'title'] = $title->getPrefixedText(); |
310 | 314 | } |
311 | 315 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -2808,6 +2808,15 @@ |
2809 | 2809 | } |
2810 | 2810 | |
2811 | 2811 | /** |
| 2812 | + * Returns a bool to say whether the Article ID for this title has already been loaded |
| 2813 | + * |
| 2814 | + * @return bool |
| 2815 | + */ |
| 2816 | + public function isArticleIDLoaded() { |
| 2817 | + return $this->mArticleID != -1; |
| 2818 | + } |
| 2819 | + |
| 2820 | + /** |
2812 | 2821 | * Get the article ID for this Title from the link cache, |
2813 | 2822 | * adding it if necessary |
2814 | 2823 | * |
— | — | @@ -2825,10 +2834,8 @@ |
2826 | 2835 | $linkCache->clearLink( $this ); |
2827 | 2836 | $this->mArticleID = $linkCache->addLinkObj( $this ); |
2828 | 2837 | $linkCache->forUpdate( $oldUpdate ); |
2829 | | - } else { |
2830 | | - if ( -1 == $this->mArticleID ) { |
2831 | | - $this->mArticleID = $linkCache->addLinkObj( $this ); |
2832 | | - } |
| 2838 | + } else if ( -1 == $this->mArticleID ) { |
| 2839 | + $this->mArticleID = $linkCache->addLinkObj( $this ); |
2833 | 2840 | } |
2834 | 2841 | return $this->mArticleID; |
2835 | 2842 | } |