* @todo document
*/
-/** */
-require_once( 'Database.php' );
-
/**
* @package MediaWiki
* @todo document
* Returns null if no such revision can be found.
*
* @param int $id
- * @static
* @access public
+ * @static
*/
public static function newFromId( $id ) {
return Revision::newFromConds(
'page_title' => $title->getDbkey() ) );
}
+ /**
+ * Load a page revision from a given revision ID number.
+ * Returns null if no such revision can be found.
+ *
+ * @param Database $db
+ * @param int $id
+ * @access public
+ * @static
+ */
+ public static function loadFromId( &$db, $id ) {
+ return Revision::loadFromConds( $db,
+ array( 'page_id=rev_page',
+ 'rev_id' => intval( $id ) ) );
+ }
+
/**
* Load either the current, or a specified, revision
* that's attached to a given page. If not attached
* @param int $id
* @return Revision
* @access public
+ * @static
*/
public static function loadFromPageId( &$db, $pageid, $id = 0 ) {
$conds=array('page_id=rev_page','rev_page'=>intval( $pageid ), 'page_id'=>intval( $pageid ));
* @param int $id
* @return Revision
* @access public
+ * @static
*/
- function loadFromTitle( &$db, $title, $id = 0 ) {
+ public static function loadFromTitle( &$db, $title, $id = 0 ) {
if( $id ) {
$matchId = intval( $id );
} else {
* @access public
* @static
*/
- function loadFromTimestamp( &$db, &$title, $timestamp ) {
+ public static function loadFromTimestamp( &$db, &$title, $timestamp ) {
return Revision::loadFromConds(
$db,
array( 'rev_timestamp' => $db->timestamp( $timestamp ),
*
* @param array $conditions
* @return Revision
- * @static
* @access private
+ * @static
*/
private static function newFromConds( $conditions ) {
$db =& wfGetDB( DB_SLAVE );
* @param Database $db
* @param array $conditions
* @return Revision
- * @static
* @access private
+ * @static
*/
private static function loadFromConds( &$db, $conditions ) {
$res = Revision::fetchFromConds( $db, $conditions );
*
* @param Title $title
* @return ResultWrapper
- * @static
* @access public
+ * @static
*/
- function fetchAllRevisions( &$title ) {
+ public static function fetchAllRevisions( &$title ) {
return Revision::fetchFromConds(
wfGetDB( DB_SLAVE ),
array( 'page_namespace' => $title->getNamespace(),
*
* @param Title $title
* @return ResultWrapper
- * @static
* @access public
+ * @static
*/
public static function fetchRevision( &$title ) {
return Revision::fetchFromConds(
* @param Database $db
* @param array $conditions
* @return ResultWrapper
- * @static
* @access private
+ * @static
*/
private static function fetchFromConds( &$db, $conditions ) {
$res = $db->select(
// Enforce spacing trimming on supplied text
$this->mComment = isset( $row['comment'] ) ? trim( strval( $row['comment'] ) ) : null;
$this->mText = isset( $row['text'] ) ? rtrim( strval( $row['text'] ) ) : null;
+ $this->mTextRow = null;
$this->mTitle = null; # Load on demand if needed
$this->mCurrent = false;
wfProfileOut( $fname );
return false;
}
- require_once('ExternalStore.php');
$text=ExternalStore::fetchFromURL($url);
}
} else {
$store = $wgDefaultExternalStore;
}
- require_once('ExternalStore.php');
// Store and get the URL
$data = ExternalStore::insert( $store, $data );
if ( !$data ) {
wfProfileIn( $fname );
// Caching may be beneficial for massive use of external storage
- global $wgRevisionCacheExpiry, $wgMemc, $wgDBname;
- $key = "$wgDBname:revisiontext:textid:" . $this->getTextId();
+ global $wgRevisionCacheExpiry, $wgMemc;
+ $key = wfMemcKey( 'revisiontext', 'textid', $this->getTextId() );
if( $wgRevisionCacheExpiry ) {
$text = $wgMemc->get( $key );
if( is_string( $text ) ) {
}
// If we kept data for lazy extraction, use it now...
- $row = $this->mTextRow;
- $this->mTextRow = null;
+ if ( isset( $this->mTextRow ) ) {
+ $row = $this->mTextRow;
+ $this->mTextRow = null;
+ } else {
+ $row = null;
+ }
if( !$row ) {
// Text data is immutable; check slaves first.