r104241 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104240‎ | r104241 | r104242 >
Date:15:39, 25 November 2011
Author:jeroendedauw
Status:reverted
Tags:
Comment:
fixed fail on non-existing pages
Modified paths:
  • /trunk/extensions/Reviews/Reviews.hooks.php (modified) (history)
  • /trunk/extensions/Reviews/includes/ReviewControl.php (modified) (history)
  • /trunk/extensions/Reviews/includes/ReviewRating.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/includes/ReviewControl.php
@@ -19,8 +19,8 @@
2020 'class' => 'review-control',
2121 );
2222
23 - $pageId = is_null( $this->review ) ? $context->getTitle()->getArticleID() : $this->review->getField( 'page_id' );
24 - $types = ReviewRating::getTypesForPageID( $pageId );
 23+ $title = is_null( $this->review ) ? $context->getTitle() : Title::newFromID( $this->review->getField( 'page_id' ) );
 24+ $types = is_null( $title ) ? array() : ReviewRating::getTypesForTitleText( $title->getFullText() );
2525
2626 if ( is_null( $this->review ) ) {
2727 $ratings = array();
@@ -30,7 +30,7 @@
3131 }
3232
3333 $review = array(
34 - 'page_id' => $pageId,
 34+ 'page_id' => $title->getArticleID(),
3535 'title' => '',
3636 'text' => '',
3737 'rating' => 0,
Index: trunk/extensions/Reviews/includes/ReviewRating.php
@@ -69,11 +69,11 @@
7070 *
7171 * @since 0.1
7272 *
73 - * @param integer $pageId
 73+ * @param string $titleText
7474 *
7575 * @return array
7676 */
77 - public static function getTypesForPageID( $pageId ) {
 77+ public static function getTypesForTitleText( $titleText ) {
7878 $ratingsPerCat = ReviewsSettings::get( 'categoryRatings' );
7979 $ratings = array();
8080
@@ -81,7 +81,7 @@
8282 'action' => 'query',
8383 'format' => 'json',
8484 'prop' => 'categories',
85 - 'titles' => Title::newFromID( $pageId )->getFullText(),
 85+ 'titles' => $titleText,
8686 ), true ), true );
8787
8888 $api->execute();
@@ -92,11 +92,13 @@
9393 }
9494
9595 foreach ( $result['query']['pages'] as $page ) {
96 - foreach ( $page['categories'] as $cat ) {
97 - $cat = explode( ':', $cat['title'], 2 );
98 - $cat = $cat[1];
99 - if ( array_key_exists( $cat, $ratingsPerCat ) ) {
100 - $ratings = array_merge( $ratings, $ratingsPerCat[$cat] );
 96+ if ( array_key_exists( 'categories', $page ) ) {
 97+ foreach ( $page['categories'] as $cat ) {
 98+ $cat = explode( ':', $cat['title'], 2 );
 99+ $cat = $cat[1];
 100+ if ( array_key_exists( $cat, $ratingsPerCat ) ) {
 101+ $ratings = array_merge( $ratings, $ratingsPerCat[$cat] );
 102+ }
101103 }
102104 }
103105 }
Index: trunk/extensions/Reviews/Reviews.hooks.php
@@ -135,7 +135,7 @@
136136 /* User */ $user = $skin->getUser();
137137
138138 if ( $user->isLoggedIn() && $user->isAllowed( 'postreview' ) && $user->getOption( 'reviews_showcontrol' )
139 - && $out->isArticle()
 139+ && $out->isArticle() && $skin->getTitle()->exists()
140140 && $skin->getRequest()->getText( 'action' ) !== 'edit' ) {
141141
142142 $review = Review::selectRow( null, array(

Status & tagging log