aboutsummaryrefslogtreecommitdiffstats
path: root/includes
diff options
context:
space:
mode:
authorBrion Vibber <brion@users.mediawiki.org>2005-04-26 09:52:11 +0000
committerBrion Vibber <brion@users.mediawiki.org>2005-04-26 09:52:11 +0000
commit86ae9336018ee945c302c291e7f2bca66d5fb71f (patch)
tree6a44d3ee6be7a3295ad2735292c83d2fa7b40700 /includes
parent8b3e9bd80c2ba3df6cdffcecdf6980b22b8ba05e (diff)
downloadmediawikicore-86ae9336018ee945c302c291e7f2bca66d5fb71f.tar.gz
mediawikicore-86ae9336018ee945c302c291e7f2bca66d5fb71f.zip
* (bug 1982) Fix loading of old text for section merging on edits.
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/8634
Diffstat (limited to 'includes')
-rw-r--r--includes/Article.php15
-rw-r--r--includes/EditPage.php2
-rw-r--r--includes/Revision.php22
3 files changed, 34 insertions, 5 deletions
diff --git a/includes/Article.php b/includes/Article.php
index 9666c98030c1..8a9ad87bb9dc 100644
--- a/includes/Article.php
+++ b/includes/Article.php
@@ -957,6 +957,8 @@ class Article {
/**
* 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';
@@ -986,12 +988,15 @@ class Article {
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;
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 1eb87ab93731..eccf09b7703b 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -365,10 +365,12 @@ class EditPage {
$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);
}
diff --git a/includes/Revision.php b/includes/Revision.php
index 67eb4be6fcff..a42ccacbde08 100644
--- a/includes/Revision.php
+++ b/includes/Revision.php
@@ -36,6 +36,7 @@ class Revision {
* @param int $id
* @return Revision
* @access public
+ * @static
*/
function &newFromTitle( &$title, $id = 0 ) {
if( $id ) {
@@ -75,6 +76,27 @@ class Revision {
}
/**
+ * 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.
*
* @param array $conditions