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
This commit is contained in:
Kunal Mehta 2016-03-07 15:56:00 -08:00 committed by Catrope
parent 93387806c2
commit b2961ccb0c

View file

@ -13,9 +13,9 @@ class EchoTargetPage extends EchoAbstractEntity {
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 @@ class EchoTargetPage extends EchoAbstractEntity {
* @return Title|null
*/
public function getTitle() {
if ( !$this->title ) {
if ( $this->title === false ) {
$this->title = Title::newFromId( $this->pageId );
}