jenkins-bot has submitted this change and it was merged.

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(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



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: merged
Gerrit-Change-Id: Id07c2c963ffcd03e212bed0a666735bcb68b92e0
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to