X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcache%2FLinkCache.php;h=0e41e265b1284b85a5b089ac8034f90ee2cb7474;hb=e05c4e9df06d68fcd43ce8eb888a0bea71b9dadf;hp=f759c0206d33701dcfbd9f6d12b02e1229cbaa8c;hpb=90108d8c93735d7d5964f907b999c3a326e87461;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php index f759c0206d..0e41e265b1 100644 --- a/includes/cache/LinkCache.php +++ b/includes/cache/LinkCache.php @@ -74,11 +74,11 @@ 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 $field String: ('length','redirect','revision') + * @param string $field ('length','redirect','revision','model') * @return mixed */ public function getGoodLinkFieldObj( $title, $field ) { - $dbkey = $title->getPrefixedDbKey(); + $dbkey = $title->getPrefixedDBkey(); if ( array_key_exists( $dbkey, $this->mGoodLinkFields ) ) { return $this->mGoodLinkFields[$dbkey][$field]; } else { @@ -102,14 +102,16 @@ class LinkCache { * @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 */ - public function addGoodLinkObj( $id, $title, $len = -1, $redir = null, $revision = false ) { - $dbkey = $title->getPrefixedDbKey(); + public function addGoodLinkObj( $id, $title, $len = -1, $redir = null, $revision = false, $model = false ) { + $dbkey = $title->getPrefixedDBkey(); $this->mGoodLinks[$dbkey] = intval( $id ); $this->mGoodLinkFields[$dbkey] = array( 'length' => intval( $len ), 'redirect' => intval( $redir ), - 'revision' => intval( $revision ) ); + 'revision' => intval( $revision ), + 'model' => intval( $model ) ); } /** @@ -117,15 +119,16 @@ class LinkCache { * @since 1.19 * @param $title Title * @param $row object which has the fields page_id, page_is_redirect, - * page_latest + * page_latest and page_content_model */ public function addGoodLinkObjFromRow( $title, $row ) { - $dbkey = $title->getPrefixedDbKey(); + $dbkey = $title->getPrefixedDBkey(); $this->mGoodLinks[$dbkey] = intval( $row->page_id ); $this->mGoodLinkFields[$dbkey] = array( 'length' => intval( $row->page_len ), 'redirect' => intval( $row->page_is_redirect ), 'revision' => intval( $row->page_latest ), + 'model' => !empty( $row->page_content_model ) ? strval( $row->page_content_model ) : null, ); } @@ -133,7 +136,7 @@ class LinkCache { * @param $title Title */ public function addBadLinkObj( $title ) { - $dbkey = $title->getPrefixedDbKey(); + $dbkey = $title->getPrefixedDBkey(); if ( !$this->isBadLink( $dbkey ) ) { $this->mBadLinks[$dbkey] = 1; } @@ -147,7 +150,7 @@ class LinkCache { * @param $title Title */ public function clearLink( $title ) { - $dbkey = $title->getPrefixedDbKey(); + $dbkey = $title->getPrefixedDBkey(); unset( $this->mBadLinks[$dbkey] ); unset( $this->mGoodLinks[$dbkey] ); unset( $this->mGoodLinkFields[$dbkey] ); @@ -159,7 +162,7 @@ class LinkCache { /** * Add a title to the link cache, return the page_id or zero if non-existent * - * @param $title String: title to add + * @param string $title title to add * @return Integer */ public function addLink( $title ) { @@ -178,7 +181,8 @@ class LinkCache { * @return Integer */ public function addLinkObj( $nt ) { - global $wgAntiLockFlags; + global $wgAntiLockFlags, $wgContentHandlerUseDB; + wfProfileIn( __METHOD__ ); $key = $nt->getPrefixedDBkey(); @@ -210,8 +214,10 @@ class LinkCache { $options = array(); } - $s = $db->selectRow( 'page', - array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ), + $f = array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ); + if ( $wgContentHandlerUseDB ) $f[] = 'page_content_model'; + + $s = $db->selectRow( 'page', $f, array( 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ), __METHOD__, $options ); # Set fields...