/**
* Fetch and uncompress the text for a given revision.
* Can ask by rev_id number or timestamp (set $field)
+ * FIXME: This function is broken. Eliminate all uses and remove.
+ * Use Revision class in place.
*/
function fetchRevisionText( $revId = null, $field = 'rev_id' ) {
$fname = 'Article::fetchRevisionText';
function getTextOfLastEditWithSectionReplacedOrAdded($section, $text, $summary = '', $edittime = NULL) {
$fname = 'Article::getTextOfLastEditWithSectionReplacedOrAdded';
- if( is_null( $edittime ) ) {
- $oldtext = $this->fetchRevisionText();
- } else {
- $oldtext = $this->fetchRevisionText( $edittime, 'rev_timestamp' );
- }
if ($section != '') {
+ if( is_null( $edittime ) ) {
+ $rev = Revision::newFromTitle( $this->mTitle );
+ } else {
+ $dbw =& wfGetDB( DB_MASTER );
+ $rev = Revision::loadFromTimestamp( $dbw, $this->mTitle, $edittime );
+ }
+ $oldtext = $rev->getText();
+
if($section=='new') {
if($summary) $subject="== {$summary} ==\n\n";
$text=$oldtext."\n\n".$subject.$text;
$userid = $wgUser->getID();
if ( $isConflict) {
+ wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime'\n" );
$text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
$this->section, $this->textbox1, $this->summary, $this->edittime);
}
else {
+ wfDebug( "EditPage::editForm getting section '$this->section'\n" );
$text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
$this->section, $this->textbox1, $this->summary);
}
* @param int $id
* @return Revision
* @access public
+ * @static
*/
function &newFromTitle( &$title, $id = 0 ) {
if( $id ) {
'page_id=rev_page' ) );
}
+ /**
+ * Load the revision for the given title with the given timestamp.
+ * WARNING: Timestamps may in some circumstances not be unique,
+ * so this isn't the best key to use.
+ *
+ * @param Database $db
+ * @param Title $title
+ * @param string $timestamp
+ * @return Revision
+ * @access public
+ * @static
+ */
+ function &loadFromTimestamp( &$db, &$title, $timestamp ) {
+ return Revision::loadFromConds(
+ $db,
+ array( 'rev_timestamp' => $db->timestamp( $timestamp ),
+ 'page_id=rev_page',
+ 'page_namespace' => $title->getNamespace(),
+ 'page_title' => $title->getDbkey() ) );
+ }
+
/**
* Given a set of conditions, fetch a revision.
*