dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Improve docs for Title::getInternalURL/getCanonicalURL"
[lhc/web/wiklou.git]
/
includes
/
block
/
Restriction
/
PageRestriction.php
diff --git
a/includes/block/Restriction/PageRestriction.php
b/includes/block/Restriction/PageRestriction.php
index
bf7ef04
..
ea73d19
100644
(file)
--- a/
includes/block/Restriction/PageRestriction.php
+++ b/
includes/block/Restriction/PageRestriction.php
@@
-25,24
+25,28
@@
namespace MediaWiki\Block\Restriction;
class PageRestriction extends AbstractRestriction {
/**
class PageRestriction extends AbstractRestriction {
/**
- *
{@inheritdoc}
+ *
@inheritDoc
*/
const TYPE = 'page';
/**
*/
const TYPE = 'page';
/**
- *
{@inheritdoc}
+ *
@inheritDoc
*/
const TYPE_ID = 1;
/**
*/
const TYPE_ID = 1;
/**
- * @var \Title
+ * @var \Title
|bool
*/
protected $title;
/**
*/
protected $title;
/**
- *
{@inheritdoc}
+ *
@inheritDoc
*/
public function matches( \Title $title ) {
*/
public function matches( \Title $title ) {
+ if ( !$this->getTitle() ) {
+ return false;
+ }
+
return $title->equals( $this->getTitle() );
}
return $title->equals( $this->getTitle() );
}
@@
-66,15
+70,21
@@
class PageRestriction extends AbstractRestriction {
* @return \Title|null
*/
public function getTitle() {
* @return \Title|null
*/
public function getTitle() {
- if (
!$this->title
) {
+ if (
$this->title === null
) {
$this->title = \Title::newFromID( $this->value );
$this->title = \Title::newFromID( $this->value );
+
+ // If the title does not exist, set to false to prevent multiple database
+ // queries.
+ if ( $this->title === null ) {
+ $this->title = false;
+ }
}
}
- return $this->title;
+ return $this->title
?? null
;
}
/**
}
/**
- *
{@inheritdoc}
+ *
@inheritDoc
*/
public static function newFromRow( \stdClass $row ) {
$restriction = parent::newFromRow( $row );
*/
public static function newFromRow( \stdClass $row ) {
$restriction = parent::newFromRow( $row );