2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2012-05-08 12:51:21 +00:00
|
|
|
* User interface for the difference engine.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-08 11:55:47 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup DifferenceEngine
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2010-11-27 19:01:51 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
/**
|
|
|
|
|
* Constant to indicate diff cache compatibility.
|
|
|
|
|
* Bump this when changing the diff formatting in a way that
|
|
|
|
|
* fixes important bugs or such to force cached diff views to
|
|
|
|
|
* clear.
|
|
|
|
|
*/
|
|
|
|
|
define( 'MW_DIFF_VERSION', '1.11a' );
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup DifferenceEngine
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-11-10 13:06:52 +00:00
|
|
|
class DifferenceEngine extends ContextSource {
|
2014-03-03 17:08:05 +00:00
|
|
|
|
2013-11-20 19:11:57 +00:00
|
|
|
/** @var int */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mOldid;
|
2013-11-20 19:11:57 +00:00
|
|
|
|
|
|
|
|
/** @var int */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mNewid;
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
private $mOldTags;
|
|
|
|
|
private $mNewTags;
|
2013-10-04 13:43:09 +00:00
|
|
|
|
2013-11-20 19:11:57 +00:00
|
|
|
/** @var Content */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mOldContent;
|
2013-11-20 19:11:57 +00:00
|
|
|
|
|
|
|
|
/** @var Content */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mNewContent;
|
2013-11-20 19:11:57 +00:00
|
|
|
|
|
|
|
|
/** @var Language */
|
2013-11-11 16:35:19 +00:00
|
|
|
protected $mDiffLang;
|
2011-02-19 21:44:20 +00:00
|
|
|
|
2014-04-05 19:54:24 +00:00
|
|
|
/** @var Title */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mOldPage;
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2014-04-05 19:54:24 +00:00
|
|
|
/** @var Title */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mNewPage;
|
2011-02-19 21:44:20 +00:00
|
|
|
|
2013-11-20 19:11:57 +00:00
|
|
|
/** @var Revision */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mOldRev;
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2014-04-05 19:54:24 +00:00
|
|
|
/** @var Revision */
|
2013-11-11 16:35:19 +00:00
|
|
|
public $mNewRev;
|
2013-11-20 19:11:57 +00:00
|
|
|
|
|
|
|
|
/** @var bool Have the revisions IDs been loaded */
|
|
|
|
|
private $mRevisionsIdsLoaded = false;
|
|
|
|
|
|
|
|
|
|
/** @var bool Have the revisions been loaded */
|
|
|
|
|
public $mRevisionsLoaded = false;
|
|
|
|
|
|
|
|
|
|
/** @var int How many text blobs have been loaded, 0, 1 or 2? */
|
|
|
|
|
public $mTextLoaded = 0;
|
|
|
|
|
|
|
|
|
|
/** @var bool Was the diff fetched from cache? */
|
|
|
|
|
public $mCacheHit = false;
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Set this to true to add debug info to the HTML output.
|
|
|
|
|
* Warning: this may cause RSS readers to spuriously mark articles as "new"
|
|
|
|
|
* (bug 20601)
|
|
|
|
|
*/
|
2013-10-04 13:43:09 +00:00
|
|
|
public $enableDebugComment = false;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2014-04-08 15:29:17 +00:00
|
|
|
/** @var bool If true, line X is not displayed when X is 1, for example
|
2013-11-20 19:11:57 +00:00
|
|
|
* to increase readability and conserve space with many small diffs.
|
|
|
|
|
*/
|
2013-11-11 16:35:19 +00:00
|
|
|
protected $mReducedLineNumbers = false;
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2014-02-05 11:02:29 +00:00
|
|
|
/** @var string Link to action=markpatrolled */
|
2013-11-11 16:35:19 +00:00
|
|
|
protected $mMarkPatrolledLink = null;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2013-11-20 19:11:57 +00:00
|
|
|
/** @var bool Show rev_deleted content if allowed */
|
|
|
|
|
protected $unhide = false;
|
2014-10-10 21:14:56 +00:00
|
|
|
|
|
|
|
|
/** @var bool Refresh the diff cache */
|
|
|
|
|
protected $mRefreshCache = false;
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**#@-*/
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
2014-07-24 17:42:45 +00:00
|
|
|
* @param IContextSource $context Context to use, anything else will be ignored
|
|
|
|
|
* @param int $old Old ID we want to show and diff with.
|
|
|
|
|
* @param string|int $new Either revision ID or 'prev' or 'next'. Default: 0.
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param int $rcid Deprecated, no longer used!
|
|
|
|
|
* @param bool $refreshCache If set, refreshes the diff cache
|
|
|
|
|
* @param bool $unhide If set, allow viewing deleted revs
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function __construct( $context = null, $old = 0, $new = 0, $rcid = 0,
|
|
|
|
|
$refreshCache = false, $unhide = false
|
|
|
|
|
) {
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $context instanceof IContextSource ) {
|
|
|
|
|
$this->setContext( $context );
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2011-11-10 13:06:52 +00:00
|
|
|
|
2010-11-27 19:01:51 +00:00
|
|
|
wfDebug( "DifferenceEngine old '$old' new '$new' rcid '$rcid'\n" );
|
2010-11-07 16:28:11 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldid = $old;
|
|
|
|
|
$this->mNewid = $new;
|
|
|
|
|
$this->mRefreshCache = $refreshCache;
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->unhide = $unhide;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param bool $value
|
2011-06-01 16:27:46 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function setReducedLineNumbers( $value = true ) {
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mReducedLineNumbers = $value;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
|
|
|
|
* @return Language
|
|
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function getDiffLang() {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mDiffLang === null ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
# Default language in which the diff text is written.
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mDiffLang = $this->getTitle()->getPageLanguage();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
return $this->mDiffLang;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function wasCacheHit() {
|
2013-11-11 16:35:19 +00:00
|
|
|
return $this->mCacheHit;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-27 19:01:51 +00:00
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function getOldid() {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$this->loadRevisionIds();
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
return $this->mOldid;
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2010-11-27 19:01:51 +00:00
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
2014-03-03 17:08:05 +00:00
|
|
|
* @return bool|int
|
2011-06-01 16:27:46 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function getNewid() {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$this->loadRevisionIds();
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
return $this->mNewid;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2006-10-03 13:00:52 +00:00
|
|
|
|
2011-05-10 01:17:01 +00:00
|
|
|
/**
|
|
|
|
|
* Look up a special:Undelete link to the given deleted revision id,
|
|
|
|
|
* as a workaround for being unable to load deleted diffs in currently.
|
|
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param int $id Revision ID
|
|
|
|
|
*
|
2011-05-10 01:17:01 +00:00
|
|
|
* @return mixed URL or false
|
|
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function deletedLink( $id ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
|
2011-05-10 01:17:01 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2013-02-03 18:47:42 +00:00
|
|
|
$row = $dbr->selectRow( 'archive', '*',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'ar_rev_id' => $id ],
|
2011-05-10 01:17:01 +00:00
|
|
|
__METHOD__ );
|
|
|
|
|
if ( $row ) {
|
|
|
|
|
$rev = Revision::newFromArchiveRow( $row );
|
|
|
|
|
$title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return SpecialPage::getTitleFor( 'Undelete' )->getFullURL( [
|
2011-05-10 01:17:01 +00:00
|
|
|
'target' => $title->getPrefixedText(),
|
|
|
|
|
'timestamp' => $rev->getTimestamp()
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2011-05-10 01:17:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2011-05-10 01:17:01 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build a wikitext link toward a deleted revision, if viewable.
|
|
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param int $id Revision ID
|
|
|
|
|
*
|
|
|
|
|
* @return string Wikitext fragment
|
2011-05-10 01:17:01 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function deletedIdMarker( $id ) {
|
2011-05-10 01:17:01 +00:00
|
|
|
$link = $this->deletedLink( $id );
|
|
|
|
|
if ( $link ) {
|
|
|
|
|
return "[$link $id]";
|
|
|
|
|
} else {
|
|
|
|
|
return $id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 14:55:28 +00:00
|
|
|
private function showMissingRevision() {
|
|
|
|
|
$out = $this->getOutput();
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$missing = [];
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev === null ||
|
|
|
|
|
( $this->mOldRev && $this->mOldContent === null )
|
2013-07-25 15:34:20 +00:00
|
|
|
) {
|
2013-11-11 16:35:19 +00:00
|
|
|
$missing[] = $this->deletedIdMarker( $this->mOldid );
|
2012-08-20 14:55:28 +00:00
|
|
|
}
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewRev === null ||
|
|
|
|
|
( $this->mNewRev && $this->mNewContent === null )
|
2013-07-25 15:34:20 +00:00
|
|
|
) {
|
2013-11-11 16:35:19 +00:00
|
|
|
$missing[] = $this->deletedIdMarker( $this->mNewid );
|
2012-08-20 14:55:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$out->setPageTitle( $this->msg( 'errorpagetitle' ) );
|
2014-09-25 12:34:41 +00:00
|
|
|
$msg = $this->msg( 'difference-missing-revision' )
|
|
|
|
|
->params( $this->getLanguage()->listToText( $missing ) )
|
|
|
|
|
->numParams( count( $missing ) )
|
|
|
|
|
->parseAsBlock();
|
|
|
|
|
$out->addHtml( $msg );
|
2012-08-20 14:55:28 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-25 08:23:32 +00:00
|
|
|
public function showDiffPage( $diffOnly = false ) {
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2011-01-04 06:12:33 +00:00
|
|
|
# Allow frames except in certain special cases
|
2011-11-10 13:06:52 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
|
$out->allowClickjacking();
|
|
|
|
|
$out->setRobotPolicy( 'noindex,nofollow' );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( !$this->loadRevisionData() ) {
|
2012-08-20 14:55:28 +00:00
|
|
|
$this->showMissingRevision();
|
2013-11-20 19:11:57 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$user = $this->getUser();
|
2013-11-11 16:35:19 +00:00
|
|
|
$permErrors = $this->mNewPage->getUserPermissionsErrors( 'read', $user );
|
|
|
|
|
if ( $this->mOldPage ) { # mOldPage might not be set, see below.
|
2011-11-06 19:59:46 +00:00
|
|
|
$permErrors = wfMergeErrorArrays( $permErrors,
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldPage->getUserPermissionsErrors( 'read', $user ) );
|
2011-11-06 19:59:46 +00:00
|
|
|
}
|
|
|
|
|
if ( count( $permErrors ) ) {
|
|
|
|
|
throw new PermissionsError( 'read', $permErrors );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$rollback = '';
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$query = [];
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
# Carry over 'diffonly' param via navigation links
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $diffOnly != $user->getBoolOption( 'diffonly' ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$query['diffonly'] = $diffOnly;
|
|
|
|
|
}
|
|
|
|
|
# Cascade unhide param in links for easy deletion browsing
|
|
|
|
|
if ( $this->unhide ) {
|
|
|
|
|
$query['unhide'] = 1;
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
# Check if one of the revisions is deleted/suppressed
|
|
|
|
|
$deleted = $suppressed = false;
|
2013-11-11 16:35:19 +00:00
|
|
|
$allowed = $this->mNewRev->userCan( Revision::DELETED_TEXT, $user );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$revisionTools = [];
|
2013-03-13 15:43:27 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
# mOldRev is false if the difference engine is called with a "vague" query for
|
2010-11-07 16:28:11 +00:00
|
|
|
# a diff between a version V and its previous version V' AND the version V
|
|
|
|
|
# is the first version of that article. In that case, V' does not exist.
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev === false ) {
|
|
|
|
|
$out->setPageTitle( $this->msg( 'difference-title', $this->mNewPage->getPrefixedText() ) );
|
2011-10-05 19:59:39 +00:00
|
|
|
$samePage = true;
|
|
|
|
|
$oldHeader = '';
|
|
|
|
|
} else {
|
2016-02-17 09:09:32 +00:00
|
|
|
Hooks::run( 'DiffViewHeader', [ $this, $this->mOldRev, $this->mNewRev ] );
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewPage->equals( $this->mOldPage ) ) {
|
|
|
|
|
$out->setPageTitle( $this->msg( 'difference-title', $this->mNewPage->getPrefixedText() ) );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$samePage = true;
|
|
|
|
|
} else {
|
2013-10-04 13:43:09 +00:00
|
|
|
$out->setPageTitle( $this->msg( 'difference-title-multipage',
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText() ) );
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->addSubtitle( $this->msg( 'difference-multipage' ) );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$samePage = false;
|
|
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $samePage && $this->mNewPage->quickUserCan( 'edit', $user ) ) {
|
|
|
|
|
if ( $this->mNewRev->isCurrent() && $this->mNewPage->userCan( 'rollback', $user ) ) {
|
|
|
|
|
$rollbackLink = Linker::generateRollback( $this->mNewRev, $this->getContext() );
|
2012-11-01 20:04:12 +00:00
|
|
|
if ( $rollbackLink ) {
|
|
|
|
|
$out->preventClickjacking();
|
|
|
|
|
$rollback = '   ' . $rollbackLink;
|
|
|
|
|
}
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
2013-10-04 13:43:09 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) &&
|
|
|
|
|
!$this->mNewRev->isDeleted( Revision::DELETED_TEXT )
|
2013-10-04 13:43:09 +00:00
|
|
|
) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$undoLink = Html::element( 'a', [
|
|
|
|
|
'href' => $this->mNewPage->getLocalURL( [
|
2011-11-10 13:06:52 +00:00
|
|
|
'action' => 'edit',
|
2013-11-11 16:35:19 +00:00
|
|
|
'undoafter' => $this->mOldid,
|
2013-11-20 19:11:57 +00:00
|
|
|
'undo' => $this->mNewid
|
2016-02-17 09:09:32 +00:00
|
|
|
] ),
|
2014-07-05 17:57:37 +00:00
|
|
|
'title' => Linker::titleAttrib( 'undo' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->msg( 'editundo' )->text()
|
2013-03-07 02:38:00 +00:00
|
|
|
);
|
2014-07-05 17:57:37 +00:00
|
|
|
$revisionTools['mw-diff-undo'] = $undoLink;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
# Make "previous revision link"
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $samePage && $this->mOldRev->getPrevious() ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$prevlink = Linker::linkKnown(
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldPage,
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->msg( 'previousdiff' )->escaped(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'id' => 'differences-prevlink' ],
|
|
|
|
|
[ 'diff' => 'prev', 'oldid' => $this->mOldid ] + $query
|
2010-11-07 16:28:11 +00:00
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
} else {
|
|
|
|
|
$prevlink = ' ';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev->isMinor() ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$oldminor = ChangesList::flag( 'minor' );
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$oldminor = '';
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$ldel = $this->revisionDeleteLink( $this->mOldRev );
|
|
|
|
|
$oldRevisionHeader = $this->getRevisionHeader( $this->mOldRev, 'complete' );
|
2016-01-29 13:03:41 +00:00
|
|
|
$oldChangeTags = ChangeTags::formatSummaryRow( $this->mOldTags, 'diff', $this->getContext() );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' .
|
|
|
|
|
'<div id="mw-diff-otitle2">' .
|
2013-11-20 19:11:57 +00:00
|
|
|
Linker::revUserTools( $this->mOldRev, !$this->unhide ) . '</div>' .
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
'<div id="mw-diff-otitle3">' . $oldminor .
|
2013-11-20 19:11:57 +00:00
|
|
|
Linker::revComment( $this->mOldRev, !$diffOnly, !$this->unhide ) . $ldel . '</div>' .
|
2013-07-06 20:53:27 +00:00
|
|
|
'<div id="mw-diff-otitle5">' . $oldChangeTags[0] . '</div>' .
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
'<div id="mw-diff-otitle4">' . $prevlink . '</div>';
|
|
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev->isDeleted( Revision::DELETED_TEXT ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$deleted = true; // old revisions text is hidden
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev->isDeleted( Revision::DELETED_RESTRICTED ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$suppressed = true; // also suppressed
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check if this user can see the revisions
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( !$this->mOldRev->userCan( Revision::DELETED_TEXT, $user ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$allowed = false;
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# Make "next revision link"
|
|
|
|
|
# Skip next link on the top revision
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $samePage && !$this->mNewRev->isCurrent() ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$nextlink = Linker::linkKnown(
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mNewPage,
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->msg( 'nextdiff' )->escaped(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'id' => 'differences-nextlink' ],
|
|
|
|
|
[ 'diff' => 'next', 'oldid' => $this->mNewid ] + $query
|
2010-11-07 16:28:11 +00:00
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
} else {
|
|
|
|
|
$nextlink = ' ';
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewRev->isMinor() ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$newminor = ChangesList::flag( 'minor' );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
} else {
|
|
|
|
|
$newminor = '';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# Handle RevisionDelete links...
|
2013-11-11 16:35:19 +00:00
|
|
|
$rdel = $this->revisionDeleteLink( $this->mNewRev );
|
2013-03-07 02:38:00 +00:00
|
|
|
|
|
|
|
|
# Allow extensions to define their own revision tools
|
2015-11-21 12:24:17 +00:00
|
|
|
Hooks::run( 'DiffRevisionTools',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $this->mNewRev, &$revisionTools, $this->mOldRev, $user ] );
|
|
|
|
|
$formattedRevisionTools = [];
|
2013-03-07 02:38:00 +00:00
|
|
|
// Put each one in parentheses (poor man's button)
|
2014-07-05 17:57:37 +00:00
|
|
|
foreach ( $revisionTools as $key => $tool ) {
|
|
|
|
|
$toolClass = is_string( $key ) ? $key : 'mw-diff-tool';
|
|
|
|
|
$element = Html::rawElement(
|
|
|
|
|
'span',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => $toolClass ],
|
2014-07-05 17:57:37 +00:00
|
|
|
$this->msg( 'parentheses' )->rawParams( $tool )->escaped()
|
|
|
|
|
);
|
|
|
|
|
$formattedRevisionTools[] = $element;
|
2013-03-07 02:38:00 +00:00
|
|
|
}
|
2013-11-11 16:35:19 +00:00
|
|
|
$newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) .
|
2013-10-04 13:43:09 +00:00
|
|
|
' ' . implode( ' ', $formattedRevisionTools );
|
2016-01-29 13:03:41 +00:00
|
|
|
$newChangeTags = ChangeTags::formatSummaryRow( $this->mNewTags, 'diff', $this->getContext() );
|
2010-11-07 16:28:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' .
|
2013-11-11 16:35:19 +00:00
|
|
|
'<div id="mw-diff-ntitle2">' . Linker::revUserTools( $this->mNewRev, !$this->unhide ) .
|
2013-11-20 19:11:57 +00:00
|
|
|
" $rollback</div>" .
|
2010-11-07 16:28:11 +00:00
|
|
|
'<div id="mw-diff-ntitle3">' . $newminor .
|
2013-11-20 19:11:57 +00:00
|
|
|
Linker::revComment( $this->mNewRev, !$diffOnly, !$this->unhide ) . $rdel . '</div>' .
|
2013-07-06 20:53:27 +00:00
|
|
|
'<div id="mw-diff-ntitle5">' . $newChangeTags[0] . '</div>' .
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
'<div id="mw-diff-ntitle4">' . $nextlink . $this->markPatrolledLink() . '</div>';
|
2010-11-07 16:28:11 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$deleted = true; // new revisions text is hidden
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$suppressed = true; // also suppressed
|
2013-04-17 14:52:47 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# If the diff cannot be shown due to a deleted revision, then output
|
|
|
|
|
# the diff header and links to unhide (if available)...
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $deleted && ( !$this->unhide || !$allowed ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->showDiffStyle();
|
|
|
|
|
$multi = $this->getMultiNotice();
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) );
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( !$allowed ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$msg = $suppressed ? 'rev-suppressed-no-diff' : 'rev-deleted-no-diff';
|
|
|
|
|
# Give explanation for why revision is not visible
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->wrapWikiMsg( "<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n",
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $msg ] );
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
|
|
|
|
# Give explanation and add a link to view the diff...
|
2016-01-06 23:13:31 +00:00
|
|
|
$query = $this->getRequest()->appendQueryValue( 'unhide', '1' );
|
2013-10-04 13:43:09 +00:00
|
|
|
$link = $this->getTitle()->getFullURL( $query );
|
2010-11-07 16:28:11 +00:00
|
|
|
$msg = $suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
|
2013-10-04 13:43:09 +00:00
|
|
|
$out->wrapWikiMsg(
|
|
|
|
|
"<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n",
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $msg, $link ]
|
2013-10-04 13:43:09 +00:00
|
|
|
);
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
# Otherwise, output a regular diff...
|
2004-11-25 23:49:52 +00:00
|
|
|
} else {
|
2010-11-07 16:28:11 +00:00
|
|
|
# Add deletion notice if the user is viewing deleted content
|
|
|
|
|
$notice = '';
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $deleted ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view';
|
2013-10-04 13:43:09 +00:00
|
|
|
$notice = "<div id='mw-$msg' class='mw-warning plainlinks'>\n" .
|
|
|
|
|
$this->msg( $msg )->parse() .
|
|
|
|
|
"</div>\n";
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
$this->showDiff( $oldHeader, $newHeader, $notice );
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( !$diffOnly ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->renderNewRevision();
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-11-27 19:01:51 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
2015-12-04 17:34:49 +00:00
|
|
|
* Build a link to mark a change as patrolled.
|
|
|
|
|
*
|
|
|
|
|
* Returns empty string if there's either no revision to patrol or the user is not allowed to.
|
2012-10-03 01:33:55 +00:00
|
|
|
* Side effect: When the patrol link is build, this method will call
|
|
|
|
|
* OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
*
|
2015-12-04 17:34:49 +00:00
|
|
|
* @return string HTML or empty string
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
*/
|
|
|
|
|
protected function markPatrolledLink() {
|
2015-12-04 17:34:49 +00:00
|
|
|
if ( $this->mMarkPatrolledLink === null ) {
|
|
|
|
|
$linkInfo = $this->getMarkPatrolledLinkInfo();
|
|
|
|
|
// If false, there is no patrol link needed/allowed
|
|
|
|
|
if ( !$linkInfo ) {
|
|
|
|
|
$this->mMarkPatrolledLink = '';
|
|
|
|
|
} else {
|
|
|
|
|
$this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown(
|
|
|
|
|
$this->mNewPage,
|
|
|
|
|
$this->msg( 'markaspatrolleddiff' )->escaped(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2015-12-04 17:34:49 +00:00
|
|
|
'action' => 'markpatrolled',
|
|
|
|
|
'rcid' => $linkInfo['rcid'],
|
|
|
|
|
'token' => $linkInfo['token'],
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2015-12-04 17:34:49 +00:00
|
|
|
) . ']</span>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $this->mMarkPatrolledLink;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns an array of meta data needed to build a "mark as patrolled" link and
|
|
|
|
|
* adds the mediawiki.page.patrol.ajax to the output.
|
|
|
|
|
*
|
|
|
|
|
* @return array|false An array of meta data for a patrol link (rcid & token)
|
|
|
|
|
* or false if no link is needed
|
|
|
|
|
*/
|
|
|
|
|
protected function getMarkPatrolledLinkInfo() {
|
2013-06-09 01:41:48 +00:00
|
|
|
global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
|
2015-12-04 17:34:49 +00:00
|
|
|
|
2013-07-20 19:24:20 +00:00
|
|
|
$user = $this->getUser();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2015-12-04 17:34:49 +00:00
|
|
|
// Prepare a change patrol link, if applicable
|
|
|
|
|
if (
|
|
|
|
|
// Is patrolling enabled and the user allowed to?
|
|
|
|
|
$wgUseRCPatrol && $this->mNewPage->quickUserCan( 'patrol', $user ) &&
|
|
|
|
|
// Only do this if the revision isn't more than 6 hours older
|
|
|
|
|
// than the Max RC age (6h because the RC might not be cleaned out regularly)
|
|
|
|
|
RecentChange::isInRCLifespan( $this->mNewRev->getTimestamp(), 21600 )
|
|
|
|
|
) {
|
|
|
|
|
// Look for an unpatrolled change corresponding to this diff
|
|
|
|
|
$db = wfGetDB( DB_SLAVE );
|
|
|
|
|
$change = RecentChange::newFromConds(
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-12-04 17:34:49 +00:00
|
|
|
'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ),
|
|
|
|
|
'rc_this_oldid' => $this->mNewid,
|
|
|
|
|
'rc_patrolled' => 0
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-12-04 17:34:49 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2015-12-04 17:34:49 +00:00
|
|
|
if ( $change && !$change->getPerformer()->equals( $user ) ) {
|
|
|
|
|
$rcid = $change->getAttribute( 'rc_id' );
|
|
|
|
|
} else {
|
|
|
|
|
// None found or the page has been created by the current user.
|
|
|
|
|
// If the user could patrol this it already would be patrolled
|
|
|
|
|
$rcid = 0;
|
|
|
|
|
}
|
|
|
|
|
// Build the link
|
|
|
|
|
if ( $rcid ) {
|
|
|
|
|
$this->getOutput()->preventClickjacking();
|
|
|
|
|
if ( $wgEnableAPI && $wgEnableWriteAPI
|
|
|
|
|
&& $user->isAllowed( 'writeapi' )
|
|
|
|
|
) {
|
|
|
|
|
$this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
2012-10-03 01:33:55 +00:00
|
|
|
|
2015-12-04 17:34:49 +00:00
|
|
|
$token = $user->getEditToken( $rcid );
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-12-04 17:34:49 +00:00
|
|
|
'rcid' => $rcid,
|
|
|
|
|
'token' => $token,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-04 17:34:49 +00:00
|
|
|
// No mark as patrolled link applicable
|
|
|
|
|
return false;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-19 21:44:20 +00:00
|
|
|
/**
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param Revision $rev
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
2011-02-19 21:44:20 +00:00
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
protected function revisionDeleteLink( $rev ) {
|
2011-12-28 18:41:36 +00:00
|
|
|
$link = Linker::getRevDeleteLink( $this->getUser(), $rev, $rev->getTitle() );
|
|
|
|
|
if ( $link !== '' ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$link = '   ' . $link . ' ';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return $link;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* Show the new revision of the page.
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function renderNewRevision() {
|
2011-11-10 13:06:52 +00:00
|
|
|
$out = $this->getOutput();
|
2013-11-11 16:35:19 +00:00
|
|
|
$revHeader = $this->getRevisionHeader( $this->mNewRev );
|
2010-12-11 05:32:48 +00:00
|
|
|
# Add "current version as of X" title
|
2015-01-16 22:50:34 +00:00
|
|
|
$out->addHTML( "<hr class='diff-hr' id='mw-oldid' />
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
|
2010-12-11 05:32:48 +00:00
|
|
|
# Page content may be handled by a hooked call instead...
|
2013-10-04 13:43:09 +00:00
|
|
|
# @codingStandardsIgnoreStart Ignoring long lines.
|
2016-03-11 17:41:26 +00:00
|
|
|
if ( Hooks::run( 'ArticleContentOnDiff', [ $this, $out ] ) ) {
|
2010-12-11 05:32:48 +00:00
|
|
|
$this->loadNewText();
|
2013-11-11 16:35:19 +00:00
|
|
|
$out->setRevisionId( $this->mNewid );
|
|
|
|
|
$out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->setArticleFlag( true );
|
2011-02-12 04:06:22 +00:00
|
|
|
|
2012-08-20 17:28:20 +00:00
|
|
|
// NOTE: only needed for B/C: custom rendering of JS/CSS via hook
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
|
2014-05-05 16:58:34 +00:00
|
|
|
// This needs to be synchronised with Article::showCssOrJsPage(), which sucks
|
2010-12-11 05:32:48 +00:00
|
|
|
// Give hooks a chance to customise the output
|
2013-05-15 01:12:35 +00:00
|
|
|
// @todo standardize this crap into one function
|
2016-03-11 17:41:26 +00:00
|
|
|
if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', [ $this->mNewContent, $this->mNewPage, $out ] ) ) {
|
2012-08-20 19:33:07 +00:00
|
|
|
// NOTE: deprecated hook, B/C only
|
2012-06-12 09:12:19 +00:00
|
|
|
// use the content object's own rendering
|
2013-11-11 16:35:19 +00:00
|
|
|
$cnt = $this->mNewRev->getContent();
|
|
|
|
|
$po = $cnt ? $cnt->getParserOutput( $this->mNewRev->getTitle(), $this->mNewRev->getId() ) : null;
|
2014-05-05 16:58:34 +00:00
|
|
|
if ( $po ) {
|
|
|
|
|
$out->addParserOutputContent( $po );
|
|
|
|
|
}
|
2010-12-11 05:32:48 +00:00
|
|
|
}
|
2016-03-11 17:41:26 +00:00
|
|
|
} elseif ( !Hooks::run( 'ArticleContentViewCustom', [ $this->mNewContent, $this->mNewPage, $out ] ) ) {
|
2012-06-12 09:12:19 +00:00
|
|
|
// Handled by extension
|
2016-03-11 17:41:26 +00:00
|
|
|
} elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', [ $this->mNewContent, $this->mNewPage, $out ] ) ) {
|
2012-08-20 19:33:07 +00:00
|
|
|
// NOTE: deprecated hook, B/C only
|
2012-06-12 09:12:19 +00:00
|
|
|
// Handled by extension
|
2011-11-14 18:28:01 +00:00
|
|
|
} else {
|
2011-11-17 20:21:54 +00:00
|
|
|
// Normal page
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->getTitle()->equals( $this->mNewPage ) ) {
|
2012-01-15 22:00:04 +00:00
|
|
|
// If the Title stored in the context is the same as the one
|
|
|
|
|
// of the new revision, we can use its associated WikiPage
|
|
|
|
|
// object.
|
|
|
|
|
$wikiPage = $this->getWikiPage();
|
|
|
|
|
} else {
|
|
|
|
|
// Otherwise we need to create our own WikiPage object
|
2013-11-11 16:35:19 +00:00
|
|
|
$wikiPage = WikiPage::factory( $this->mNewPage );
|
2012-01-15 22:00:04 +00:00
|
|
|
}
|
2011-11-14 18:28:01 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$parserOutput = $this->getParserOutput( $wikiPage, $this->mNewRev );
|
2011-11-14 18:28:01 +00:00
|
|
|
|
2014-01-04 22:07:33 +00:00
|
|
|
# WikiPage::getParserOutput() should not return false, but just in case
|
|
|
|
|
if ( $parserOutput ) {
|
2011-11-14 18:28:01 +00:00
|
|
|
$out->addParserOutput( $parserOutput );
|
2011-02-12 04:06:22 +00:00
|
|
|
}
|
2010-12-11 05:32:48 +00:00
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2013-10-04 13:43:09 +00:00
|
|
|
# @codingStandardsIgnoreEnd
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# Add redundant patrol link on bottom...
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->addHTML( $this->markPatrolledLink() );
|
2010-11-07 16:28:11 +00:00
|
|
|
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2012-06-25 11:44:32 +00:00
|
|
|
protected function getParserOutput( WikiPage $page, Revision $rev ) {
|
2012-09-18 15:43:20 +00:00
|
|
|
$parserOptions = $page->makeParserOptions( $this->getContext() );
|
2012-06-25 11:44:32 +00:00
|
|
|
|
2015-01-29 15:46:28 +00:00
|
|
|
if ( !$rev->isCurrent() || !$rev->getTitle()->quickUserCan( 'edit', $this->getUser() ) ) {
|
2012-06-25 11:44:32 +00:00
|
|
|
$parserOptions->setEditSection( false );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$parserOutput = $page->getParserOutput( $parserOptions, $rev->getId() );
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2012-06-25 11:44:32 +00:00
|
|
|
return $parserOutput;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-17 07:37:55 +00:00
|
|
|
/**
|
2011-11-10 13:06:52 +00:00
|
|
|
* Get the diff text, send it to the OutputPage object
|
2010-11-07 16:28:11 +00:00
|
|
|
* Returns false if the diff could not be generated, otherwise returns true
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
2013-10-04 13:43:09 +00:00
|
|
|
* @param string|bool $otitle Header for old text or false
|
|
|
|
|
* @param string|bool $ntitle Header for new text or false
|
2013-10-29 23:43:53 +00:00
|
|
|
* @param string $notice HTML between diff header and body
|
|
|
|
|
*
|
2011-06-01 16:27:46 +00:00
|
|
|
* @return bool
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function showDiff( $otitle, $ntitle, $notice = '' ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$diff = $this->getDiff( $otitle, $ntitle, $notice );
|
|
|
|
|
if ( $diff === false ) {
|
2012-08-20 14:55:28 +00:00
|
|
|
$this->showMissingRevision();
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
$this->showDiffStyle();
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->getOutput()->addHTML( $diff );
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* Add style sheets and supporting JS for diff display.
|
|
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function showDiffStyle() {
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->getOutput()->addModuleStyles( 'mediawiki.action.history.diff' );
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get complete diff table, including header
|
2004-04-17 07:37:55 +00:00
|
|
|
*
|
2012-12-05 14:21:58 +00:00
|
|
|
* @param string|bool $otitle Header for old text or false
|
|
|
|
|
* @param string|bool $ntitle Header for new text or false
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $notice HTML between diff header and body
|
2014-03-03 17:08:05 +00:00
|
|
|
*
|
2010-11-07 16:28:11 +00:00
|
|
|
* @return mixed
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function getDiff( $otitle, $ntitle, $notice = '' ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$body = $this->getDiffBody();
|
|
|
|
|
if ( $body === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-10-04 13:43:09 +00:00
|
|
|
|
|
|
|
|
$multi = $this->getMultiNotice();
|
|
|
|
|
// Display a message when the diff is empty
|
|
|
|
|
if ( $body === '' ) {
|
|
|
|
|
$notice .= '<div class="mw-diff-empty">' .
|
|
|
|
|
$this->msg( 'diff-empty' )->parse() .
|
|
|
|
|
"</div>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->addHeader( $body, $otitle, $ntitle, $multi, $notice );
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* Get the diff table body, without header
|
2004-04-17 07:37:55 +00:00
|
|
|
*
|
2010-11-18 20:34:02 +00:00
|
|
|
* @return mixed (string/false)
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2010-11-18 20:34:02 +00:00
|
|
|
public function getDiffBody() {
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mCacheHit = true;
|
2010-11-07 16:28:11 +00:00
|
|
|
// Check if the diff should be hidden from this user
|
2010-11-18 20:34:02 +00:00
|
|
|
if ( !$this->loadRevisionData() ) {
|
|
|
|
|
return false;
|
2013-11-11 16:35:19 +00:00
|
|
|
} elseif ( $this->mOldRev &&
|
|
|
|
|
!$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
|
2013-10-04 13:43:09 +00:00
|
|
|
) {
|
2010-11-18 20:34:02 +00:00
|
|
|
return false;
|
2013-11-11 16:35:19 +00:00
|
|
|
} elseif ( $this->mNewRev &&
|
|
|
|
|
!$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
|
2013-10-04 13:43:09 +00:00
|
|
|
) {
|
2010-11-18 20:34:02 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// Short-circuit
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev === false || ( $this->mOldRev && $this->mNewRev
|
2013-11-20 19:11:57 +00:00
|
|
|
&& $this->mOldRev->getID() == $this->mNewRev->getID() )
|
|
|
|
|
) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
// Cacheable?
|
|
|
|
|
$key = false;
|
2015-10-15 02:45:03 +00:00
|
|
|
$cache = ObjectCache::getMainWANInstance();
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldid && $this->mNewid ) {
|
2013-10-27 02:47:28 +00:00
|
|
|
$key = $this->getDiffBodyCacheKey();
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Try cache
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( !$this->mRefreshCache ) {
|
2015-10-15 02:45:03 +00:00
|
|
|
$difftext = $cache->get( $key );
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( $difftext ) {
|
2015-06-03 22:38:02 +00:00
|
|
|
wfIncrStats( 'diff_cache.hit' );
|
2010-11-07 16:28:11 +00:00
|
|
|
$difftext = $this->localiseLineNumbers( $difftext );
|
|
|
|
|
$difftext .= "\n<!-- diff cache key $key -->\n";
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return $difftext;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
} // don't try to load but save the result
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mCacheHit = false;
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Loadtext is permission safe, this just clears out the diff
|
|
|
|
|
if ( !$this->loadText() ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$difftext = $this->generateContentDiffBody( $this->mOldContent, $this->mNewContent );
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Save to cache for 7 days
|
2016-02-17 09:09:32 +00:00
|
|
|
if ( !Hooks::run( 'AbortDiffCache', [ &$this ] ) ) {
|
2015-06-03 22:38:02 +00:00
|
|
|
wfIncrStats( 'diff_cache.uncacheable' );
|
2010-11-18 20:34:02 +00:00
|
|
|
} elseif ( $key !== false && $difftext !== false ) {
|
2015-06-03 22:38:02 +00:00
|
|
|
wfIncrStats( 'diff_cache.miss' );
|
2015-10-15 02:45:03 +00:00
|
|
|
$cache->set( $key, $difftext, 7 * 86400 );
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
2015-06-03 22:38:02 +00:00
|
|
|
wfIncrStats( 'diff_cache.uncacheable' );
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
// Replace line numbers with the text in the user's language
|
|
|
|
|
if ( $difftext !== false ) {
|
|
|
|
|
$difftext = $this->localiseLineNumbers( $difftext );
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return $difftext;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-27 02:47:28 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the cache key for diff body text or content.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.23
|
2014-03-03 17:08:05 +00:00
|
|
|
*
|
2013-10-27 02:47:28 +00:00
|
|
|
* @throws MWException
|
2014-03-03 17:08:05 +00:00
|
|
|
* @return string
|
2013-10-27 02:47:28 +00:00
|
|
|
*/
|
|
|
|
|
protected function getDiffBodyCacheKey() {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( !$this->mOldid || !$this->mNewid ) {
|
|
|
|
|
throw new MWException( 'mOldid and mNewid must be set to get diff cache key.' );
|
2013-10-27 02:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
return wfMemcKey( 'diff', 'version', MW_DIFF_VERSION,
|
|
|
|
|
'oldid', $this->mOldid, 'newid', $this->mNewid );
|
2013-10-27 02:47:28 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-12 09:12:19 +00:00
|
|
|
/**
|
|
|
|
|
* Generate a diff, no caching.
|
|
|
|
|
*
|
2012-10-15 11:04:40 +00:00
|
|
|
* This implementation uses generateTextDiffBody() to generate a diff based on the default
|
|
|
|
|
* serialization of the given Content objects. This will fail if $old or $new are not
|
|
|
|
|
* instances of TextContent.
|
|
|
|
|
*
|
|
|
|
|
* Subclasses may override this to provide a different rendering for the diff,
|
|
|
|
|
* perhaps taking advantage of the content's native form. This is required for all content
|
|
|
|
|
* models that are not text based.
|
2012-06-12 09:12:19 +00:00
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @since 1.21
|
|
|
|
|
*
|
|
|
|
|
* @param Content $old Old content
|
|
|
|
|
* @param Content $new New content
|
2012-06-12 09:12:19 +00:00
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @throws MWException If old or new content is not an instance of TextContent.
|
2012-12-09 03:12:12 +00:00
|
|
|
* @return bool|string
|
2012-06-12 09:12:19 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function generateContentDiffBody( Content $old, Content $new ) {
|
2012-08-21 14:26:14 +00:00
|
|
|
if ( !( $old instanceof TextContent ) ) {
|
2013-11-20 19:11:57 +00:00
|
|
|
throw new MWException( "Diff not implemented for " . get_class( $old ) . "; " .
|
|
|
|
|
"override generateContentDiffBody to fix this." );
|
2012-08-21 14:26:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !( $new instanceof TextContent ) ) {
|
|
|
|
|
throw new MWException( "Diff not implemented for " . get_class( $new ) . "; "
|
|
|
|
|
. "override generateContentDiffBody to fix this." );
|
|
|
|
|
}
|
2012-06-12 09:12:19 +00:00
|
|
|
|
|
|
|
|
$otext = $old->serialize();
|
|
|
|
|
$ntext = $new->serialize();
|
|
|
|
|
|
|
|
|
|
return $this->generateTextDiffBody( $otext, $ntext );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a diff, no caching
|
|
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param string $otext Old text, must be already segmented
|
|
|
|
|
* @param string $ntext New text, must be already segmented
|
|
|
|
|
*
|
2012-12-09 03:12:12 +00:00
|
|
|
* @return bool|string
|
2012-10-05 13:03:24 +00:00
|
|
|
* @deprecated since 1.21, use generateContentDiffBody() instead!
|
2012-06-12 09:12:19 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function generateDiffBody( $otext, $ntext ) {
|
2012-10-11 15:36:42 +00:00
|
|
|
ContentHandler::deprecated( __METHOD__, "1.21" );
|
2012-06-12 09:12:19 +00:00
|
|
|
|
|
|
|
|
return $this->generateTextDiffBody( $otext, $ntext );
|
|
|
|
|
}
|
2012-03-27 14:07:42 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Generate a diff, no caching
|
|
|
|
|
*
|
2012-06-12 09:12:19 +00:00
|
|
|
* @todo move this to TextDifferenceEngine, make DifferenceEngine abstract. At some point.
|
|
|
|
|
*
|
2014-07-24 17:42:45 +00:00
|
|
|
* @param string $otext Old text, must be already segmented
|
|
|
|
|
* @param string $ntext New text, must be already segmented
|
2014-03-03 17:08:05 +00:00
|
|
|
*
|
2012-02-09 21:33:27 +00:00
|
|
|
* @return bool|string
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function generateTextDiffBody( $otext, $ntext ) {
|
2016-03-04 22:41:50 +00:00
|
|
|
$time = microtime( true );
|
|
|
|
|
|
|
|
|
|
$result = $this->textDiff( $otext, $ntext );
|
|
|
|
|
|
2016-03-11 21:11:43 +00:00
|
|
|
$time = intval( ( microtime( true ) - $time ) * 1000 );
|
|
|
|
|
$this->getStats()->timing( 'diff_time', $time );
|
|
|
|
|
// Log requests slower than 99th percentile
|
|
|
|
|
if ( $time > 100 && $this->mOldPage && $this->mNewPage ) {
|
|
|
|
|
wfDebugLog( 'diff',
|
|
|
|
|
"$time ms diff: {$this->mOldid} -> {$this->mNewid} {$this->mNewPage}" );
|
|
|
|
|
}
|
2016-03-04 22:41:50 +00:00
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates diff, to be wrapped internally in a logging/instrumentation
|
|
|
|
|
*
|
|
|
|
|
* @param string $otext Old text, must be already segmented
|
|
|
|
|
* @param string $ntext New text, must be already segmented
|
|
|
|
|
* @return bool|string
|
|
|
|
|
*/
|
|
|
|
|
protected function textDiff( $otext, $ntext ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
global $wgExternalDiffEngine, $wgContLang;
|
2007-11-27 21:36:43 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
$otext = str_replace( "\r\n", "\n", $otext );
|
|
|
|
|
$ntext = str_replace( "\r\n", "\n", $ntext );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2016-03-04 07:04:30 +00:00
|
|
|
if ( $wgExternalDiffEngine == 'wikidiff' ) {
|
|
|
|
|
wfDeprecated( 'wikidiff support', '1.27' );
|
|
|
|
|
$wgExternalDiffEngine = false;
|
2008-08-05 19:40:29 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2016-03-04 19:21:53 +00:00
|
|
|
if ( $wgExternalDiffEngine == 'wikidiff2' ) {
|
|
|
|
|
if ( function_exists( 'wikidiff2_do_diff' ) ) {
|
|
|
|
|
# Better external diff engine, the 2 may some day be dropped
|
|
|
|
|
# This one does the escaping and segmenting itself
|
|
|
|
|
$text = wikidiff2_do_diff( $otext, $ntext, 2 );
|
|
|
|
|
$text .= $this->debug( 'wikidiff2' );
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
# Diff via the shell
|
2012-05-26 03:19:55 +00:00
|
|
|
$tmpDir = wfTempDir();
|
|
|
|
|
$tempName1 = tempnam( $tmpDir, 'diff_' );
|
|
|
|
|
$tempName2 = tempnam( $tmpDir, 'diff_' );
|
2010-11-07 16:28:11 +00:00
|
|
|
|
|
|
|
|
$tempFile1 = fopen( $tempName1, "w" );
|
|
|
|
|
if ( !$tempFile1 ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$tempFile2 = fopen( $tempName2, "w" );
|
|
|
|
|
if ( !$tempFile2 ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
fwrite( $tempFile1, $otext );
|
|
|
|
|
fwrite( $tempFile2, $ntext );
|
|
|
|
|
fclose( $tempFile1 );
|
|
|
|
|
fclose( $tempFile2 );
|
|
|
|
|
$cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 );
|
|
|
|
|
$difftext = wfShellExec( $cmd );
|
|
|
|
|
$difftext .= $this->debug( "external $wgExternalDiffEngine" );
|
|
|
|
|
unlink( $tempName1 );
|
|
|
|
|
unlink( $tempName2 );
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return $difftext;
|
2004-08-30 23:17:04 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# Native PHP diff
|
|
|
|
|
$ota = explode( "\n", $wgContLang->segmentForDiff( $otext ) );
|
|
|
|
|
$nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
|
|
|
|
|
$diffs = new Diff( $ota, $nta );
|
|
|
|
|
$formatter = new TableDiffFormatter();
|
2014-12-17 17:41:27 +00:00
|
|
|
$difftext = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) );
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2011-02-10 16:04:19 +00:00
|
|
|
return $difftext;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Generate a debug comment indicating diff generating time,
|
|
|
|
|
* server node, and generator backend.
|
2013-10-29 23:43:53 +00:00
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param string $generator : What diff engine was used
|
2013-10-29 23:43:53 +00:00
|
|
|
*
|
2012-02-09 21:33:27 +00:00
|
|
|
* @return string
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2010-11-27 19:01:51 +00:00
|
|
|
protected function debug( $generator = "internal" ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
global $wgShowHostnames;
|
|
|
|
|
if ( !$this->enableDebugComment ) {
|
|
|
|
|
return '';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$data = [ $generator ];
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $wgShowHostnames ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$data[] = wfHostname();
|
|
|
|
|
}
|
|
|
|
|
$data[] = wfTimestamp( TS_DB );
|
2013-11-20 19:11:57 +00:00
|
|
|
|
|
|
|
|
return "<!-- diff generator: " .
|
2013-11-21 18:30:01 +00:00
|
|
|
implode( " ", array_map( "htmlspecialchars", $data ) ) .
|
2013-11-20 19:11:57 +00:00
|
|
|
" -->\n";
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Replace line numbers with the text in the user's language
|
2013-10-29 23:43:53 +00:00
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param string $text
|
2013-10-29 23:43:53 +00:00
|
|
|
*
|
2012-02-09 21:33:27 +00:00
|
|
|
* @return mixed
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function localiseLineNumbers( $text ) {
|
2013-11-20 19:11:57 +00:00
|
|
|
return preg_replace_callback(
|
|
|
|
|
'/<!--LINE (\d+)-->/',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ &$this, 'localiseLineNumbersCb' ],
|
2013-11-20 19:11:57 +00:00
|
|
|
$text
|
|
|
|
|
);
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-25 08:23:32 +00:00
|
|
|
public function localiseLineNumbersCb( $matches ) {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $matches[1] === '1' && $this->mReducedLineNumbers ) {
|
2013-04-17 14:52:47 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
return $this->msg( 'lineno' )->numParams( $matches[1] )->escaped();
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2006-10-03 13:00:52 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* If there are revisions between the ones being compared, return a note saying so.
|
2014-03-03 17:08:05 +00:00
|
|
|
*
|
2010-11-18 00:08:37 +00:00
|
|
|
* @return string
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function getMultiNotice() {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( !is_object( $this->mOldRev ) || !is_object( $this->mNewRev ) ) {
|
2010-11-18 00:08:37 +00:00
|
|
|
return '';
|
2013-11-11 16:35:19 +00:00
|
|
|
} elseif ( !$this->mOldPage->equals( $this->mNewPage ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
// Comparing two different pages? Count would be meaningless.
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev->getTimestamp() > $this->mNewRev->getTimestamp() ) {
|
|
|
|
|
$oldRev = $this->mNewRev; // flip
|
|
|
|
|
$newRev = $this->mOldRev; // flip
|
2011-04-05 23:28:39 +00:00
|
|
|
} else { // normal case
|
2013-11-11 16:35:19 +00:00
|
|
|
$oldRev = $this->mOldRev;
|
|
|
|
|
$newRev = $this->mNewRev;
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2005-08-31 02:22:05 +00:00
|
|
|
|
2014-04-07 22:18:19 +00:00
|
|
|
// Sanity: don't show the notice if too many rows must be scanned
|
2014-07-23 20:04:48 +00:00
|
|
|
// @todo show some special message for that case
|
2014-04-07 22:18:19 +00:00
|
|
|
$nEdits = $this->mNewPage->countRevisionsBetween( $oldRev, $newRev, 1000 );
|
|
|
|
|
if ( $nEdits > 0 && $nEdits <= 1000 ) {
|
2011-04-05 23:28:39 +00:00
|
|
|
$limit = 100; // use diff-multi-manyusers if too many users
|
2014-01-08 20:29:42 +00:00
|
|
|
$users = $this->mNewPage->getAuthorsBetween( $oldRev, $newRev, $limit );
|
|
|
|
|
$numUsers = count( $users );
|
2014-02-05 11:02:29 +00:00
|
|
|
|
2014-12-09 19:16:50 +00:00
|
|
|
if ( $numUsers == 1 && $users[0] == $newRev->getUserText( Revision::RAW ) ) {
|
2014-01-08 20:29:42 +00:00
|
|
|
$numUsers = 0; // special case to say "by the same user" instead of "by one other user"
|
|
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-18 00:08:37 +00:00
|
|
|
return self::intermediateEditsMsg( $nEdits, $numUsers, $limit );
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2010-11-18 00:08:37 +00:00
|
|
|
return ''; // nothing
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-18 00:08:37 +00:00
|
|
|
/**
|
|
|
|
|
* Get a notice about how many intermediate edits and users there are
|
2014-03-03 17:08:05 +00:00
|
|
|
*
|
|
|
|
|
* @param int $numEdits
|
|
|
|
|
* @param int $numUsers
|
|
|
|
|
* @param int $limit
|
|
|
|
|
*
|
2010-11-18 00:08:37 +00:00
|
|
|
* @return string
|
2010-11-27 19:01:51 +00:00
|
|
|
*/
|
2010-11-18 00:08:37 +00:00
|
|
|
public static function intermediateEditsMsg( $numEdits, $numUsers, $limit ) {
|
2014-01-08 20:29:42 +00:00
|
|
|
if ( $numUsers === 0 ) {
|
|
|
|
|
$msg = 'diff-multi-sameuser';
|
|
|
|
|
} elseif ( $numUsers > $limit ) {
|
2010-11-18 00:08:37 +00:00
|
|
|
$msg = 'diff-multi-manyusers';
|
|
|
|
|
$numUsers = $limit;
|
|
|
|
|
} else {
|
2014-01-08 20:29:42 +00:00
|
|
|
$msg = 'diff-multi-otherusers';
|
2010-11-18 00:08:37 +00:00
|
|
|
}
|
2013-11-20 19:11:57 +00:00
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
return wfMessage( $msg )->numParams( $numEdits, $numUsers )->parse();
|
2010-11-18 00:08:37 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
|
|
|
|
* Get a header for a specified revision.
|
|
|
|
|
*
|
2014-03-03 17:08:05 +00:00
|
|
|
* @param Revision $rev
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $complete 'complete' to get the header wrapped depending
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
* the visibility of the revision and a link to edit the page.
|
2014-03-03 17:08:05 +00:00
|
|
|
*
|
|
|
|
|
* @return string HTML fragment
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
*/
|
2012-06-18 14:57:22 +00:00
|
|
|
protected function getRevisionHeader( Revision $rev, $complete = '' ) {
|
2011-11-21 16:13:21 +00:00
|
|
|
$lang = $this->getLanguage();
|
2011-11-10 13:06:52 +00:00
|
|
|
$user = $this->getUser();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$revtimestamp = $rev->getTimestamp();
|
2011-11-10 13:06:52 +00:00
|
|
|
$timestamp = $lang->userTimeAndDate( $revtimestamp, $user );
|
|
|
|
|
$dateofrev = $lang->userDate( $revtimestamp, $user );
|
|
|
|
|
$timeofrev = $lang->userTime( $revtimestamp, $user );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$header = $this->msg(
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$rev->isCurrent() ? 'currentrev-asof' : 'revisionasof',
|
|
|
|
|
$timestamp,
|
|
|
|
|
$dateofrev,
|
|
|
|
|
$timeofrev
|
2011-11-10 13:06:52 +00:00
|
|
|
)->escaped();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( $complete !== 'complete' ) {
|
|
|
|
|
return $header;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$title = $rev->getTitle();
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$header = Linker::linkKnown( $title, $header, [],
|
|
|
|
|
[ 'oldid' => $rev->getID() ] );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$editQuery = [ 'action' => 'edit' ];
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( !$rev->isCurrent() ) {
|
|
|
|
|
$editQuery['oldid'] = $rev->getID();
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-04 13:43:09 +00:00
|
|
|
$key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';
|
|
|
|
|
$msg = $this->msg( $key )->escaped();
|
2014-07-05 17:57:37 +00:00
|
|
|
$editLink = $this->msg( 'parentheses' )->rawParams(
|
2016-02-17 09:09:32 +00:00
|
|
|
Linker::linkKnown( $title, $msg, [], $editQuery ) )->escaped();
|
2014-07-05 17:57:37 +00:00
|
|
|
$header .= ' ' . Html::rawElement(
|
|
|
|
|
'span',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => 'mw-diff-edit' ],
|
2014-07-05 17:57:37 +00:00
|
|
|
$editLink
|
|
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
|
2013-10-04 13:43:09 +00:00
|
|
|
$header = Html::rawElement(
|
|
|
|
|
'span',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => 'history-deleted' ],
|
2013-10-04 13:43:09 +00:00
|
|
|
$header
|
|
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2016-02-17 09:09:32 +00:00
|
|
|
$header = Html::rawElement( 'span', [ 'class' => 'history-deleted' ], $header );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $header;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Add the header to a diff body
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
2013-11-20 19:11:57 +00:00
|
|
|
* @param string $diff Diff body
|
|
|
|
|
* @param string $otitle Old revision header
|
|
|
|
|
* @param string $ntitle New revision header
|
2013-11-20 19:22:36 +00:00
|
|
|
* @param string $multi Notice telling user that there are intermediate
|
|
|
|
|
* revisions between the ones being compared
|
2013-11-20 19:11:57 +00:00
|
|
|
* @param string $notice Other notices, e.g. that user is viewing deleted content
|
2013-10-29 23:43:53 +00:00
|
|
|
*
|
2011-06-01 16:27:46 +00:00
|
|
|
* @return string
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) {
|
2011-07-23 19:03:54 +00:00
|
|
|
// shared.css sets diff in interface language/dir, but the actual content
|
|
|
|
|
// is often in a different language, mostly the page content language/dir
|
2016-02-17 09:09:32 +00:00
|
|
|
$header = Html::openElement( 'table', [
|
|
|
|
|
'class' => [ 'diff', 'diff-contentalign-' . $this->getDiffLang()->alignStart() ],
|
2015-12-03 12:12:25 +00:00
|
|
|
'data-mw' => 'interface',
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2015-04-17 21:49:52 +00:00
|
|
|
$userLang = htmlspecialchars( $this->getLanguage()->getHtmlCode() );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( !$diff && !$otitle ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$header .= "
|
2015-04-17 21:49:52 +00:00
|
|
|
<tr style='vertical-align: top;' lang='{$userLang}'>
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
<td class='diff-ntitle'>{$ntitle}</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
$multiColspan = 1;
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( $diff ) { // Safari/Chrome show broken output if cols not used
|
|
|
|
|
$header .= "
|
|
|
|
|
<col class='diff-marker' />
|
|
|
|
|
<col class='diff-content' />
|
|
|
|
|
<col class='diff-marker' />
|
|
|
|
|
<col class='diff-content' />";
|
|
|
|
|
$colspan = 2;
|
|
|
|
|
$multiColspan = 4;
|
|
|
|
|
} else {
|
|
|
|
|
$colspan = 1;
|
|
|
|
|
$multiColspan = 2;
|
|
|
|
|
}
|
2013-06-10 17:43:47 +00:00
|
|
|
if ( $otitle || $ntitle ) {
|
|
|
|
|
$header .= "
|
2015-04-17 21:49:52 +00:00
|
|
|
<tr style='vertical-align: top;' lang='{$userLang}'>
|
2013-06-10 17:43:47 +00:00
|
|
|
<td colspan='$colspan' class='diff-otitle'>{$otitle}</td>
|
|
|
|
|
<td colspan='$colspan' class='diff-ntitle'>{$ntitle}</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
|
|
|
|
|
if ( $multi != '' ) {
|
2013-10-04 13:43:09 +00:00
|
|
|
$header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
|
2015-04-17 21:49:52 +00:00
|
|
|
"class='diff-multi' lang='{$userLang}'>{$multi}</td></tr>";
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
if ( $notice != '' ) {
|
2015-04-17 21:49:52 +00:00
|
|
|
$header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
|
|
|
|
|
"lang='{$userLang}'>{$notice}</td></tr>";
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return $header . $diff . "</table>";
|
2008-03-21 11:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Use specified text instead of loading from the database
|
2012-10-05 13:03:24 +00:00
|
|
|
* @deprecated since 1.21, use setContent() instead.
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function setText( $oldText, $newText ) {
|
2012-10-11 15:36:42 +00:00
|
|
|
ContentHandler::deprecated( __METHOD__, "1.21" );
|
2012-03-23 15:18:20 +00:00
|
|
|
|
2012-06-12 09:12:19 +00:00
|
|
|
$oldContent = ContentHandler::makeContent( $oldText, $this->getTitle() );
|
|
|
|
|
$newContent = ContentHandler::makeContent( $newText, $this->getTitle() );
|
2012-03-27 14:07:42 +00:00
|
|
|
|
2012-06-12 09:12:19 +00:00
|
|
|
$this->setContent( $oldContent, $newContent );
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2012-06-12 09:12:19 +00:00
|
|
|
/**
|
|
|
|
|
* Use specified text instead of loading from the database
|
2014-08-14 18:22:52 +00:00
|
|
|
* @param Content $oldContent
|
|
|
|
|
* @param Content $newContent
|
2012-10-05 13:03:24 +00:00
|
|
|
* @since 1.21
|
2012-06-12 09:12:19 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function setContent( Content $oldContent, Content $newContent ) {
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldContent = $oldContent;
|
|
|
|
|
$this->mNewContent = $newContent;
|
2012-03-23 15:18:20 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mTextLoaded = 2;
|
|
|
|
|
$this->mRevisionsLoaded = true;
|
2012-06-12 09:12:19 +00:00
|
|
|
}
|
2012-03-23 15:18:20 +00:00
|
|
|
|
2011-07-23 19:03:54 +00:00
|
|
|
/**
|
|
|
|
|
* Set the language in which the diff text is written
|
|
|
|
|
* (Defaults to page content language).
|
2014-08-14 18:22:52 +00:00
|
|
|
* @param Language|string $lang
|
2011-07-23 19:03:54 +00:00
|
|
|
* @since 1.19
|
|
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function setTextLanguage( $lang ) {
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mDiffLang = wfGetLangObj( $lang );
|
2011-07-23 19:03:54 +00:00
|
|
|
}
|
|
|
|
|
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
/**
|
|
|
|
|
* Maps a revision pair definition as accepted by DifferenceEngine constructor
|
|
|
|
|
* to a pair of actual integers representing revision ids.
|
|
|
|
|
*
|
|
|
|
|
* @param int $old Revision id, e.g. from URL parameter 'oldid'
|
|
|
|
|
* @param int|string $new Revision id or strings 'next' or 'prev', e.g. from URL parameter 'diff'
|
2014-03-03 17:08:05 +00:00
|
|
|
*
|
|
|
|
|
* @return int[] List of two revision ids, older first, later second.
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
* Zero signifies invalid argument passed.
|
|
|
|
|
* false signifies that there is no previous/next revision ($old is the oldest/newest one).
|
|
|
|
|
*/
|
|
|
|
|
public function mapDiffPrevNext( $old, $new ) {
|
|
|
|
|
if ( $new === 'prev' ) {
|
|
|
|
|
// Show diff between revision $old and the previous one. Get previous one from DB.
|
|
|
|
|
$newid = intval( $old );
|
|
|
|
|
$oldid = $this->getTitle()->getPreviousRevisionID( $newid );
|
|
|
|
|
} elseif ( $new === 'next' ) {
|
|
|
|
|
// Show diff between revision $old and the next one. Get next one from DB.
|
|
|
|
|
$oldid = intval( $old );
|
|
|
|
|
$newid = $this->getTitle()->getNextRevisionID( $oldid );
|
|
|
|
|
} else {
|
|
|
|
|
$oldid = intval( $old );
|
|
|
|
|
$newid = intval( $new );
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ $oldid, $newid ];
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
}
|
|
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
|
|
|
|
* Load revision IDs
|
|
|
|
|
*/
|
|
|
|
|
private function loadRevisionIds() {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mRevisionsIdsLoaded ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mRevisionsIdsLoaded = true;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$old = $this->mOldid;
|
|
|
|
|
$new = $this->mNewid;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
list( $this->mOldid, $this->mNewid ) = self::mapDiffPrevNext( $old, $new );
|
|
|
|
|
if ( $new === 'next' && $this->mNewid === false ) {
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
# if no result, NewId points to the newest old revision. The only newer
|
|
|
|
|
# revision is cur, which is "0".
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mNewid = 0;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
Correctly update wl_notificationtimestamp when viewing old revisions
== Prelude ==
wl_notificationtimestamp controls sending the user e-mail
notifications about changes to pages, as well as showing the "updated
since last visit" markers on history pages, recent changes and
watchlist.
== The bug ==
Previously, on every view of a page, the notification timestamp was
cleared, regardless of whether the user as actually viewing the latest
revision. When viewing a diff, however, the timestamp was cleared only
if one of the revisions being compared was the latest one of its page.
The same behavior applied to talk page message indicators (which are
actually stored sepately to cater to anonymous users).
This was inconsistent and surprising when one was attempting to, say,
go through the 50 new posts to a discussion page in a peacemeal
fashion.
== The fix ==
If the revision being viewed is the latest (or can't be determined),
the timestamp is cleared as previously, as this is necessary to
reenable e-mail notifications for given user and page.
If the revision isn't the latest, the timestamp is updated to
revision's timestamp plus one second. This uses up to two simple
(selectField) indexed queries per page view, only fired when we
do not already know we're looking at the latest version.
Talk page indicator is updated to point at the next revision after the
one being viewed, or cleared if viewing the latest revision. The
UserClearNewTalkNotification hook gained $oldid as the second argument
(a backwards-compatible change). In Skin, we no longer ignore the
indicator being present if we're viewing the talk page, as it might
still be valid.
== The bonus ==
Comments and formatting was updated in a few places, including
tables.sql and Wiki.php.
The following functions gained a second, optional $oldid parameter
(holy indirection, Batman!):
* WikiPage#doViewUpdates()
* User#clearNotification()
* WatchedItem#resetNotificationTimestamp()
DifferenceEngine gained a public method mapDiffPrevNext() used
to parse the ids from URL parameters like oldid=12345&diff=prev,
factored out of loadRevisionIds(). A bug where the NewDifferenceEngine
hook would not be called in some cases, dating back to its
introduction in r45518, was fixed in the process.
Bug: 41759
Change-Id: I4144ba1987b8d7a7e8b24f4f067eedac2ae44459
2013-09-16 10:31:40 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run(
|
2013-11-20 19:22:36 +00:00
|
|
|
'NewDifferenceEngine',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ $this->getTitle(), &$this->mOldid, &$this->mNewid, $old, $new ]
|
2013-11-20 19:22:36 +00:00
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Load revision metadata for the specified articles. If newid is 0, then compare
|
|
|
|
|
* the old article in oldid to the current article; if oldid is 0, then
|
|
|
|
|
* compare the current article to the immediately previous one (ignoring the
|
|
|
|
|
* value of newid).
|
|
|
|
|
*
|
|
|
|
|
* If oldid is false, leave the corresponding revision object set
|
|
|
|
|
* to false. This is impossible via ordinary user input, and is provided for
|
|
|
|
|
* API convenience.
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function loadRevisionData() {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mRevisionsLoaded ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
// Whether it succeeds or fails, we don't want to try again
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mRevisionsLoaded = true;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
$this->loadRevisionIds();
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Load the new revision object
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewid ) {
|
|
|
|
|
$this->mNewRev = Revision::newFromId( $this->mNewid );
|
2013-10-04 13:43:09 +00:00
|
|
|
} else {
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mNewRev = Revision::newFromTitle(
|
2013-10-04 13:43:09 +00:00
|
|
|
$this->getTitle(),
|
|
|
|
|
false,
|
|
|
|
|
Revision::READ_NORMAL
|
|
|
|
|
);
|
|
|
|
|
}
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( !$this->mNewRev instanceof Revision ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
2011-06-01 16:27:46 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Update the new revision ID in case it was 0 (makes life easier doing UI stuff)
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mNewid = $this->mNewRev->getId();
|
|
|
|
|
$this->mNewPage = $this->mNewRev->getTitle();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Load the old revision object
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldRev = false;
|
|
|
|
|
if ( $this->mOldid ) {
|
|
|
|
|
$this->mOldRev = Revision::newFromId( $this->mOldid );
|
|
|
|
|
} elseif ( $this->mOldid === 0 ) {
|
|
|
|
|
$rev = $this->mNewRev->getPrevious();
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $rev ) {
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldid = $rev->getId();
|
|
|
|
|
$this->mOldRev = $rev;
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
|
|
|
|
// No previous revision; mark to show as first-version only.
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldid = false;
|
|
|
|
|
$this->mOldRev = false;
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2013-11-11 16:35:19 +00:00
|
|
|
} /* elseif ( $this->mOldid === false ) leave mOldRev false; */
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( is_null( $this->mOldRev ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev ) {
|
|
|
|
|
$this->mOldPage = $this->mOldRev->getTitle();
|
2007-05-16 17:57:00 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2013-07-06 20:53:27 +00:00
|
|
|
// Load tags information for both revisions
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldid !== false ) {
|
|
|
|
|
$this->mOldTags = $dbr->selectField(
|
2013-07-06 20:53:27 +00:00
|
|
|
'tag_summary',
|
|
|
|
|
'ts_tags',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'ts_rev_id' => $this->mOldid ],
|
2013-07-06 20:53:27 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mOldTags = false;
|
2013-07-06 20:53:27 +00:00
|
|
|
}
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mNewTags = $dbr->selectField(
|
2013-07-06 20:53:27 +00:00
|
|
|
'tag_summary',
|
|
|
|
|
'ts_tags',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'ts_rev_id' => $this->mNewid ],
|
2013-07-06 20:53:27 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Load the text of the revisions, as well as revision data.
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function loadText() {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mTextLoaded == 2 ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2013-08-25 07:26:20 +00:00
|
|
|
// Whether it succeeds or fails, we don't want to try again
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mTextLoaded = 2;
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( !$this->loadRevisionData() ) {
|
|
|
|
|
return false;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mOldRev ) {
|
|
|
|
|
$this->mOldContent = $this->mOldRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
|
|
|
|
|
if ( $this->mOldContent === null ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mNewRev ) {
|
|
|
|
|
$this->mNewContent = $this->mNewRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
|
|
|
|
|
if ( $this->mNewContent === null ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Load the text of the new revision, not the old one
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2014-02-25 08:23:32 +00:00
|
|
|
public function loadNewText() {
|
2013-11-11 16:35:19 +00:00
|
|
|
if ( $this->mTextLoaded >= 1 ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mTextLoaded = 1;
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( !$this->loadRevisionData() ) {
|
|
|
|
|
return false;
|
2004-08-30 23:45:05 +00:00
|
|
|
}
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2013-11-11 16:35:19 +00:00
|
|
|
$this->mNewContent = $this->mNewRev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
|
2013-08-25 07:26:20 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2014-03-03 17:08:05 +00:00
|
|
|
|
2008-09-24 09:44:45 +00:00
|
|
|
}
|