$lc = LinkCache::singleton();
if ( $data ) {
- $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect );
+ $lc->addGoodLinkObj( $data->page_id, $this->mTitle, $data->page_len, $data->page_is_redirect, $data->page_latest );
$this->mTitle->mArticleID = intval( $data->page_id );
$remaining = $this->data;
while ( $row = $res->fetchObject() ) {
$title = Title::makeTitle( $row->page_namespace, $row->page_title );
- $cache->addGoodLinkObj( $row->page_id, $title, $row->page_len, $row->page_is_redirect );
+ $cache->addGoodLinkObj( $row->page_id, $title, $row->page_len, $row->page_is_redirect, $row->page_latest );
$ids[$title->getPrefixedDBkey()] = $row->page_id;
unset( $remaining[$row->page_namespace][$row->page_title] );
}
wfProfileOut( __METHOD__ );
return false;
}
- $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect FROM $page WHERE $set";
+ $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, page_latest FROM $page WHERE $set";
// Do query
$res = $dbr->query( $sql, __METHOD__ );
* @param $len Integer
* @param $redir Integer
*/
- public function addGoodLinkObj( $id, $title, $len = -1, $redir = null ) {
+ public function addGoodLinkObj( $id, $title, $len = -1, $redir = null, $revision = false ) {
$dbkey = $title->getPrefixedDbKey();
$this->mGoodLinks[$dbkey] = intval( $id );
$this->mGoodLinkFields[$dbkey] = array(
'length' => intval( $len ),
- 'redirect' => intval( $redir ) );
+ 'redirect' => intval( $redir ),
+ 'revision' => intval( $revision ) );
}
public function addBadLinkObj( $title ) {
}
$s = $db->selectRow( 'page',
- array( 'page_id', 'page_len', 'page_is_redirect' ),
+ array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ),
array( 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ),
__METHOD__, $options );
# Set fields...
$id = intval( $s->page_id );
$len = intval( $s->page_len );
$redirect = intval( $s->page_is_redirect );
+ $revision = intval( $s->page_latest );
} else {
$len = -1;
$redirect = 0;
+ $revision = 0;
}
if ( $id == 0 ) {
$this->addBadLinkObj( $nt );
} else {
- $this->addGoodLinkObj( $id, $nt, $len, $redirect );
+ $this->addGoodLinkObj( $id, $nt, $len, $redirect, $revision );
}
wfProfileOut( __METHOD__ );
return $id;
* What is the page_latest field for this page?
*
* @param $flags \type{\int} a bit field; may be GAID_FOR_UPDATE to select for update
- * @return \type{\int} or false if the page doesn't exist
+ * @return \type{\int} or 0 if the page doesn't exist
*/
public function getLatestRevID( $flags = 0 ) {
if ( $this->mLatestID !== false )
return $this->mLatestID;
+ # Calling getArticleID() loads the field from cache as needed
+ if ( !$this->getArticleID( $flags ) ) {
+ return $this->mLatestID = 0;
+ }
+ $linkCache = LinkCache::singleton();
+ $this->mLatestID = intval( $linkCache->getGoodLinkFieldObj( $this, 'revision' ) );
- $db = ( $flags & GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
- $this->mLatestID = (int)$db->selectField(
- 'page', 'page_latest', $this->pageCond(), __METHOD__ );
return $this->mLatestID;
}
}
$res = $db->select( array( 'page', $table ),
- array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect' ),
+ array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ),
array(
"{$prefix}_from=page_id",
"{$prefix}_namespace" => $this->getNamespace(),
if ( $db->numRows( $res ) ) {
foreach ( $res as $row ) {
if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) {
- $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect );
+ $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
$retVal[] = $titleObj;
}
}
$dbr = wfGetDB( DB_MASTER );
$uid = intval( $user->getId() );
list( $watchlist, $page ) = $dbr->tableNamesN( 'watchlist', 'page' );
- $sql = "SELECT wl_namespace, wl_title, page_id, page_len, page_is_redirect
+ $sql = "SELECT wl_namespace, wl_title, page_id, page_len, page_is_redirect, page_latest
FROM {$watchlist} LEFT JOIN {$page} ON ( wl_namespace = page_namespace
AND wl_title = page_title ) WHERE wl_user = {$uid}";
$res = $dbr->query( $sql, __METHOD__ );
if( $title instanceof Title ) {
// Update the link cache while we're at it
if( $row->page_id ) {
- $cache->addGoodLinkObj( $row->page_id, $title, $row->page_len, $row->page_is_redirect );
+ $cache->addGoodLinkObj( $row->page_id, $title, $row->page_len, $row->page_is_redirect, $row->page_latest );
} else {
$cache->addBadLinkObj( $title );
}
$encName = $db->addQuotes( $this->getName() );
$res = $db->select( array( 'page', 'imagelinks'),
- array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect' ),
+ array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ),
array( 'page_id' => 'il_from', 'il_to' => $encName ),
__METHOD__,
$options );
if ( $db->numRows( $res ) ) {
while ( $row = $db->fetchObject( $res ) ) {
if ( $titleObj = Title::newFromRow( $row ) ) {
- $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect );
+ $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
$retVal[] = $titleObj;
}
}
# Not in the link cache, add it to the query
if ( !isset( $current ) ) {
$current = $ns;
- $query = "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len";
+ $query = "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len, page_latest";
$query .= " FROM $page WHERE (page_namespace=$ns AND page_title IN(";
} elseif ( $current != $ns ) {
$current = $ns;
while ( $s = $dbr->fetchObject($res) ) {
$title = Title::makeTitle( $s->page_namespace, $s->page_title );
$pdbk = $title->getPrefixedDBkey();
- $linkCache->addGoodLinkObj( $s->page_id, $title, $s->page_len, $s->page_is_redirect );
+ $linkCache->addGoodLinkObj( $s->page_id, $title, $s->page_len, $s->page_is_redirect, $s->page_latest );
$output->addLink( $title, $s->page_id );
# FIXME: convoluted data flow
# The redirect status and length is passed to getLinkColour via the LinkCache