Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/275721

Change subject: EchoTargetPage: Don't call Title::newFromId() repeatedly
......................................................................

EchoTargetPage: Don't call Title::newFromId() repeatedly

Title::newFromId() can return null, and if this were the case the
instance caching would never work, so it would continually make useless
database queries.

Initialize the $title member variable as false to begin with, and use
that to check whether we've already checked Title::newFromId().

Change-Id: Id07c2c963ffcd03e212bed0a666735bcb68b92e0
---
M includes/model/TargetPage.php
1 file changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/21/275721/1

diff --git a/includes/model/TargetPage.php b/includes/model/TargetPage.php
index d62437a..c678947 100644
--- a/includes/model/TargetPage.php
+++ b/includes/model/TargetPage.php
@@ -13,9 +13,9 @@
        protected $user;
 
        /**
-        * @var Title|null
+        * @var Title|null|bool false if not initialized yet
         */
-       protected $title;
+       protected $title = false;
 
        /**
         * @var int
@@ -107,7 +107,7 @@
         * @return Title|null
         */
        public function getTitle() {
-               if ( !$this->title ) {
+               if ( $this->title === false ) {
                        $this->title = Title::newFromId( $this->pageId );
                }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/275721
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id07c2c963ffcd03e212bed0a666735bcb68b92e0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to