r100427 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100426‎ | r100427 | r100428 >
Date:16:22, 21 October 2011
Author:jeroendedauw
Status:ok
Tags:
Comment:
Follow up to r100402;
Modified paths:
  • /trunk/extensions/Contest/includes/ContestDBObject.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestant.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/specials/SpecialContestant.php
@@ -50,10 +50,12 @@
5151 }
5252
5353 if ( $this->getRequest()->wasPosted() ) {
54 - $contestant->setReadDb( DB_MASTER );
 54+ ContestContestant::s()->setReadDb( DB_MASTER );
5555 }
5656
5757 $contestant->loadFields();
 58+ ContestContestant::s()->setReadDb( DB_SLAVE );
 59+
5860 $this->showPage( $contestant );
5961 }
6062 }
@@ -295,7 +297,14 @@
296298
297299 $out->addHTML( '<div class="contestant-comments">' );
298300
299 - foreach ( $contestant->getComments() as /* ContestComment */ $comment ) {
 301+ if ( $this->getRequest()->wasPosted() ) {
 302+ ContestComment::s()->setReadDb( DB_MASTER );
 303+ }
 304+
 305+ $comments = $contestant->getComments();
 306+ ContestComment::s()->setReadDb( DB_SLAVE );
 307+
 308+ foreach ( $comments as /* ContestComment */ $comment ) {
300309 $out->addHTML( $this->getCommentHTML( $comment ) );
301310 }
302311
Index: trunk/extensions/Contest/includes/ContestDBObject.php
@@ -30,8 +30,8 @@
3131 * @since 0.2
3232 * @var integer DB_ enum
3333 */
34 - protected $readDb = DB_SLAVE;
35 -
 34+ protected static $readDb = DB_SLAVE;
 35+
3636 /**
3737 * Constructor.
3838 *
@@ -283,27 +283,6 @@
284284 }
285285
286286 /**
287 - * Get the database type used for read operations.
288 - *
289 - * @since 0.2
290 - * @return integer DB_ enum
291 - */
292 - public function getReadDb() {
293 - return $this->readDb;
294 - }
295 -
296 - /**
297 - * Set the database type to use for read operations.
298 - *
299 - * @param integer $db
300 - *
301 - * @since 0.2
302 - */
303 - public function setReadDb( $db ) {
304 - $this->readDb = $db;
305 - }
306 -
307 - /**
308287 * Updates the object in the database.
309288 *
310289 * @since 0.1
@@ -481,6 +460,27 @@
482461 //
483462
484463 /**
 464+ * Get the database type used for read operations.
 465+ *
 466+ * @since 0.2
 467+ * @return integer DB_ enum
 468+ */
 469+ public function getReadDb() {
 470+ return self::$readDb;
 471+ }
 472+
 473+ /**
 474+ * Set the database type to use for read operations.
 475+ *
 476+ * @param integer $db
 477+ *
 478+ * @since 0.2
 479+ */
 480+ public function setReadDb( $db ) {
 481+ self::$readDb = $db;
 482+ }
 483+
 484+ /**
485485 * Gets if the object can take a certain field.
486486 *
487487 * @since 0.1

Follow-up revisions

RevisionCommit summaryAuthorDate
r1004401.18wmf1 REL r100402, r100405, r100419, r100427, r100432, r100433, r100435, r...reedy19:22, 21 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100402use master db after submission so results do not get omitted due to rep lagjeroendedauw01:53, 21 October 2011

Status & tagging log