mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
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:
parent
93387806c2
commit
b2961ccb0c
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue