summaryrefslogtreecommitdiff
path: root/includes/cache/LinkCache.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/cache/LinkCache.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/cache/LinkCache.php')
-rw-r--r--includes/cache/LinkCache.php75
1 files changed, 33 insertions, 42 deletions
diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php
index 54de1989..6925df90 100644
--- a/includes/cache/LinkCache.php
+++ b/includes/cache/LinkCache.php
@@ -35,7 +35,6 @@ class LinkCache {
private $mGoodLinkFields = array();
private $mBadLinks = array();
private $mForUpdate = false;
- private $useDatabase = true;
/**
* @var LinkCache
@@ -52,6 +51,7 @@ class LinkCache {
return self::$instance;
}
self::$instance = new LinkCache;
+
return self::$instance;
}
@@ -78,6 +78,7 @@ class LinkCache {
/**
* General accessor to get/set whether SELECT FOR UPDATE should be used
*
+ * @param bool $update
* @return bool
*/
public function forUpdate( $update = null ) {
@@ -85,8 +86,8 @@ class LinkCache {
}
/**
- * @param $title
- * @return array|int
+ * @param string $title
+ * @return int
*/
public function getGoodLinkID( $title ) {
if ( array_key_exists( $title, $this->mGoodLinks ) ) {
@@ -99,9 +100,9 @@ class LinkCache {
/**
* Get a field of a title object from cache.
* If this link is not good, it will return NULL.
- * @param $title Title
+ * @param Title $title
* @param string $field ('length','redirect','revision','model')
- * @return mixed
+ * @return string|null
*/
public function getGoodLinkFieldObj( $title, $field ) {
$dbkey = $title->getPrefixedDBkey();
@@ -113,7 +114,7 @@ class LinkCache {
}
/**
- * @param $title
+ * @param string $title
* @return bool
*/
public function isBadLink( $title ) {
@@ -123,28 +124,31 @@ class LinkCache {
/**
* Add a link for the title to the link cache
*
- * @param $id Integer: page's ID
- * @param $title Title object
- * @param $len Integer: text's length
- * @param $redir Integer: whether the page is a redirect
- * @param $revision Integer: latest revision's ID
- * @param $model Integer: latest revision's content model ID
+ * @param int $id Page's ID
+ * @param Title $title
+ * @param int $len Text's length
+ * @param int $redir Whether the page is a redirect
+ * @param int $revision Latest revision's ID
+ * @param string|null $model Latest revision's content model ID
*/
- public function addGoodLinkObj( $id, $title, $len = -1, $redir = null, $revision = false, $model = false ) {
+ public function addGoodLinkObj( $id, $title, $len = -1, $redir = null,
+ $revision = 0, $model = null
+ ) {
$dbkey = $title->getPrefixedDBkey();
- $this->mGoodLinks[$dbkey] = intval( $id );
+ $this->mGoodLinks[$dbkey] = (int)$id;
$this->mGoodLinkFields[$dbkey] = array(
- 'length' => intval( $len ),
- 'redirect' => intval( $redir ),
- 'revision' => intval( $revision ),
- 'model' => intval( $model ) );
+ 'length' => (int)$len,
+ 'redirect' => (int)$redir,
+ 'revision' => (int)$revision,
+ 'model' => $model ? (string)$model : null,
+ );
}
/**
* Same as above with better interface.
* @since 1.19
- * @param $title Title
- * @param $row object which has the fields page_id, page_is_redirect,
+ * @param Title $title
+ * @param stdClass $row Object which has the fields page_id, page_is_redirect,
* page_latest and page_content_model
*/
public function addGoodLinkObjFromRow( $title, $row ) {
@@ -159,7 +163,7 @@ class LinkCache {
}
/**
- * @param $title Title
+ * @param Title $title
*/
public function addBadLinkObj( $title ) {
$dbkey = $title->getPrefixedDBkey();
@@ -173,7 +177,7 @@ class LinkCache {
}
/**
- * @param $title Title
+ * @param Title $title
*/
public function clearLink( $title ) {
$dbkey = $title->getPrefixedDBkey();
@@ -193,8 +197,8 @@ class LinkCache {
/**
* Add a title to the link cache, return the page_id or zero if non-existent
*
- * @param string $title title to add
- * @return Integer
+ * @param string $title Title to add
+ * @return int
*/
public function addLink( $title ) {
$nt = Title::newFromDBkey( $title );
@@ -206,23 +210,10 @@ class LinkCache {
}
/**
- * Enable or disable database use.
- * @since 1.22
- * @param $value Boolean
- * @return Boolean
- */
- public function useDatabase( $value = null ) {
- if ( $value !== null ) {
- $this->useDatabase = (bool)$value;
- }
- return $this->useDatabase;
- }
-
- /**
* Add a title to the link cache, return the page_id or zero if non-existent
*
- * @param $nt Title object to add
- * @return Integer
+ * @param Title $nt Title object to add
+ * @return int
*/
public function addLinkObj( $nt ) {
global $wgAntiLockFlags, $wgContentHandlerUseDB;
@@ -232,20 +223,19 @@ class LinkCache {
$key = $nt->getPrefixedDBkey();
if ( $this->isBadLink( $key ) || $nt->isExternal() ) {
wfProfileOut( __METHOD__ );
+
return 0;
}
$id = $this->getGoodLinkID( $key );
if ( $id != 0 ) {
wfProfileOut( __METHOD__ );
+
return $id;
}
if ( $key === '' ) {
wfProfileOut( __METHOD__ );
- return 0;
- }
- if( !$this->useDatabase ) {
return 0;
}
@@ -280,6 +270,7 @@ class LinkCache {
}
wfProfileOut( __METHOD__ );
+
return $id;
}