r99627 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99626‎ | r99627 | r99628 >
Date:09:49, 12 October 2011
Author:questpc
Status:deferred
Tags:
Comment:
Fixed qp_PollStore::getInterpTitle() logic to work correctly in Special:Pollresults
Modified paths:
  • /trunk/extensions/QPoll/model/qp_pollstore.php (modified) (history)
  • /trunk/extensions/QPoll/specials/qp_results.php (modified) (history)

Diff [purge]

Index: trunk/extensions/QPoll/model/qp_pollstore.php
@@ -254,9 +254,9 @@
255255 }
256256
257257 /**
258 - * @return mixed Title instance of interpretation template
 258+ * @return mixed Title instance of interpretation template (existing or not)
259259 * false, when no interpretation template is defined in poll header
260 - * null, when interpretation template does not exist (error)
 260+ * null, when the title parts are invalid (error)
261261 */
262262 function getInterpTitle() {
263263 if ( is_null( $this->interpDBkey ) ) {
@@ -266,7 +266,7 @@
267267 return false;
268268 }
269269 $title = Title::newFromText( $this->interpDBkey, $this->interpNS );
270 - return ( $title instanceof Title ) ? ( $title->exists() ? $title : null ) : null;
 270+ return ( $title instanceof Title ) ? $title : null;
271271 }
272272
273273 // warning: will work only after successful loadUserAlreadyVoted() or loadUserVote()
@@ -889,9 +889,10 @@
890890 $this->interpResult = new qp_InterpResult();
891891 $interpTitle = $this->getInterpTitle();
892892 if ( $interpTitle === false ) {
 893+ # this poll has no interpretation script
893894 return;
894895 }
895 - if ( $interpTitle === null ) {
 896+ if ( !( $interpTitle instanceof Title ) || !$interpTitle->exists() ) {
896897 $this->interpResult->storeErroneous = false;
897898 $this->interpResult->setError( wfMsg( 'qp_error_no_interpretation' ) );
898899 return;
Index: trunk/extensions/QPoll/specials/qp_results.php
@@ -182,7 +182,7 @@
183183 array( '__tag' => 'div', 'style' => 'font-weight:bold;', wfMsg( 'qp_results_submit_attempts', intval( $pollStore->attempts ) ) )
184184 );
185185 $interpTitle = $pollStore->getInterpTitle();
186 - if ( $interpTitle === null ) {
 186+ if ( !( $interpTitle instanceof Title ) ) {
187187 $tags[] = wfMsg( 'qp_poll_has_no_interpretation' );
188188 return $tags;
189189 }

Status & tagging log