2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2012-05-22 18:06:30 +00:00
|
|
|
* User interface for page actions.
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*
|
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
|
|
|
* @file
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Class for viewing MediaWiki article and history.
|
|
|
|
|
*
|
|
|
|
|
* This maintains WikiPage functions for backwards compatibility.
|
|
|
|
|
*
|
2013-05-15 01:12:35 +00:00
|
|
|
* @todo Move and rewrite code to an Action class
|
2004-09-02 23:28:24 +00:00
|
|
|
*
|
2005-04-12 02:07:16 +00:00
|
|
|
* See design.txt for an overview.
|
2004-09-02 23:28:24 +00:00
|
|
|
* Note: edit user interface and cache support functions have been
|
2006-10-11 08:25:26 +00:00
|
|
|
* moved to separate EditPage and HTMLFileCache classes.
|
2004-09-03 00:20:26 +00:00
|
|
|
*
|
2010-03-15 23:22:50 +00:00
|
|
|
* @internal documentation reviewed 15 Mar 2010
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2013-02-07 20:46:02 +00:00
|
|
|
class Article implements Page {
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var IContextSource The context this Article is executed in */
|
2011-04-25 11:59:31 +00:00
|
|
|
protected $mContext;
|
2011-04-12 23:00:49 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var WikiPage The WikiPage object of this instance */
|
2011-06-29 22:09:51 +00:00
|
|
|
protected $mPage;
|
|
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var ParserOptions ParserOptions object for $wgUser articles */
|
2011-09-29 17:54:19 +00:00
|
|
|
public $mParserOptions;
|
|
|
|
|
|
2012-04-15 00:12:01 +00:00
|
|
|
/**
|
2014-05-15 15:38:28 +00:00
|
|
|
* @var string Text of the revision we are working on
|
|
|
|
|
* @todo BC cruft
|
2012-04-15 00:12:01 +00:00
|
|
|
*/
|
2014-05-15 15:38:28 +00:00
|
|
|
public $mContent;
|
2012-04-11 10:49:43 +00:00
|
|
|
|
|
|
|
|
/**
|
2014-05-15 15:38:28 +00:00
|
|
|
* @var Content Content of the revision we are working on
|
2012-10-05 13:03:24 +00:00
|
|
|
* @since 1.21
|
2012-04-11 10:49:43 +00:00
|
|
|
*/
|
2014-08-02 23:48:54 +00:00
|
|
|
public $mContentObject;
|
2012-04-11 10:49:43 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var bool Is the content ($mContent) already loaded? */
|
2014-08-02 23:48:54 +00:00
|
|
|
public $mContentLoaded = false;
|
2012-04-15 00:12:01 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var int|null The oldid of the article that is to be shown, 0 for the current revision */
|
2014-08-02 23:48:54 +00:00
|
|
|
public $mOldId;
|
2011-04-25 11:59:31 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var Title Title from which we were redirected here */
|
2014-08-02 23:48:54 +00:00
|
|
|
public $mRedirectedFrom = null;
|
2011-04-25 11:59:31 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var string|bool URL to redirect to or false if none */
|
2014-08-02 23:48:54 +00:00
|
|
|
public $mRedirectUrl = false;
|
2012-04-15 00:12:01 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var int Revision ID of revision we are working on */
|
2014-08-02 23:48:54 +00:00
|
|
|
public $mRevIdFetched = 0;
|
2011-04-25 11:59:31 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var Revision Revision we are working on */
|
2014-08-02 23:48:54 +00:00
|
|
|
public $mRevision = null;
|
2011-04-25 11:59:31 +00:00
|
|
|
|
2014-05-15 15:38:28 +00:00
|
|
|
/** @var ParserOutput */
|
|
|
|
|
public $mParserOutput;
|
2004-09-02 23:28:24 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor and clear the article
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title Reference to a Title object.
|
|
|
|
|
* @param int $oldId Revision ID, null to fetch from request, zero for current
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function __construct( Title $title, $oldId = null ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mOldId = $oldId;
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->mPage = $this->newPage( $title );
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-05 13:43:32 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title
|
2011-10-05 13:43:32 +00:00
|
|
|
* @return WikiPage
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
protected function newPage( Title $title ) {
|
|
|
|
|
return new WikiPage( $title );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor from a page id
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param int $id Article ID to load
|
2011-10-29 01:17:26 +00:00
|
|
|
* @return Article|null
|
2011-06-29 22:09:51 +00:00
|
|
|
*/
|
|
|
|
|
public static function newFromID( $id ) {
|
|
|
|
|
$t = Title::newFromID( $id );
|
|
|
|
|
# @todo FIXME: Doesn't inherit right
|
|
|
|
|
return $t == null ? null : new self( $t );
|
|
|
|
|
# return $t == null ? null : new static( $t ); // PHP 5.3
|
2003-09-01 08:30:14 +00:00
|
|
|
}
|
2008-08-21 00:45:13 +00:00
|
|
|
|
2011-05-22 18:38:04 +00:00
|
|
|
/**
|
|
|
|
|
* Create an Article object of the appropriate class for the given page.
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title
|
|
|
|
|
* @param IContextSource $context
|
|
|
|
|
* @return Article
|
2011-05-22 18:38:04 +00:00
|
|
|
*/
|
2011-09-15 15:19:49 +00:00
|
|
|
public static function newFromTitle( $title, IContextSource $context ) {
|
2011-05-22 18:38:04 +00:00
|
|
|
if ( NS_MEDIA == $title->getNamespace() ) {
|
|
|
|
|
// FIXME: where should this go?
|
|
|
|
|
$title = Title::makeTitle( NS_FILE, $title->getDBkey() );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-28 03:51:00 +00:00
|
|
|
$page = null;
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'ArticleFromTitle', array( &$title, &$page, $context ) );
|
2011-06-28 03:51:00 +00:00
|
|
|
if ( !$page ) {
|
2013-04-26 14:42:31 +00:00
|
|
|
switch ( $title->getNamespace() ) {
|
2011-06-28 03:51:00 +00:00
|
|
|
case NS_FILE:
|
2012-05-23 06:53:01 +00:00
|
|
|
$page = new ImagePage( $title );
|
2011-06-28 03:51:00 +00:00
|
|
|
break;
|
|
|
|
|
case NS_CATEGORY:
|
2012-05-23 06:53:01 +00:00
|
|
|
$page = new CategoryPage( $title );
|
2011-06-28 03:51:00 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2012-05-23 06:53:01 +00:00
|
|
|
$page = new Article( $title );
|
2011-06-28 03:51:00 +00:00
|
|
|
}
|
2011-05-22 18:38:04 +00:00
|
|
|
}
|
|
|
|
|
$page->setContext( $context );
|
2011-06-28 03:51:00 +00:00
|
|
|
|
2011-05-22 18:38:04 +00:00
|
|
|
return $page;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 19:41:32 +00:00
|
|
|
/**
|
|
|
|
|
* Create an Article object of the appropriate class for the given page.
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param WikiPage $page
|
|
|
|
|
* @param IContextSource $context
|
|
|
|
|
* @return Article
|
2011-11-15 19:41:32 +00:00
|
|
|
*/
|
|
|
|
|
public static function newFromWikiPage( WikiPage $page, IContextSource $context ) {
|
|
|
|
|
$article = self::newFromTitle( $page->getTitle(), $context );
|
|
|
|
|
$article->mPage = $page; // override to keep process cached vars
|
|
|
|
|
return $article;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-13 00:29:20 +00:00
|
|
|
/**
|
|
|
|
|
* Tell the page view functions that this view was redirected
|
|
|
|
|
* from another page on the wiki.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $from
|
2006-01-13 00:29:20 +00:00
|
|
|
*/
|
2010-03-14 23:20:40 +00:00
|
|
|
public function setRedirectedFrom( Title $from ) {
|
2006-01-13 00:29:20 +00:00
|
|
|
$this->mRedirectedFrom = $from;
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2004-12-29 01:07:43 +00:00
|
|
|
/**
|
2010-06-28 07:17:16 +00:00
|
|
|
* Get the title object of the article
|
2012-01-06 20:00:04 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return Title Title object of this page
|
2004-12-29 01:07:43 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getTitle() {
|
2011-06-29 22:09:51 +00:00
|
|
|
return $this->mPage->getTitle();
|
2004-12-29 01:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-06 20:00:04 +00:00
|
|
|
/**
|
|
|
|
|
* Get the WikiPage object of this instance
|
|
|
|
|
*
|
|
|
|
|
* @since 1.19
|
|
|
|
|
* @return WikiPage
|
|
|
|
|
*/
|
|
|
|
|
public function getPage() {
|
|
|
|
|
return $this->mPage;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2008-11-30 10:10:15 +00:00
|
|
|
* Clear the object
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function clear() {
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->mContentLoaded = false;
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2006-01-13 00:29:20 +00:00
|
|
|
$this->mRedirectedFrom = null; # Title object if set
|
2005-03-29 16:38:30 +00:00
|
|
|
$this->mRevIdFetched = 0;
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mRedirectUrl = false;
|
2011-06-29 22:09:51 +00:00
|
|
|
|
|
|
|
|
$this->mPage->clear();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2006-01-13 00:29:20 +00:00
|
|
|
* Note that getContent/loadContent do not follow redirects anymore.
|
|
|
|
|
* If you need to fetch redirectable content easily, try
|
2012-01-08 17:34:28 +00:00
|
|
|
* the shortcut in WikiPage::getRedirectTarget()
|
2004-09-02 23:28:24 +00:00
|
|
|
*
|
2010-06-28 07:17:16 +00:00
|
|
|
* This function has side effects! Do not use this function if you
|
|
|
|
|
* only want the real revision text if any.
|
|
|
|
|
*
|
2014-04-15 20:18:19 +00:00
|
|
|
* @deprecated since 1.21; use WikiPage::getContent() instead
|
2012-04-11 10:49:43 +00:00
|
|
|
*
|
2012-02-09 18:01:54 +00:00
|
|
|
* @return string Return the text of this revision
|
2009-12-26 20:03:33 +00:00
|
|
|
*/
|
2012-03-05 17:09:41 +00:00
|
|
|
public function getContent() {
|
2012-10-11 15:36:42 +00:00
|
|
|
ContentHandler::deprecated( __METHOD__, '1.21' );
|
2012-04-05 09:51:24 +00:00
|
|
|
$content = $this->getContentObject();
|
|
|
|
|
return ContentHandler::getContentText( $content );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-04-16 06:49:38 +00:00
|
|
|
* Returns a Content object representing the pages effective display content,
|
2012-06-19 01:28:05 +00:00
|
|
|
* not necessarily the revision's content!
|
|
|
|
|
*
|
|
|
|
|
* Note that getContent/loadContent do not follow redirects anymore.
|
2012-04-05 09:51:24 +00:00
|
|
|
* If you need to fetch redirectable content easily, try
|
|
|
|
|
* the shortcut in WikiPage::getRedirectTarget()
|
|
|
|
|
*
|
|
|
|
|
* This function has side effects! Do not use this function if you
|
|
|
|
|
* only want the real revision text if any.
|
|
|
|
|
*
|
2012-05-14 21:24:18 +00:00
|
|
|
* @return Content Return the content of this revision
|
2012-04-26 11:24:13 +00:00
|
|
|
*
|
2012-10-05 13:03:24 +00:00
|
|
|
* @since 1.21
|
2012-04-05 09:51:24 +00:00
|
|
|
*/
|
2012-10-08 15:26:11 +00:00
|
|
|
protected function getContentObject() {
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mPage->getID() === 0 ) {
|
2008-11-28 14:29:25 +00:00
|
|
|
# If this is a MediaWiki:x message, then load the messages
|
|
|
|
|
# and return the message value for x.
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) {
|
|
|
|
|
$text = $this->getTitle()->getDefaultMessageText();
|
2011-02-03 15:29:13 +00:00
|
|
|
if ( $text === false ) {
|
2008-11-28 18:37:31 +00:00
|
|
|
$text = '';
|
2011-02-03 15:29:13 +00:00
|
|
|
}
|
2012-04-05 09:51:24 +00:00
|
|
|
|
|
|
|
|
$content = ContentHandler::makeContent( $text, $this->getTitle() );
|
2005-12-28 14:47:30 +00:00
|
|
|
} else {
|
2012-08-20 14:55:28 +00:00
|
|
|
$message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
|
|
|
|
|
$content = new MessageContent( $message, null, 'parsemag' );
|
2005-12-28 14:47:30 +00:00
|
|
|
}
|
2005-07-03 04:00:33 +00:00
|
|
|
} else {
|
2012-03-05 15:53:25 +00:00
|
|
|
$this->fetchContentObject();
|
2013-01-09 13:25:49 +00:00
|
|
|
$content = $this->mContentObject;
|
2004-05-13 12:20:59 +00:00
|
|
|
}
|
2013-01-09 13:25:49 +00:00
|
|
|
|
|
|
|
|
return $content;
|
2004-05-13 12:20:59 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return int The oldid of the article that is to be shown, 0 for the current revision
|
2004-11-13 08:40:34 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getOldID() {
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( is_null( $this->mOldId ) ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mOldId = $this->getOldIDFromRequest();
|
2004-11-13 08:40:34 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2005-12-30 09:33:11 +00:00
|
|
|
return $this->mOldId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
|
2006-01-07 12:10:04 +00:00
|
|
|
*
|
|
|
|
|
* @return int The old id for the request
|
2005-12-30 09:33:11 +00:00
|
|
|
*/
|
2008-08-26 00:32:55 +00:00
|
|
|
public function getOldIDFromRequest() {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mRedirectUrl = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$request = $this->getContext()->getRequest();
|
|
|
|
|
$oldid = $request->getIntOrNull( 'oldid' );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $oldid === null ) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $oldid !== 0 ) {
|
|
|
|
|
# Load the given revision and check whether the page is another one.
|
|
|
|
|
# In that case, update this instance to reflect the change.
|
2012-03-09 14:50:39 +00:00
|
|
|
if ( $oldid === $this->mPage->getLatest() ) {
|
|
|
|
|
$this->mRevision = $this->mPage->getRevision();
|
|
|
|
|
} else {
|
|
|
|
|
$this->mRevision = Revision::newFromId( $oldid );
|
|
|
|
|
if ( $this->mRevision !== null ) {
|
|
|
|
|
// Revision title doesn't match the page title given?
|
|
|
|
|
if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
|
|
|
|
|
$function = array( get_class( $this->mPage ), 'newFromID' );
|
|
|
|
|
$this->mPage = call_user_func( $function, $this->mRevision->getPage() );
|
|
|
|
|
}
|
2004-10-02 21:36:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
if ( $request->getVal( 'direction' ) == 'next' ) {
|
2011-11-14 18:05:55 +00:00
|
|
|
$nextid = $this->getTitle()->getNextRevisionID( $oldid );
|
|
|
|
|
if ( $nextid ) {
|
|
|
|
|
$oldid = $nextid;
|
2012-01-29 19:05:04 +00:00
|
|
|
$this->mRevision = null;
|
2011-11-14 18:05:55 +00:00
|
|
|
} else {
|
|
|
|
|
$this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
|
|
|
|
|
}
|
2012-04-22 23:42:38 +00:00
|
|
|
} elseif ( $request->getVal( 'direction' ) == 'prev' ) {
|
2011-11-14 18:05:55 +00:00
|
|
|
$previd = $this->getTitle()->getPreviousRevisionID( $oldid );
|
|
|
|
|
if ( $previd ) {
|
|
|
|
|
$oldid = $previd;
|
2012-01-29 19:05:04 +00:00
|
|
|
$this->mRevision = null;
|
2011-11-14 18:05:55 +00:00
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2005-12-30 09:33:11 +00:00
|
|
|
return $oldid;
|
2004-11-13 08:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2005-12-30 09:33:11 +00:00
|
|
|
* Load the revision (including text) into this object
|
2011-11-14 18:05:55 +00:00
|
|
|
*
|
2014-04-15 20:18:19 +00:00
|
|
|
* @deprecated since 1.19; use fetchContent()
|
2004-12-19 08:00:50 +00:00
|
|
|
*/
|
2006-01-13 00:29:20 +00:00
|
|
|
function loadContent() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.19' );
|
2011-11-14 18:05:55 +00:00
|
|
|
$this->fetchContent();
|
2004-12-19 08:00:50 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-12-19 08:00:50 +00:00
|
|
|
/**
|
2005-01-11 01:28:18 +00:00
|
|
|
* Get text of an article from database
|
2006-01-13 00:29:20 +00:00
|
|
|
* Does *NOT* follow redirects.
|
2010-05-30 14:28:54 +00:00
|
|
|
*
|
2012-05-24 10:01:19 +00:00
|
|
|
* @protected
|
2014-03-23 01:28:57 +00:00
|
|
|
* @note This is really internal functionality that should really NOT be
|
|
|
|
|
* used by other functions. For accessing article content, use the WikiPage
|
|
|
|
|
* class, especially WikiBase::getContent(). However, a lot of legacy code
|
|
|
|
|
* uses this method to retrieve page text from the database, so the function
|
|
|
|
|
* has to remain public for now.
|
2012-05-24 10:01:19 +00:00
|
|
|
*
|
2014-04-23 11:39:49 +00:00
|
|
|
* @return string|bool String containing article contents, or false if null
|
2014-04-15 20:18:19 +00:00
|
|
|
* @deprecated since 1.21, use WikiPage::getContent() instead
|
2004-12-19 08:00:50 +00:00
|
|
|
*/
|
2012-05-24 10:01:19 +00:00
|
|
|
function fetchContent() { #BC cruft!
|
2012-10-11 15:36:42 +00:00
|
|
|
ContentHandler::deprecated( __METHOD__, '1.21' );
|
2012-03-05 15:53:25 +00:00
|
|
|
|
|
|
|
|
if ( $this->mContentLoaded && $this->mContent ) {
|
2004-12-19 08:00:50 +00:00
|
|
|
return $this->mContent;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
$content = $this->fetchContentObject();
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2014-05-01 14:12:25 +00:00
|
|
|
if ( !$content ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-15 01:12:35 +00:00
|
|
|
// @todo Get rid of mContent everywhere!
|
|
|
|
|
$this->mContent = ContentHandler::getContentText( $content );
|
2012-08-20 17:28:20 +00:00
|
|
|
ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
|
2005-12-21 12:02:18 +00:00
|
|
|
|
2004-03-23 10:11:24 +00:00
|
|
|
return $this->mContent;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
/**
|
|
|
|
|
* Get text content object
|
|
|
|
|
* Does *NOT* follow redirects.
|
2014-03-23 01:28:57 +00:00
|
|
|
* @todo When is this null?
|
2012-04-05 09:51:24 +00:00
|
|
|
*
|
2014-03-23 01:28:57 +00:00
|
|
|
* @note Code that wants to retrieve page content from the database should
|
|
|
|
|
* use WikiPage::getContent().
|
2012-05-24 10:01:19 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return Content|null|bool
|
2012-04-26 11:24:13 +00:00
|
|
|
*
|
2012-10-05 13:03:24 +00:00
|
|
|
* @since 1.21
|
2012-04-05 09:51:24 +00:00
|
|
|
*/
|
|
|
|
|
protected function fetchContentObject() {
|
|
|
|
|
if ( $this->mContentLoaded ) {
|
|
|
|
|
return $this->mContentObject;
|
|
|
|
|
}
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
$this->mContentLoaded = true;
|
|
|
|
|
$this->mContent = null;
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
$oldid = $this->getOldID();
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
# Pre-fill content with error message so that if something
|
|
|
|
|
# fails we'll have something telling us what we intended.
|
2012-09-13 14:21:54 +00:00
|
|
|
//XXX: this isn't page content but a UI message. horrible.
|
2013-02-09 21:44:24 +00:00
|
|
|
$this->mContentObject = new MessageContent( 'missing-revision', array( $oldid ), array() );
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
if ( $oldid ) {
|
|
|
|
|
# $this->mRevision might already be fetched by getOldIDFromRequest()
|
|
|
|
|
if ( !$this->mRevision ) {
|
|
|
|
|
$this->mRevision = Revision::newFromId( $oldid );
|
|
|
|
|
if ( !$this->mRevision ) {
|
|
|
|
|
wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ( !$this->mPage->getLatest() ) {
|
2014-03-23 01:28:57 +00:00
|
|
|
wfDebug( __METHOD__ . " failed to find page data for title " .
|
|
|
|
|
$this->getTitle()->getPrefixedText() . "\n" );
|
2012-04-05 09:51:24 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
$this->mRevision = $this->mPage->getRevision();
|
2012-03-06 17:35:46 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
if ( !$this->mRevision ) {
|
2014-03-23 01:28:57 +00:00
|
|
|
wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " .
|
|
|
|
|
$this->mPage->getLatest() . "\n" );
|
2012-04-05 09:51:24 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
// @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
|
|
|
|
|
// We should instead work with the Revision object when we need it...
|
2014-03-23 01:28:57 +00:00
|
|
|
// Loads if user is allowed
|
2014-09-15 09:44:35 +00:00
|
|
|
$content = $this->mRevision->getContent(
|
2014-03-23 01:28:57 +00:00
|
|
|
Revision::FOR_THIS_USER,
|
|
|
|
|
$this->getContext()->getUser()
|
|
|
|
|
);
|
2014-09-15 09:44:35 +00:00
|
|
|
|
|
|
|
|
if ( !$content ) {
|
|
|
|
|
wfDebug( __METHOD__ . " failed to retrieve content of revision " .
|
|
|
|
|
$this->mRevision->getId() . "\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->mContentObject = $content;
|
2012-04-05 09:51:24 +00:00
|
|
|
$this->mRevIdFetched = $this->mRevision->getId();
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) );
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
return $this->mContentObject;
|
|
|
|
|
}
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Returns true if the currently-referenced revision is the current edit
|
|
|
|
|
* to this page (and it exists).
|
|
|
|
|
* @return bool
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function isCurrent() {
|
|
|
|
|
# If no oldid, this is the current version.
|
|
|
|
|
if ( $this->getOldID() == 0 ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-07-01 20:36:04 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
|
2005-06-29 23:44:03 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2011-12-30 16:12:46 +00:00
|
|
|
/**
|
|
|
|
|
* Get the fetched Revision object depending on request parameters or null
|
|
|
|
|
* on failure.
|
|
|
|
|
*
|
2012-01-05 19:05:02 +00:00
|
|
|
* @since 1.19
|
2011-12-30 16:12:46 +00:00
|
|
|
* @return Revision|null
|
|
|
|
|
*/
|
|
|
|
|
public function getRevisionFetched() {
|
2012-03-05 17:09:41 +00:00
|
|
|
$this->fetchContentObject();
|
2011-12-30 16:12:46 +00:00
|
|
|
|
|
|
|
|
return $this->mRevision;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-22 23:38:58 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Use this to fetch the rev ID used on page views
|
2008-12-22 23:38:58 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return int Revision ID of last article revision
|
2008-12-22 23:38:58 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function getRevIdFetched() {
|
|
|
|
|
if ( $this->mRevIdFetched ) {
|
|
|
|
|
return $this->mRevIdFetched;
|
|
|
|
|
} else {
|
|
|
|
|
return $this->mPage->getLatest();
|
|
|
|
|
}
|
2008-12-22 23:38:58 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-11 11:39:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* This is the default action of the index.php entry point: just view the
|
|
|
|
|
* page of the given title.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function view() {
|
2014-07-11 14:05:36 +00:00
|
|
|
global $wgUseFileCache, $wgUseETag, $wgDebugToolbar, $wgMaxRedirects;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# Get variables from query string
|
2011-11-14 18:05:55 +00:00
|
|
|
# As side effect this will load the revision and update the title
|
|
|
|
|
# in a revision ID is passed in the request, so this should remain
|
|
|
|
|
# the first call of this method even if $oldid is used way below.
|
2011-06-29 22:09:51 +00:00
|
|
|
$oldid = $this->getOldID();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$user = $this->getContext()->getUser();
|
2011-11-14 18:05:55 +00:00
|
|
|
# Another whitelist check in case getOldID() is altering the title
|
2012-04-22 23:42:38 +00:00
|
|
|
$permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $user );
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( count( $permErrors ) ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": denied on secondary read check\n" );
|
|
|
|
|
throw new PermissionsError( 'read', $permErrors );
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
2011-11-14 18:05:55 +00:00
|
|
|
# getOldID() may as well want us to redirect somewhere else
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mRedirectUrl ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->redirect( $this->mRedirectUrl );
|
2011-06-29 22:09:51 +00:00
|
|
|
wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
|
2011-05-14 17:11:32 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
2011-05-14 17:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# If we got diff in the query, we want to see a diff page instead of the article.
|
2012-04-22 23:42:38 +00:00
|
|
|
if ( $this->getContext()->getRequest()->getCheck( 'diff' ) ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
wfDebug( __METHOD__ . ": showing diff page\n" );
|
|
|
|
|
$this->showDiffPage();
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
2011-05-14 17:11:32 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
# Set page title (may be overridden by DISPLAYTITLE)
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setPageTitle( $this->getTitle()->getPrefixedText() );
|
2011-11-14 18:05:55 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setArticleFlag( true );
|
2011-06-29 22:09:51 +00:00
|
|
|
# Allow frames by default
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->allowClickjacking();
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$parserCache = ParserCache::singleton();
|
2004-09-11 11:39:24 +00:00
|
|
|
|
2011-09-29 17:51:27 +00:00
|
|
|
$parserOptions = $this->getParserOptions();
|
2011-06-29 22:09:51 +00:00
|
|
|
# Render printable version, use printable version cache
|
2012-04-22 23:42:38 +00:00
|
|
|
if ( $outputPage->isPrintable() ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$parserOptions->setIsPrintable( true );
|
|
|
|
|
$parserOptions->setEditSection( false );
|
2012-06-11 09:31:38 +00:00
|
|
|
} elseif ( !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user ) ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$parserOptions->setEditSection( false );
|
2008-11-28 14:29:25 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# Try client and file cache
|
2011-12-04 18:29:57 +00:00
|
|
|
if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $wgUseETag ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setETag( $parserCache->getETag( $this, $parserOptions ) );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2005-07-01 20:36:04 +00:00
|
|
|
|
2014-07-11 14:05:36 +00:00
|
|
|
# Use the greatest of the page's timestamp or the timestamp of any
|
|
|
|
|
# redirect in the chain (bug 67849)
|
|
|
|
|
$timestamp = $this->mPage->getTouched();
|
|
|
|
|
if ( isset( $this->mRedirectedFrom ) ) {
|
|
|
|
|
$timestamp = max( $timestamp, $this->mRedirectedFrom->getTouched() );
|
|
|
|
|
|
|
|
|
|
# If there can be more than one redirect in the chain, we have
|
|
|
|
|
# to go through the whole chain too in case an intermediate
|
|
|
|
|
# redirect was changed.
|
|
|
|
|
if ( $wgMaxRedirects > 1 ) {
|
|
|
|
|
$titles = Revision::newFromTitle( $this->mRedirectedFrom )
|
|
|
|
|
->getContent( Revision::FOR_THIS_USER, $user )
|
|
|
|
|
->getRedirectChain();
|
|
|
|
|
$thisTitle = $this->getTitle();
|
|
|
|
|
foreach ( $titles as $title ) {
|
|
|
|
|
if ( Title::compare( $title, $thisTitle ) === 0 ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$timestamp = max( $timestamp, $title->getTouched() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# Is it client cached?
|
2014-07-11 14:05:36 +00:00
|
|
|
if ( $outputPage->checkLastModified( $timestamp ) ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
wfDebug( __METHOD__ . ": done 304\n" );
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
|
|
|
|
# Try file cache
|
|
|
|
|
} elseif ( $wgUseFileCache && $this->tryFileCache() ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": done file cache\n" );
|
|
|
|
|
# tell wgOut that output is taken care of
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->disable();
|
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
|
|
|
$this->mPage->doViewUpdates( $user, $oldid );
|
2005-02-06 07:28:21 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Should the parser cache be used?
|
2011-11-17 20:21:54 +00:00
|
|
|
$useParserCache = $this->mPage->isParserCacheUsed( $parserOptions, $oldid );
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
|
2012-04-22 23:42:38 +00:00
|
|
|
if ( $user->getStubThreshold() ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
wfIncrStats( 'pcache_miss_stub' );
|
2006-06-04 00:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-08 18:01:22 +00:00
|
|
|
$this->showRedirectedFromHeader();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$this->showNamespaceHeader();
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Iterate through the possible ways of constructing the output text.
|
|
|
|
|
# Keep going until $outputDone is set, or we run out of things to do.
|
|
|
|
|
$pass = 0;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$outputDone = false;
|
2010-04-10 23:52:07 +00:00
|
|
|
$this->mParserOutput = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
while ( !$outputDone && ++$pass ) {
|
2013-04-26 14:42:31 +00:00
|
|
|
switch ( $pass ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
case 1:
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
|
2009-08-31 19:19:12 +00:00
|
|
|
break;
|
|
|
|
|
case 2:
|
2011-11-14 18:05:55 +00:00
|
|
|
# Early abort if the page doesn't exist
|
|
|
|
|
if ( !$this->mPage->exists() ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing missing article\n" );
|
|
|
|
|
$this->showMissingArticle();
|
2014-01-17 18:49:06 +00:00
|
|
|
$this->mPage->doViewUpdates( $user );
|
2011-11-14 18:05:55 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Try the parser cache
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $useParserCache ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->mParserOutput = $parserCache->get( $this, $parserOptions );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
if ( $this->mParserOutput !== false ) {
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $oldid ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing parser cache contents for current rev permalink\n" );
|
|
|
|
|
$this->setOldSubtitle( $oldid );
|
|
|
|
|
} else {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing parser cache contents\n" );
|
|
|
|
|
}
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addParserOutput( $this->mParserOutput );
|
2009-08-31 19:19:12 +00:00
|
|
|
# Ensure that UI elements requiring revision ID have
|
|
|
|
|
# the correct version information.
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setRevisionId( $this->mPage->getLatest() );
|
2011-06-29 22:09:51 +00:00
|
|
|
# Preload timestamp to avoid a DB hit
|
2011-12-16 20:55:54 +00:00
|
|
|
$cachedTimestamp = $this->mParserOutput->getTimestamp();
|
|
|
|
|
if ( $cachedTimestamp !== null ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setRevisionTimestamp( $cachedTimestamp );
|
2011-12-16 20:55:54 +00:00
|
|
|
$this->mPage->setTimestamp( $cachedTimestamp );
|
|
|
|
|
}
|
2011-12-10 16:30:40 +00:00
|
|
|
$outputDone = true;
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2011-11-14 18:05:55 +00:00
|
|
|
# This will set $this->mRevision if needed
|
2012-03-05 17:09:41 +00:00
|
|
|
$this->fetchContentObject();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Are we looking at an old revision
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $oldid && $this->mRevision ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->setOldSubtitle( $oldid );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
if ( !$this->showDeletedRevisionHeader() ) {
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
|
2009-08-31 19:19:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Ensure that UI elements requiring revision ID have
|
|
|
|
|
# the correct version information.
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setRevisionId( $this->getRevIdFetched() );
|
2011-12-10 16:30:40 +00:00
|
|
|
# Preload timestamp to avoid a DB hit
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setRevisionTimestamp( $this->getTimestamp() );
|
2009-08-31 19:19:12 +00:00
|
|
|
|
|
|
|
|
# Pages containing custom CSS or JavaScript get special treatment
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) {
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->showCssOrJsPage();
|
|
|
|
|
$outputDone = true;
|
2014-12-09 07:23:30 +00:00
|
|
|
} elseif ( !Hooks::run( 'ArticleContentViewCustom',
|
2012-10-08 15:26:11 +00:00
|
|
|
array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
|
2012-08-20 17:28:20 +00:00
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
# Allow extensions do their own custom view for certain pages
|
|
|
|
|
$outputDone = true;
|
2013-04-20 22:49:30 +00:00
|
|
|
} elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom',
|
2012-10-08 15:26:11 +00:00
|
|
|
array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
|
2012-08-20 17:28:20 +00:00
|
|
|
|
2011-08-11 17:21:31 +00:00
|
|
|
# Allow extensions do their own custom view for certain pages
|
|
|
|
|
$outputDone = true;
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
# Run the parse, protected by a pool counter
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( __METHOD__ . ": doing uncached parse\n" );
|
2010-08-09 21:53:21 +00:00
|
|
|
|
2014-01-04 22:07:33 +00:00
|
|
|
$content = $this->getContentObject();
|
2012-11-10 15:29:56 +00:00
|
|
|
$poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
|
2014-01-04 22:07:33 +00:00
|
|
|
$this->getRevIdFetched(), $useParserCache, $content );
|
2010-12-13 19:47:34 +00:00
|
|
|
|
2010-08-27 20:57:32 +00:00
|
|
|
if ( !$poolArticleView->execute() ) {
|
2011-11-17 20:21:54 +00:00
|
|
|
$error = $poolArticleView->getError();
|
|
|
|
|
if ( $error ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->clearHTML(); // for release() errors
|
|
|
|
|
$outputPage->enableClientCache( false );
|
|
|
|
|
$outputPage->setRobotPolicy( 'noindex,nofollow' );
|
2011-11-17 20:21:54 +00:00
|
|
|
|
|
|
|
|
$errortext = $error->getWikiText( false, 'view-pool-error' );
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
|
2011-11-17 20:21:54 +00:00
|
|
|
}
|
2009-08-31 19:19:12 +00:00
|
|
|
# Connection or timeout error
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-11-17 20:21:54 +00:00
|
|
|
|
|
|
|
|
$this->mParserOutput = $poolArticleView->getParserOutput();
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addParserOutput( $this->mParserOutput );
|
2014-01-04 22:07:33 +00:00
|
|
|
if ( $content->getRedirectTarget() ) {
|
2015-01-29 16:45:22 +00:00
|
|
|
$outputPage->addSubtitle( "<span id=\"redirectsub\">" .
|
|
|
|
|
$this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
|
2014-01-04 22:07:33 +00:00
|
|
|
}
|
2011-11-17 20:21:54 +00:00
|
|
|
|
|
|
|
|
# Don't cache a dirty ParserOutput object
|
|
|
|
|
if ( $poolArticleView->getIsDirty() ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setSquidMaxage( 0 );
|
2014-03-23 01:28:57 +00:00
|
|
|
$outputPage->addHTML( "<!-- parser cache is expired, " .
|
|
|
|
|
"sending anyway due to pool overload-->\n" );
|
2011-11-17 20:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$outputDone = true;
|
2009-08-31 19:19:12 +00:00
|
|
|
break;
|
|
|
|
|
# Should be unreachable, but just in case...
|
|
|
|
|
default:
|
|
|
|
|
break 2;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-24 21:12:26 +00:00
|
|
|
# Get the ParserOutput actually *displayed* here.
|
|
|
|
|
# Note that $this->mParserOutput is the *current* version output.
|
|
|
|
|
$pOutput = ( $outputDone instanceof ParserOutput )
|
|
|
|
|
? $outputDone // object fetched by hook
|
|
|
|
|
: $this->mParserOutput;
|
|
|
|
|
|
|
|
|
|
# Adjust title for main page & pages with displaytitle
|
|
|
|
|
if ( $pOutput ) {
|
|
|
|
|
$this->adjustDisplayTitle( $pOutput );
|
2010-04-10 13:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-11 13:04:58 +00:00
|
|
|
# For the main page, overwrite the <title> element with the con-
|
|
|
|
|
# tents of 'pagetitle-view-mainpage' instead of the default (if
|
|
|
|
|
# that's not empty).
|
2010-06-28 07:17:16 +00:00
|
|
|
# This message always exists because it is in the i18n files
|
2011-09-12 21:26:08 +00:00
|
|
|
if ( $this->getTitle()->isMainPage() ) {
|
2011-02-17 17:06:06 +00:00
|
|
|
$msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
|
|
|
|
|
if ( !$msg->isDisabled() ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
|
2011-02-17 17:06:06 +00:00
|
|
|
}
|
2010-04-11 13:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-24 21:12:26 +00:00
|
|
|
# Check for any __NOINDEX__ tags on the page using $pOutput
|
|
|
|
|
$policy = $this->getRobotPolicy( 'view', $pOutput );
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setIndexPolicy( $policy['index'] );
|
|
|
|
|
$outputPage->setFollowPolicy( $policy['follow'] );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
|
|
|
|
$this->showViewFooter();
|
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
|
|
|
$this->mPage->doViewUpdates( $user, $oldid );
|
2011-09-24 21:12:26 +00:00
|
|
|
|
2013-02-23 10:35:22 +00:00
|
|
|
$outputPage->addModules( 'mediawiki.action.view.postEdit' );
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2011-09-24 21:12:26 +00:00
|
|
|
* Adjust title for pages with displaytitle, -{T|}- or language conversion
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param ParserOutput $pOutput
|
2011-09-24 21:12:26 +00:00
|
|
|
*/
|
|
|
|
|
public function adjustDisplayTitle( ParserOutput $pOutput ) {
|
|
|
|
|
# Adjust the title if it was set by displaytitle, -{T|}- or language conversion
|
|
|
|
|
$titleText = $pOutput->getTitleText();
|
|
|
|
|
if ( strval( $titleText ) !== '' ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$this->getContext()->getOutput()->setPageTitle( $titleText );
|
2011-09-24 21:12:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
|
|
|
|
* Show a diff page according to current request variables. For use within
|
|
|
|
|
* Article::view() only, other callers should use the DifferenceEngine class.
|
2012-08-24 18:49:19 +00:00
|
|
|
*
|
2013-05-15 01:12:35 +00:00
|
|
|
* @todo Make protected
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
*/
|
|
|
|
|
public function showDiffPage() {
|
2012-04-22 23:42:38 +00:00
|
|
|
$request = $this->getContext()->getRequest();
|
|
|
|
|
$user = $this->getContext()->getUser();
|
|
|
|
|
$diff = $request->getVal( 'diff' );
|
|
|
|
|
$rcid = $request->getVal( 'rcid' );
|
|
|
|
|
$diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
|
|
|
|
|
$purge = $request->getVal( 'action' ) == 'purge';
|
|
|
|
|
$unhide = $request->getInt( 'unhide' ) == 1;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$oldid = $this->getOldID();
|
|
|
|
|
|
2012-08-24 18:49:19 +00:00
|
|
|
$rev = $this->getRevisionFetched();
|
|
|
|
|
|
|
|
|
|
if ( !$rev ) {
|
2012-10-08 15:26:11 +00:00
|
|
|
$this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
|
2014-09-25 12:34:41 +00:00
|
|
|
$msg = $this->getContext()->msg( 'difference-missing-revision' )
|
|
|
|
|
->params( $oldid )
|
|
|
|
|
->numParams( 1 )
|
|
|
|
|
->parseAsBlock();
|
|
|
|
|
$this->getContext()->getOutput()->addHtml( $msg );
|
2012-08-24 18:49:19 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$contentHandler = $rev->getContentHandler();
|
2014-03-23 01:28:57 +00:00
|
|
|
$de = $contentHandler->createDifferenceEngine(
|
|
|
|
|
$this->getContext(),
|
|
|
|
|
$oldid,
|
|
|
|
|
$diff,
|
|
|
|
|
$rcid,
|
|
|
|
|
$purge,
|
|
|
|
|
$unhide
|
|
|
|
|
);
|
2012-03-27 14:08:04 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// DifferenceEngine directly fetched the revision:
|
|
|
|
|
$this->mRevIdFetched = $de->mNewid;
|
|
|
|
|
$de->showDiffPage( $diffOnly );
|
|
|
|
|
|
2014-03-23 01:28:57 +00:00
|
|
|
// Run view updates for the newer revision being diffed (and shown
|
|
|
|
|
// below the diff if not $diffOnly).
|
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
|
|
|
list( $old, $new ) = $de->mapDiffPrevNext( $oldid, $diff );
|
|
|
|
|
// New can be false, convert it to 0 - this conveniently means the latest revision
|
|
|
|
|
$this->mPage->doViewUpdates( $user, (int)$new );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* Show a page view for a page formatted as CSS or JavaScript. To be called by
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* Article::view() only.
|
|
|
|
|
*
|
2012-10-16 10:38:20 +00:00
|
|
|
* This exists mostly to serve the deprecated ShowRawCssJs hook (used to customize these views).
|
|
|
|
|
* It has been replaced by the ContentGetParserOutput hook, which lets you do the same but with
|
|
|
|
|
* more flexibility.
|
2012-10-08 15:26:11 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param bool $showCacheHint Whether to show a message telling the user
|
2014-03-23 01:28:57 +00:00
|
|
|
* to clear the browser cache (default: true).
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
*/
|
2012-03-30 12:46:42 +00:00
|
|
|
protected function showCssOrJsPage( $showCacheHint = true ) {
|
2012-10-09 12:23:42 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
|
|
|
|
|
2012-04-05 09:51:24 +00:00
|
|
|
if ( $showCacheHint ) {
|
|
|
|
|
$dir = $this->getContext()->getLanguage()->getDir();
|
2014-12-17 08:10:26 +00:00
|
|
|
$lang = $this->getContext()->getLanguage()->getHtmlCode();
|
2011-07-07 16:15:27 +00:00
|
|
|
|
2014-03-23 01:28:57 +00:00
|
|
|
$outputPage->wrapWikiMsg(
|
|
|
|
|
"<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
|
|
|
|
|
'clearyourcache'
|
|
|
|
|
);
|
2012-04-05 09:51:24 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2012-10-24 13:00:13 +00:00
|
|
|
$this->fetchContentObject();
|
|
|
|
|
|
|
|
|
|
if ( $this->mContentObject ) {
|
|
|
|
|
// Give hooks a chance to customise the output
|
2014-03-23 01:28:57 +00:00
|
|
|
if ( ContentHandler::runLegacyHooks(
|
|
|
|
|
'ShowRawCssJs',
|
|
|
|
|
array( $this->mContentObject, $this->getTitle(), $outputPage ) )
|
|
|
|
|
) {
|
2014-05-05 16:58:34 +00:00
|
|
|
// If no legacy hooks ran, display the content of the parser output, including RL modules,
|
|
|
|
|
// but excluding metadata like categories and language links
|
2012-10-24 13:00:13 +00:00
|
|
|
$po = $this->mContentObject->getParserOutput( $this->getTitle() );
|
2014-05-05 16:58:34 +00:00
|
|
|
$outputPage->addParserOutputContent( $po );
|
2012-10-24 13:00:13 +00:00
|
|
|
}
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
/**
|
|
|
|
|
* Get the robot policy to be used for the current view
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $action The action= GET parameter
|
|
|
|
|
* @param ParserOutput|null $pOutput
|
|
|
|
|
* @return array The policy that should be set
|
2014-07-24 09:30:25 +00:00
|
|
|
* @todo actions other than 'view'
|
2009-08-31 19:19:12 +00:00
|
|
|
*/
|
2013-05-24 14:17:12 +00:00
|
|
|
public function getRobotPolicy( $action, $pOutput = null ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$ns = $this->getTitle()->getNamespace();
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2013-01-11 10:30:21 +00:00
|
|
|
# Don't index user and user talk pages for blocked users (bug 11443)
|
|
|
|
|
if ( ( $ns == NS_USER || $ns == NS_USER_TALK ) && !$this->getTitle()->isSubpage() ) {
|
|
|
|
|
$specificTarget = null;
|
|
|
|
|
$vagueTarget = null;
|
|
|
|
|
$titleText = $this->getTitle()->getText();
|
|
|
|
|
if ( IP::isValid( $titleText ) ) {
|
|
|
|
|
$vagueTarget = $titleText;
|
|
|
|
|
} else {
|
|
|
|
|
$specificTarget = $titleText;
|
|
|
|
|
}
|
|
|
|
|
if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) {
|
|
|
|
|
return array(
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2013-01-11 10:30:21 +00:00
|
|
|
'follow' => 'nofollow'
|
|
|
|
|
);
|
2009-01-14 23:42:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mPage->getID() === 0 || $this->getOldID() ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
# Non-articles (special pages etc), and old revisions
|
2010-05-30 14:28:54 +00:00
|
|
|
return array(
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2010-05-30 14:28:54 +00:00
|
|
|
'follow' => 'nofollow'
|
|
|
|
|
);
|
2012-04-22 23:42:38 +00:00
|
|
|
} elseif ( $this->getContext()->getOutput()->isPrintable() ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Discourage indexing of printable versions, but encourage following
|
2010-05-30 14:28:54 +00:00
|
|
|
return array(
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2010-05-30 14:28:54 +00:00
|
|
|
'follow' => 'follow'
|
|
|
|
|
);
|
2012-04-22 23:42:38 +00:00
|
|
|
} elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# For ?curid=x urls, disallow indexing
|
2010-05-30 14:28:54 +00:00
|
|
|
return array(
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2010-05-30 14:28:54 +00:00
|
|
|
'follow' => 'follow'
|
|
|
|
|
);
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Otherwise, construct the policy based on the various config variables.
|
|
|
|
|
$policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
|
|
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Honour customised robot policies for this namespace
|
2010-05-30 14:28:54 +00:00
|
|
|
$policy = array_merge(
|
|
|
|
|
$policy,
|
|
|
|
|
self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
|
|
|
|
|
);
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
2011-09-24 21:12:26 +00:00
|
|
|
if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
|
2009-09-01 14:11:29 +00:00
|
|
|
# __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
|
|
|
|
|
# a final sanity check that we have really got the parser output.
|
2010-05-30 14:28:54 +00:00
|
|
|
$policy = array_merge(
|
|
|
|
|
$policy,
|
2011-09-24 21:12:26 +00:00
|
|
|
array( 'index' => $pOutput->getIndexPolicy() )
|
2010-05-30 14:28:54 +00:00
|
|
|
);
|
2005-12-26 13:01:18 +00:00
|
|
|
}
|
2009-08-31 19:19:12 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
# (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
|
2010-05-30 14:28:54 +00:00
|
|
|
$policy = array_merge(
|
|
|
|
|
$policy,
|
2011-06-29 22:09:51 +00:00
|
|
|
self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
|
2010-05-30 14:28:54 +00:00
|
|
|
);
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $policy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts a String robot policy into an associative array, to allow
|
|
|
|
|
* merging of several policies using array_merge().
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param array|string $policy Returns empty array on null/false/'', transparent
|
2014-04-23 11:39:49 +00:00
|
|
|
* to already-converted arrays, converts string.
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return array 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
|
2009-08-31 19:19:12 +00:00
|
|
|
*/
|
2010-02-14 22:07:30 +00:00
|
|
|
public static function formatRobotPolicy( $policy ) {
|
|
|
|
|
if ( is_array( $policy ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
return $policy;
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( !$policy ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
return array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$policy = explode( ',', $policy );
|
|
|
|
|
$policy = array_map( 'trim', $policy );
|
|
|
|
|
|
|
|
|
|
$arr = array();
|
2010-02-14 22:07:30 +00:00
|
|
|
foreach ( $policy as $var ) {
|
|
|
|
|
if ( in_array( $var, array( 'index', 'noindex' ) ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$arr['index'] = $var;
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$arr['follow'] = $var;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
return $arr;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* If this request is a redirect view, send "redirected from" subtitle to
|
2012-04-22 23:42:38 +00:00
|
|
|
* the output. Returns true if the header was needed, false if this is not
|
|
|
|
|
* a redirect view. Handles both local and remote redirects.
|
2010-03-15 01:08:07 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return bool
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
*/
|
|
|
|
|
public function showRedirectedFromHeader() {
|
2012-04-22 23:42:38 +00:00
|
|
|
global $wgRedirectSources;
|
|
|
|
|
$outputPage = $this->getContext()->getOutput();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
2014-07-08 00:50:37 +00:00
|
|
|
$request = $this->getContext()->getRequest();
|
|
|
|
|
$rdfrom = $request->getVal( 'rdfrom' );
|
|
|
|
|
|
|
|
|
|
// Construct a URL for the current page view, but with the target title
|
|
|
|
|
$query = $request->getValues();
|
|
|
|
|
unset( $query['rdfrom'] );
|
|
|
|
|
unset( $query['title'] );
|
2014-09-28 15:26:27 +00:00
|
|
|
if ( $this->getTitle()->isRedirect() ) {
|
|
|
|
|
// Prevent double redirects
|
|
|
|
|
$query['redirect'] = 'no';
|
|
|
|
|
}
|
2014-07-08 00:50:37 +00:00
|
|
|
$redirectTargetUrl = $this->getTitle()->getLinkURL( $query );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( isset( $this->mRedirectedFrom ) ) {
|
2006-01-13 00:29:20 +00:00
|
|
|
// This is an internally redirected page view.
|
|
|
|
|
// We'll need a backlink to the source page for navigation.
|
2014-12-09 07:23:30 +00:00
|
|
|
if ( Hooks::run( 'ArticleViewRedirect', array( &$this ) ) ) {
|
2011-11-08 18:01:22 +00:00
|
|
|
$redir = Linker::linkKnown(
|
2009-06-06 22:42:48 +00:00
|
|
|
$this->mRedirectedFrom,
|
|
|
|
|
null,
|
|
|
|
|
array(),
|
2011-11-08 18:01:22 +00:00
|
|
|
array( 'redirect' => 'no' )
|
2009-06-06 22:42:48 +00:00
|
|
|
);
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2014-11-22 09:35:58 +00:00
|
|
|
$outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
|
|
|
|
|
wfMessage( 'redirectedfrom' )->rawParams( $redir )->parse()
|
|
|
|
|
. "</span>" );
|
2006-12-08 06:09:15 +00:00
|
|
|
|
2014-07-08 00:50:37 +00:00
|
|
|
// Add the script to update the displayed URL and
|
|
|
|
|
// set the fragment if one was specified in the redirect
|
|
|
|
|
$outputPage->addJsConfigVars( array(
|
|
|
|
|
'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
|
|
|
|
|
) );
|
|
|
|
|
$outputPage->addModules( 'mediawiki.action.view.redirect' );
|
2009-02-13 16:17:39 +00:00
|
|
|
|
|
|
|
|
// Add a <link rel="canonical"> tag
|
2012-12-31 01:11:43 +00:00
|
|
|
$outputPage->setCanonicalUrl( $this->getTitle()->getLocalURL() );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
// Tell the output object that the user arrived at this article through a redirect
|
|
|
|
|
$outputPage->setRedirectedFrom( $this->mRedirectedFrom );
|
2011-11-30 12:43:10 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return true;
|
2006-01-13 00:29:20 +00:00
|
|
|
}
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( $rdfrom ) {
|
2006-01-13 00:29:20 +00:00
|
|
|
// This is an externally redirected view, from some other wiki.
|
|
|
|
|
// If it was reported from a trusted site, supply a backlink.
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
|
2011-04-25 11:59:31 +00:00
|
|
|
$redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
|
2014-11-22 09:35:58 +00:00
|
|
|
$outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
|
|
|
|
|
wfMessage( 'redirectedfrom' )->rawParams( $redir )->parse()
|
|
|
|
|
. "</span>" );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2014-07-08 00:50:37 +00:00
|
|
|
// Add the script to update the displayed URL
|
|
|
|
|
$outputPage->addJsConfigVars( array(
|
|
|
|
|
'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
|
|
|
|
|
) );
|
|
|
|
|
$outputPage->addModules( 'mediawiki.action.view.redirect' );
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return true;
|
2006-01-13 00:29:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* Show a header specific to the namespace currently being viewed, like
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* [[MediaWiki:Talkpagetext]]. For Article::view().
|
|
|
|
|
*/
|
|
|
|
|
public function showNamespaceHeader() {
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->isTalkPage() ) {
|
2011-01-14 10:51:05 +00:00
|
|
|
if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
|
2014-03-23 01:28:57 +00:00
|
|
|
$this->getContext()->getOutput()->wrapWikiMsg(
|
|
|
|
|
"<div class=\"mw-talkpageheader\">\n$1\n</div>",
|
|
|
|
|
array( 'talkpageheader' )
|
|
|
|
|
);
|
2009-03-27 20:22:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2009-03-27 20:22:52 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
|
|
|
|
* Show the footer section of an ordinary page view
|
|
|
|
|
*/
|
|
|
|
|
public function showViewFooter() {
|
|
|
|
|
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
|
2014-03-23 01:28:57 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() == NS_USER_TALK
|
|
|
|
|
&& IP::isValid( $this->getTitle()->getText() )
|
|
|
|
|
) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
|
2004-06-04 10:40:44 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2012-12-29 02:53:18 +00:00
|
|
|
// Show a footer allowing the user to patrol the shown revision or page if possible
|
2013-05-29 19:29:42 +00:00
|
|
|
$patrolFooterShown = $this->showPatrolFooter();
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'ArticleViewFooter', array( $this, $patrolFooterShown ) );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2008-12-22 23:38:58 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* If patrol is possible, output a patrol UI box. This is called from the
|
|
|
|
|
* footer section of ordinary page views. If patrol is not possible or not
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* desired, does nothing.
|
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.
|
2013-05-29 19:29:42 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
*/
|
|
|
|
|
public function showPatrolFooter() {
|
2013-06-13 23:04:57 +00:00
|
|
|
global $wgUseNPPatrol, $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
2012-05-07 23:30:48 +00:00
|
|
|
$user = $this->getContext()->getUser();
|
2012-12-29 02:53:18 +00:00
|
|
|
$cache = wfGetMainCache();
|
2013-06-09 01:41:48 +00:00
|
|
|
$rc = false;
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2014-03-23 01:28:57 +00:00
|
|
|
if ( !$this->getTitle()->quickUserCan( 'patrol', $user )
|
|
|
|
|
|| !( $wgUseRCPatrol || $wgUseNPPatrol )
|
|
|
|
|
) {
|
2013-06-09 01:41:48 +00:00
|
|
|
// Patrolling is disabled or the user isn't allowed to
|
2013-05-29 19:29:42 +00:00
|
|
|
return false;
|
2012-12-29 02:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
2013-06-09 01:41:48 +00:00
|
|
|
// New page patrol: Get the timestamp of the oldest revison which
|
|
|
|
|
// the revision table holds for the given page. Then we look
|
|
|
|
|
// whether it's within the RC lifespan and if it is, we try
|
|
|
|
|
// to get the recentchanges row belonging to that entry
|
|
|
|
|
// (with rc_new = 1).
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2013-06-09 01:41:48 +00:00
|
|
|
// Check for cached results
|
|
|
|
|
if ( $cache->get( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ) ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2014-03-23 01:28:57 +00:00
|
|
|
if ( $this->mRevision
|
|
|
|
|
&& !RecentChange::isInRCLifespan( $this->mRevision->getTimestamp(), 21600 )
|
|
|
|
|
) {
|
2013-06-09 01:41:48 +00:00
|
|
|
// The current revision is already older than what could be in the RC table
|
|
|
|
|
// 6h tolerance because the RC might not be cleaned out regularly
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2013-06-09 01:41:48 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$oldestRevisionTimestamp = $dbr->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'MIN( rev_timestamp )',
|
|
|
|
|
array( 'rev_page' => $this->getTitle()->getArticleID() ),
|
|
|
|
|
__METHOD__
|
|
|
|
|
);
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2014-03-23 01:28:57 +00:00
|
|
|
if ( $oldestRevisionTimestamp
|
|
|
|
|
&& RecentChange::isInRCLifespan( $oldestRevisionTimestamp, 21600 )
|
|
|
|
|
) {
|
2013-06-09 01:41:48 +00:00
|
|
|
// 6h tolerance because the RC might not be cleaned out regularly
|
2012-12-29 02:53:18 +00:00
|
|
|
$rc = RecentChange::newFromConds(
|
|
|
|
|
array(
|
|
|
|
|
'rc_new' => 1,
|
|
|
|
|
'rc_timestamp' => $oldestRevisionTimestamp,
|
|
|
|
|
'rc_namespace' => $this->getTitle()->getNamespace(),
|
|
|
|
|
'rc_cur_id' => $this->getTitle()->getArticleID(),
|
|
|
|
|
'rc_patrolled' => 0
|
|
|
|
|
),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
array( 'USE INDEX' => 'new_name_timestamp' )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$rc ) {
|
|
|
|
|
// No RC entry around
|
|
|
|
|
|
|
|
|
|
// Cache the information we gathered above in case we can't patrol
|
|
|
|
|
// Don't cache in case we can patrol as this could change
|
2013-06-09 01:41:48 +00:00
|
|
|
$cache->set( wfMemcKey( 'NotPatrollablePage', $this->getTitle()->getArticleID() ), '1' );
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2013-05-29 19:29:42 +00:00
|
|
|
return false;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2014-12-11 08:59:28 +00:00
|
|
|
if ( $rc->getPerformer()->equals( $user ) ) {
|
2013-07-20 19:24:20 +00:00
|
|
|
// Don't show a patrol link for own creations. If the user could
|
|
|
|
|
// patrol them, they already would be patrolled
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-29 02:53:18 +00:00
|
|
|
$rcid = $rc->getAttribute( 'rc_id' );
|
|
|
|
|
|
2012-05-07 23:30:48 +00:00
|
|
|
$token = $user->getEditToken( $rcid );
|
2012-10-03 01:33:55 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->preventClickjacking();
|
2013-05-28 12:00:52 +00:00
|
|
|
if ( $wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed( 'writeapi' ) ) {
|
|
|
|
|
$outputPage->addModules( 'mediawiki.page.patrol.ajax' );
|
|
|
|
|
}
|
2009-07-15 09:48:25 +00:00
|
|
|
|
2012-08-20 14:55:28 +00:00
|
|
|
$link = Linker::linkKnown(
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
wfMessage( 'markaspatrolledtext' )->escaped(),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'markpatrolled',
|
|
|
|
|
'rcid' => $rcid,
|
|
|
|
|
'token' => $token,
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addHTML(
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
"<div class='patrollink'>" .
|
2012-08-20 14:55:28 +00:00
|
|
|
wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
'</div>'
|
|
|
|
|
);
|
2013-05-29 19:29:42 +00:00
|
|
|
|
|
|
|
|
return true;
|
2009-12-26 20:03:33 +00:00
|
|
|
}
|
2008-08-08 00:01:53 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* Show the error text for a missing article. For articles in the MediaWiki
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* namespace, show the default message text. To be called from Article::view().
|
|
|
|
|
*/
|
|
|
|
|
public function showMissingArticle() {
|
2012-04-22 23:42:38 +00:00
|
|
|
global $wgSend404Code;
|
2014-07-02 22:55:03 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
2013-05-19 17:27:53 +00:00
|
|
|
// Whether the page is a root user page of an existing user (but not a subpage)
|
2013-02-21 22:45:57 +00:00
|
|
|
$validUserPage = false;
|
2009-09-13 02:07:21 +00:00
|
|
|
|
2014-07-02 22:55:03 +00:00
|
|
|
$title = $this->getTitle();
|
|
|
|
|
|
2010-02-10 13:08:24 +00:00
|
|
|
# Show info in user (talk) namespace. Does the user exist? Is he blocked?
|
2014-07-02 22:55:03 +00:00
|
|
|
if ( $title->getNamespace() == NS_USER
|
|
|
|
|
|| $title->getNamespace() == NS_USER_TALK
|
2014-03-23 01:28:57 +00:00
|
|
|
) {
|
2014-07-02 22:55:03 +00:00
|
|
|
$parts = explode( '/', $title->getText() );
|
2009-10-10 09:29:44 +00:00
|
|
|
$rootPart = $parts[0];
|
2010-02-19 10:37:20 +00:00
|
|
|
$user = User::newFromName( $rootPart, false /* allow IP users*/ );
|
2009-10-10 09:29:44 +00:00
|
|
|
$ip = User::isIP( $rootPart );
|
2014-06-07 22:43:15 +00:00
|
|
|
$block = Block::newFromTarget( $user, $user );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2013-04-26 14:42:31 +00:00
|
|
|
if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
|
2011-06-20 19:45:35 +00:00
|
|
|
array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
|
2014-10-11 19:11:57 +00:00
|
|
|
} elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
|
|
|
|
|
# Show log extract if the user is currently blocked
|
2010-02-10 13:08:24 +00:00
|
|
|
LogEventsList::showLogExtract(
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage,
|
2010-02-10 13:08:24 +00:00
|
|
|
'block',
|
2014-06-07 22:43:15 +00:00
|
|
|
MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget(),
|
2010-02-10 13:08:24 +00:00
|
|
|
'',
|
|
|
|
|
array(
|
|
|
|
|
'lim' => 1,
|
|
|
|
|
'showIfEmpty' => false,
|
|
|
|
|
'msgKey' => array(
|
2010-02-19 10:37:20 +00:00
|
|
|
'blocked-notice-logextract',
|
|
|
|
|
$user->getName() # Support GENDER in notice
|
2010-02-10 13:08:24 +00:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
2014-07-02 22:55:03 +00:00
|
|
|
$validUserPage = !$title->isSubpage();
|
2013-02-21 22:45:57 +00:00
|
|
|
} else {
|
2014-07-02 22:55:03 +00:00
|
|
|
$validUserPage = !$title->isSubpage();
|
2009-09-13 02:07:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'ShowMissingArticle', array( $this ) );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2013-10-29 11:15:18 +00:00
|
|
|
// Give extensions a chance to hide their (unrelated) log entries
|
|
|
|
|
$logTypes = array( 'delete', 'move' );
|
|
|
|
|
$conds = array( "log_action != 'revision'" );
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) );
|
2013-10-29 11:15:18 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Show delete and move logs
|
2014-10-31 21:16:06 +00:00
|
|
|
LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '',
|
|
|
|
|
array( 'lim' => 10,
|
|
|
|
|
'conds' => $conds,
|
|
|
|
|
'showIfEmpty' => false,
|
|
|
|
|
'msgKey' => array( 'moveddeleted-notice' ) )
|
|
|
|
|
);
|
2005-07-01 20:36:04 +00:00
|
|
|
|
2013-02-21 22:45:57 +00:00
|
|
|
if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
|
2012-02-13 22:32:44 +00:00
|
|
|
// If there's no backing content, send a 404 Not Found
|
|
|
|
|
// for better machine handling of broken links.
|
2012-04-22 23:42:38 +00:00
|
|
|
$this->getContext()->getRequest()->response()->header( "HTTP/1.1 404 Not Found" );
|
2012-02-13 22:32:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 04:28:50 +00:00
|
|
|
// Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
|
|
|
|
|
$policy = $this->getRobotPolicy( 'view' );
|
|
|
|
|
$outputPage->setIndexPolicy( $policy['index'] );
|
|
|
|
|
$outputPage->setFollowPolicy( $policy['follow'] );
|
2013-05-24 14:17:12 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
$hookResult = Hooks::run( 'BeforeDisplayNoArticleText', array( $this ) );
|
2012-02-13 22:32:44 +00:00
|
|
|
|
2014-07-21 12:47:42 +00:00
|
|
|
if ( !$hookResult ) {
|
2012-02-13 22:32:44 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Show error message
|
|
|
|
|
$oldid = $this->getOldID();
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $oldid ) {
|
2012-08-20 14:55:28 +00:00
|
|
|
$text = wfMessage( 'missing-revision', $oldid )->plain();
|
2014-07-02 22:55:03 +00:00
|
|
|
} elseif ( $title->getNamespace() === NS_MEDIAWIKI ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// Use the default message text
|
2014-07-02 22:55:03 +00:00
|
|
|
$text = $title->getDefaultMessageText();
|
|
|
|
|
} elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
|
|
|
|
|
&& $title->quickUserCan( 'edit', $this->getContext()->getUser() )
|
2012-05-31 08:03:46 +00:00
|
|
|
) {
|
2013-09-11 20:03:10 +00:00
|
|
|
$message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
|
|
|
|
|
$text = wfMessage( $message )->plain();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
} else {
|
2012-08-20 14:55:28 +00:00
|
|
|
$text = wfMessage( 'noarticletext-nopermission' )->plain();
|
2004-02-27 02:24:14 +00:00
|
|
|
}
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$text = "<div class='noarticletext'>\n$text\n</div>";
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addWikiText( $text );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2006-06-13 11:37:09 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* If the revision requested for view is deleted, check permissions.
|
2012-04-22 23:42:38 +00:00
|
|
|
* Send either an error message or a warning header to the output.
|
2010-05-30 14:28:54 +00:00
|
|
|
*
|
2014-07-24 17:43:25 +00:00
|
|
|
* @return bool True if the view is allowed, false if not.
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
*/
|
|
|
|
|
public function showDeletedRevisionHeader() {
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// Not deleted
|
|
|
|
|
return true;
|
2004-08-09 05:38:11 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
2012-07-16 09:03:02 +00:00
|
|
|
$user = $this->getContext()->getUser();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// If the user is not allowed to see it...
|
2012-07-16 09:03:02 +00:00
|
|
|
if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $user ) ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
'rev-deleted-text-permission' );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return false;
|
|
|
|
|
// If the user needs to confirm that they want to see it...
|
2012-04-22 23:42:38 +00:00
|
|
|
} elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Give explanation and add a link to view the revision...
|
|
|
|
|
$oldid = intval( $this->getOldID() );
|
2013-03-27 13:36:05 +00:00
|
|
|
$link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" );
|
2009-07-30 18:01:41 +00:00
|
|
|
$msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
|
|
|
|
|
'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
|
2010-02-14 22:07:30 +00:00
|
|
|
array( $msg, $link ) );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return false;
|
|
|
|
|
// We are allowed to see...
|
|
|
|
|
} else {
|
2009-07-30 18:01:41 +00:00
|
|
|
$msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
|
|
|
|
|
'rev-suppressed-text-view' : 'rev-deleted-text-view';
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return true;
|
2008-11-28 14:29:25 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2011-11-11 15:58:17 +00:00
|
|
|
/**
|
|
|
|
|
* Generate the navigation links when browsing through an article revisions
|
|
|
|
|
* It shows the information as:
|
|
|
|
|
* Revision as of \<date\>; view current revision
|
|
|
|
|
* \<- Previous version | Next Version -\>
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param int $oldid Revision ID of this article revision
|
2011-11-11 15:58:17 +00:00
|
|
|
*/
|
|
|
|
|
public function setOldSubtitle( $oldid = 0 ) {
|
2014-12-09 07:23:30 +00:00
|
|
|
if ( !Hooks::run( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
|
2011-11-11 15:58:17 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-29 16:01:58 +00:00
|
|
|
$context = $this->getContext();
|
|
|
|
|
$unhide = $context->getRequest()->getInt( 'unhide' ) == 1;
|
2011-11-11 15:58:17 +00:00
|
|
|
|
|
|
|
|
# Cascade unhide param in links for easy deletion browsing
|
|
|
|
|
$extraParams = array();
|
2012-03-09 20:37:44 +00:00
|
|
|
if ( $unhide ) {
|
2011-11-11 15:58:17 +00:00
|
|
|
$extraParams['unhide'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 20:26:08 +00:00
|
|
|
if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
|
|
|
|
|
$revision = $this->mRevision;
|
|
|
|
|
} else {
|
|
|
|
|
$revision = Revision::newFromId( $oldid );
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-11 15:58:17 +00:00
|
|
|
$timestamp = $revision->getTimestamp();
|
|
|
|
|
|
|
|
|
|
$current = ( $oldid == $this->mPage->getLatest() );
|
2015-01-29 16:01:58 +00:00
|
|
|
$language = $context->getLanguage();
|
|
|
|
|
$user = $context->getUser();
|
2012-06-11 09:31:38 +00:00
|
|
|
|
|
|
|
|
$td = $language->userTimeAndDate( $timestamp, $user );
|
|
|
|
|
$tddate = $language->userDate( $timestamp, $user );
|
|
|
|
|
$tdtime = $language->userTime( $timestamp, $user );
|
2011-11-11 15:58:17 +00:00
|
|
|
|
|
|
|
|
# Show user links if allowed to see them. If hidden, then show them only if requested...
|
|
|
|
|
$userlinks = Linker::revUserTools( $revision, !$unhide );
|
|
|
|
|
|
2015-01-29 16:01:58 +00:00
|
|
|
$infomsg = $current && !$context->msg( 'revision-info-current' )->isDisabled()
|
2011-11-11 15:58:17 +00:00
|
|
|
? 'revision-info-current'
|
|
|
|
|
: 'revision-info';
|
|
|
|
|
|
2015-01-29 16:01:58 +00:00
|
|
|
$outputPage = $context->getOutput();
|
2014-10-11 19:11:57 +00:00
|
|
|
$outputPage->addSubtitle( "<div id=\"mw-{$infomsg}\">" .
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( $infomsg, $td )
|
2014-10-11 19:11:57 +00:00
|
|
|
->rawParams( $userlinks )
|
|
|
|
|
->params( $revision->getID(), $tddate, $tdtime, $revision->getUserText() )
|
|
|
|
|
->rawParams( Linker::revComment( $revision, true, true ) )
|
|
|
|
|
->parse() .
|
|
|
|
|
"</div>"
|
|
|
|
|
);
|
2011-11-11 15:58:17 +00:00
|
|
|
|
|
|
|
|
$lnk = $current
|
2015-01-29 16:01:58 +00:00
|
|
|
? $context->msg( 'currentrevisionlink' )->escaped()
|
2012-07-29 19:11:33 +00:00
|
|
|
: Linker::linkKnown(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( 'currentrevisionlink' )->escaped(),
|
2011-11-11 15:58:17 +00:00
|
|
|
array(),
|
2012-07-29 19:11:33 +00:00
|
|
|
$extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
);
|
|
|
|
|
$curdiff = $current
|
2015-01-29 16:01:58 +00:00
|
|
|
? $context->msg( 'diff' )->escaped()
|
2012-07-29 19:11:33 +00:00
|
|
|
: Linker::linkKnown(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( 'diff' )->escaped(),
|
2011-11-11 15:58:17 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'diff' => 'cur',
|
|
|
|
|
'oldid' => $oldid
|
2012-07-29 19:11:33 +00:00
|
|
|
) + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
);
|
2013-02-09 21:44:24 +00:00
|
|
|
$prev = $this->getTitle()->getPreviousRevisionID( $oldid );
|
2011-11-11 15:58:17 +00:00
|
|
|
$prevlink = $prev
|
2012-07-29 19:11:33 +00:00
|
|
|
? Linker::linkKnown(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( 'previousrevision' )->escaped(),
|
2011-11-11 15:58:17 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'direction' => 'prev',
|
|
|
|
|
'oldid' => $oldid
|
2012-07-29 19:11:33 +00:00
|
|
|
) + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
)
|
2015-01-29 16:01:58 +00:00
|
|
|
: $context->msg( 'previousrevision' )->escaped();
|
2011-11-11 15:58:17 +00:00
|
|
|
$prevdiff = $prev
|
2012-07-29 19:11:33 +00:00
|
|
|
? Linker::linkKnown(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( 'diff' )->escaped(),
|
2011-11-11 15:58:17 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'diff' => 'prev',
|
|
|
|
|
'oldid' => $oldid
|
2012-07-29 19:11:33 +00:00
|
|
|
) + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
)
|
2015-01-29 16:01:58 +00:00
|
|
|
: $context->msg( 'diff' )->escaped();
|
2011-11-11 15:58:17 +00:00
|
|
|
$nextlink = $current
|
2015-01-29 16:01:58 +00:00
|
|
|
? $context->msg( 'nextrevision' )->escaped()
|
2012-07-29 19:11:33 +00:00
|
|
|
: Linker::linkKnown(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( 'nextrevision' )->escaped(),
|
2011-11-11 15:58:17 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'direction' => 'next',
|
|
|
|
|
'oldid' => $oldid
|
2012-07-29 19:11:33 +00:00
|
|
|
) + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
);
|
|
|
|
|
$nextdiff = $current
|
2015-01-29 16:01:58 +00:00
|
|
|
? $context->msg( 'diff' )->escaped()
|
2012-07-29 19:11:33 +00:00
|
|
|
: Linker::linkKnown(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( 'diff' )->escaped(),
|
2011-11-11 15:58:17 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'diff' => 'next',
|
|
|
|
|
'oldid' => $oldid
|
2012-07-29 19:11:33 +00:00
|
|
|
) + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
);
|
|
|
|
|
|
2012-06-11 09:31:38 +00:00
|
|
|
$cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
|
2011-12-28 18:41:36 +00:00
|
|
|
if ( $cdel !== '' ) {
|
2011-11-11 15:58:17 +00:00
|
|
|
$cdel .= ' ';
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addSubtitle( "<div id=\"mw-revision-nav\">" . $cdel .
|
2015-01-29 16:01:58 +00:00
|
|
|
$context->msg( 'revision-nav' )->rawParams(
|
2012-08-20 14:55:28 +00:00
|
|
|
$prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
|
|
|
|
|
)->escaped() . "</div>" );
|
2011-11-11 15:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
2008-08-02 02:39:09 +00:00
|
|
|
/**
|
2014-01-04 22:07:33 +00:00
|
|
|
* Return the HTML for the top of a redirect page
|
|
|
|
|
*
|
|
|
|
|
* Chances are you should just be using the ParserOutput from
|
|
|
|
|
* WikitextContent::getParserOutput instead of calling this for redirects.
|
2010-05-30 14:28:54 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title|array $target Destination(s) to redirect
|
|
|
|
|
* @param bool $appendSubtitle [optional]
|
|
|
|
|
* @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
|
2014-09-05 13:40:12 +00:00
|
|
|
* @return string Containing HTML with redirect link
|
2008-08-02 02:39:09 +00:00
|
|
|
*/
|
|
|
|
|
public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
|
2014-01-04 22:07:33 +00:00
|
|
|
$lang = $this->getTitle()->getPageLanguage();
|
2014-09-05 14:12:04 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
2014-01-04 22:07:33 +00:00
|
|
|
if ( $appendSubtitle ) {
|
2015-01-29 16:45:22 +00:00
|
|
|
$out->addSubtitle( wfMessage( 'redirectpagesub' ) );
|
2014-01-04 22:07:33 +00:00
|
|
|
}
|
2014-09-05 14:12:04 +00:00
|
|
|
$out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
|
2014-01-04 22:07:33 +00:00
|
|
|
return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the HTML for the top of a redirect page
|
|
|
|
|
*
|
|
|
|
|
* Chances are you should just be using the ParserOutput from
|
|
|
|
|
* WikitextContent::getParserOutput instead of calling this for redirects.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.23
|
|
|
|
|
* @param Language $lang
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title|array $target Destination(s) to redirect
|
2014-01-04 22:07:33 +00:00
|
|
|
* @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
|
2014-09-05 13:40:12 +00:00
|
|
|
* @return string Containing HTML with redirect link
|
2014-01-04 22:07:33 +00:00
|
|
|
*/
|
|
|
|
|
public static function getRedirectHeaderHtml( Language $lang, $target, $forceKnown = false ) {
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( !is_array( $target ) ) {
|
2009-01-21 20:42:32 +00:00
|
|
|
$target = array( $target );
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2014-09-05 14:12:04 +00:00
|
|
|
$html = '<ul class="redirectText">';
|
|
|
|
|
/** @var Title $title */
|
|
|
|
|
foreach ( $target as $title ) {
|
|
|
|
|
$html .= '<li>' . Linker::link(
|
|
|
|
|
$title,
|
|
|
|
|
htmlspecialchars( $title->getFullText() ),
|
|
|
|
|
array(),
|
|
|
|
|
// Automatically append redirect=no to each link, since most of them are
|
|
|
|
|
// redirect pages themselves.
|
|
|
|
|
array( 'redirect' => 'no' ),
|
|
|
|
|
( $forceKnown ? array( 'known', 'noclasses' ) : array() )
|
|
|
|
|
) . '</li>';
|
2008-11-28 14:29:25 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2014-09-05 13:54:14 +00:00
|
|
|
$redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->text();
|
|
|
|
|
|
2010-11-19 21:23:50 +00:00
|
|
|
return '<div class="redirectMsg">' .
|
2014-09-05 14:12:04 +00:00
|
|
|
'<p>' . $redirectToText . '</p>' .
|
|
|
|
|
$html .
|
|
|
|
|
'</div>';
|
2008-05-11 19:49:08 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-03-15 01:08:07 +00:00
|
|
|
/**
|
|
|
|
|
* Handle action=render
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function render() {
|
2014-05-23 05:04:26 +00:00
|
|
|
$this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
|
2012-04-22 23:42:38 +00:00
|
|
|
$this->getContext()->getOutput()->setArticleBodyOnly( true );
|
2014-03-11 20:00:02 +00:00
|
|
|
$this->getContext()->getOutput()->enableSectionEditLinks( false );
|
2005-07-03 04:00:33 +00:00
|
|
|
$this->view();
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* action=protect handler
|
|
|
|
|
*/
|
|
|
|
|
public function protect() {
|
|
|
|
|
$form = new ProtectionForm( $this );
|
|
|
|
|
$form->execute();
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* action=unprotect handler (alias)
|
|
|
|
|
*/
|
|
|
|
|
public function unprotect() {
|
|
|
|
|
$this->protect();
|
2004-04-21 16:17:49 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2011-05-21 19:35:16 +00:00
|
|
|
/**
|
2004-09-02 23:28:24 +00:00
|
|
|
* UI entry point for page deletion
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function delete() {
|
2011-11-02 15:30:55 +00:00
|
|
|
# This code desperately needs to be totally rewritten
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
$title = $this->getTitle();
|
2014-12-15 20:04:54 +00:00
|
|
|
$context = $this->getContext();
|
|
|
|
|
$user = $context->getUser();
|
2011-11-03 08:55:04 +00:00
|
|
|
|
2011-11-02 15:30:55 +00:00
|
|
|
# Check permissions
|
2014-08-02 13:32:45 +00:00
|
|
|
$permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
|
|
|
|
|
if ( count( $permissionErrors ) ) {
|
|
|
|
|
throw new PermissionsError( 'delete', $permissionErrors );
|
2011-11-02 15:30:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Read-only check...
|
|
|
|
|
if ( wfReadOnly() ) {
|
|
|
|
|
throw new ReadOnlyError;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-13 23:36:27 +00:00
|
|
|
# Better double-check that it hasn't been deleted yet!
|
2012-07-25 10:22:47 +00:00
|
|
|
$this->mPage->loadPageData( 'fromdbmaster' );
|
|
|
|
|
if ( !$this->mPage->exists() ) {
|
2012-08-20 14:55:28 +00:00
|
|
|
$deleteLogPage = new LogPage( 'delete' );
|
2014-12-15 20:04:54 +00:00
|
|
|
$outputPage = $context->getOutput();
|
|
|
|
|
$outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
|
2011-11-03 08:55:04 +00:00
|
|
|
array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) )
|
|
|
|
|
);
|
2012-08-20 14:55:28 +00:00
|
|
|
$outputPage->addHTML(
|
|
|
|
|
Xml::element( 'h2', null, $deleteLogPage->getName()->text() )
|
|
|
|
|
);
|
2011-04-13 23:36:27 +00:00
|
|
|
LogEventsList::showLogExtract(
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage,
|
2011-04-13 23:36:27 +00:00
|
|
|
'delete',
|
2012-08-20 14:55:28 +00:00
|
|
|
$title
|
2011-04-13 23:36:27 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 20:04:54 +00:00
|
|
|
$request = $context->getRequest();
|
2012-04-22 23:42:38 +00:00
|
|
|
$deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
|
|
|
|
|
$deleteReason = $request->getText( 'wpReason' );
|
2011-11-03 08:55:04 +00:00
|
|
|
|
|
|
|
|
if ( $deleteReasonList == 'other' ) {
|
|
|
|
|
$reason = $deleteReason;
|
|
|
|
|
} elseif ( $deleteReason != '' ) {
|
|
|
|
|
// Entry from drop down menu + additional comment
|
2012-08-20 14:55:28 +00:00
|
|
|
$colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
|
|
|
|
|
$reason = $deleteReasonList . $colonseparator . $deleteReason;
|
2011-11-03 08:55:04 +00:00
|
|
|
} else {
|
|
|
|
|
$reason = $deleteReasonList;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
|
2013-12-01 20:39:00 +00:00
|
|
|
array( 'delete', $this->getTitle()->getPrefixedText() ) )
|
|
|
|
|
) {
|
2011-11-03 08:55:04 +00:00
|
|
|
# Flag to hide all contents of the archived revisions
|
2012-04-22 23:42:38 +00:00
|
|
|
$suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
|
2011-11-03 08:55:04 +00:00
|
|
|
|
2011-04-13 23:36:27 +00:00
|
|
|
$this->doDelete( $reason, $suppress );
|
|
|
|
|
|
2013-06-13 18:02:55 +00:00
|
|
|
WatchAction::doWatchOrUnwatch( $request->getCheck( 'wpWatch' ), $title, $user );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate deletion reason
|
|
|
|
|
$hasHistory = false;
|
|
|
|
|
if ( !$reason ) {
|
2012-04-05 09:51:24 +00:00
|
|
|
try {
|
|
|
|
|
$reason = $this->generateReason( $hasHistory );
|
2015-01-09 23:44:47 +00:00
|
|
|
} catch ( Exception $e ) {
|
2014-03-23 01:28:57 +00:00
|
|
|
# if a page is horribly broken, we still want to be able to
|
|
|
|
|
# delete it. So be lenient about errors here.
|
2013-02-03 20:05:24 +00:00
|
|
|
wfDebug( "Error while building auto delete summary: $e" );
|
2012-04-05 09:51:24 +00:00
|
|
|
$reason = '';
|
|
|
|
|
}
|
2011-04-13 23:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the page has a history, insert a warning
|
2011-11-03 08:55:04 +00:00
|
|
|
if ( $hasHistory ) {
|
2014-05-03 16:47:25 +00:00
|
|
|
$title = $this->getTitle();
|
|
|
|
|
|
2014-10-11 19:11:57 +00:00
|
|
|
// The following can use the real revision count as this is only being shown for users
|
|
|
|
|
// that can delete this page.
|
|
|
|
|
// This, as a side-effect, also makes sure that the following query isn't being run for
|
|
|
|
|
// pages with a larger history, unless the user has the 'bigdelete' right
|
|
|
|
|
// (and is about to delete this page).
|
2014-05-03 16:47:25 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$revisions = $edits = (int)$dbr->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'COUNT(rev_page)',
|
|
|
|
|
array( 'rev_page' => $title->getArticleID() ),
|
|
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
|
2011-05-17 22:03:20 +00:00
|
|
|
// @todo FIXME: i18n issue/patchwork message
|
2014-12-15 20:04:54 +00:00
|
|
|
$context->getOutput()->addHTML(
|
2014-10-11 19:11:57 +00:00
|
|
|
'<strong class="mw-delete-warning-revisions">' .
|
2014-12-15 20:04:54 +00:00
|
|
|
$context->msg( 'historywarning' )->numParams( $revisions )->parse() .
|
|
|
|
|
$context->msg( 'word-separator' )->escaped() . Linker::linkKnown( $title,
|
|
|
|
|
$context->msg( 'history' )->escaped(),
|
2011-04-13 23:36:27 +00:00
|
|
|
array( 'rel' => 'archives' ),
|
|
|
|
|
array( 'action' => 'history' ) ) .
|
|
|
|
|
'</strong>'
|
|
|
|
|
);
|
|
|
|
|
|
2014-05-03 16:47:25 +00:00
|
|
|
if ( $title->isBigDeletion() ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
global $wgDeleteRevisionsLimit;
|
2014-12-15 20:04:54 +00:00
|
|
|
$context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
|
2014-03-23 01:28:57 +00:00
|
|
|
array(
|
|
|
|
|
'delete-warning-toobig',
|
2014-12-15 20:04:54 +00:00
|
|
|
$context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
|
2014-03-23 01:28:57 +00:00
|
|
|
)
|
|
|
|
|
);
|
2011-04-13 23:36:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-15 14:05:49 +00:00
|
|
|
$this->confirmDelete( $reason );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-04-13 23:36:27 +00:00
|
|
|
/**
|
|
|
|
|
* Output deletion confirmation dialog
|
2011-05-17 22:03:20 +00:00
|
|
|
* @todo FIXME: Move to another file?
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $reason Prefilled reason
|
2011-04-13 23:36:27 +00:00
|
|
|
*/
|
|
|
|
|
public function confirmDelete( $reason ) {
|
|
|
|
|
wfDebug( "Article::confirmDelete\n" );
|
|
|
|
|
|
2014-08-01 14:31:50 +00:00
|
|
|
$title = $this->getTitle();
|
2014-08-14 18:51:21 +00:00
|
|
|
$ctx = $this->getContext();
|
|
|
|
|
$outputPage = $ctx->getOutput();
|
|
|
|
|
$useMediaWikiUIEverywhere = $ctx->getConfig()->get( 'UseMediaWikiUIEverywhere' );
|
2014-08-01 14:31:50 +00:00
|
|
|
$outputPage->setPageTitle( wfMessage( 'delete-confirm', $title->getPrefixedText() ) );
|
|
|
|
|
$outputPage->addBacklinkSubtitle( $title );
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setRobotPolicy( 'noindex,nofollow' );
|
2014-08-01 14:31:50 +00:00
|
|
|
$backlinkCache = $title->getBacklinkCache();
|
2014-01-18 01:09:09 +00:00
|
|
|
if ( $backlinkCache->hasLinks( 'pagelinks' ) || $backlinkCache->hasLinks( 'templatelinks' ) ) {
|
2013-05-23 23:22:17 +00:00
|
|
|
$outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
|
|
|
|
|
'deleting-backlinks-warning' );
|
|
|
|
|
}
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addWikiMsg( 'confirmdeletetext' );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
$user = $this->getContext()->getUser();
|
|
|
|
|
|
|
|
|
|
if ( $user->isAllowed( 'suppressrevision' ) ) {
|
2014-08-14 18:51:21 +00:00
|
|
|
$suppress = Html::openElement( 'div', array( 'id' => 'wpDeleteSuppressRow' ) ) .
|
|
|
|
|
"<strong>" .
|
2012-08-20 14:55:28 +00:00
|
|
|
Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
|
2011-04-13 23:36:27 +00:00
|
|
|
'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) .
|
2014-08-14 18:51:21 +00:00
|
|
|
"</strong>" .
|
|
|
|
|
Html::closeElement( 'div' );
|
2011-04-13 23:36:27 +00:00
|
|
|
} else {
|
|
|
|
|
$suppress = '';
|
|
|
|
|
}
|
2014-08-01 14:31:50 +00:00
|
|
|
$checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $title );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2014-08-14 18:51:21 +00:00
|
|
|
$form = Html::openElement( 'form', array( 'method' => 'post',
|
2014-08-01 14:31:50 +00:00
|
|
|
'action' => $title->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
|
2014-08-14 18:51:21 +00:00
|
|
|
Html::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) .
|
|
|
|
|
Html::element( 'legend', null, wfMessage( 'delete-legend' )->text() ) .
|
|
|
|
|
Html::openElement( 'div', array( 'id' => 'mw-deleteconfirm-table' ) ) .
|
|
|
|
|
Html::openElement( 'div', array( 'id' => 'wpDeleteReasonListRow' ) ) .
|
|
|
|
|
Html::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
|
|
|
|
|
' ' .
|
|
|
|
|
Xml::listDropDown(
|
|
|
|
|
'wpDeleteReasonList',
|
|
|
|
|
wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
|
|
|
|
|
wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(),
|
|
|
|
|
'',
|
|
|
|
|
'wpReasonDropDown',
|
|
|
|
|
1
|
|
|
|
|
) .
|
|
|
|
|
Html::closeElement( 'div' ) .
|
|
|
|
|
Html::openElement( 'div', array( 'id' => 'wpDeleteReasonRow' ) ) .
|
|
|
|
|
Html::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
|
|
|
|
|
' ' .
|
|
|
|
|
Html::input( 'wpReason', $reason, 'text', array(
|
|
|
|
|
'size' => '60',
|
|
|
|
|
'maxlength' => '255',
|
|
|
|
|
'tabindex' => '2',
|
|
|
|
|
'id' => 'wpReason',
|
|
|
|
|
'class' => 'mw-ui-input-inline',
|
|
|
|
|
'autofocus'
|
|
|
|
|
) ) .
|
|
|
|
|
Html::closeElement( 'div' );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
|
|
|
|
# Disallow watching if user is not logged in
|
2011-11-03 08:55:04 +00:00
|
|
|
if ( $user->isLoggedIn() ) {
|
2014-08-14 18:51:21 +00:00
|
|
|
$form .=
|
2012-08-20 14:55:28 +00:00
|
|
|
Xml::checkLabel( wfMessage( 'watchthis' )->text(),
|
2014-08-14 18:51:21 +00:00
|
|
|
'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
2014-08-14 18:51:21 +00:00
|
|
|
$form .=
|
|
|
|
|
Html::openElement( 'div' ) .
|
|
|
|
|
$suppress .
|
2012-08-20 14:55:28 +00:00
|
|
|
Xml::submitButton( wfMessage( 'deletepage' )->text(),
|
2014-08-14 18:51:21 +00:00
|
|
|
array(
|
|
|
|
|
'name' => 'wpConfirmB',
|
|
|
|
|
'id' => 'wpConfirmB',
|
|
|
|
|
'tabindex' => '5',
|
|
|
|
|
'class' => $useMediaWikiUIEverywhere ? 'mw-ui-button mw-ui-destructive' : '',
|
|
|
|
|
)
|
|
|
|
|
) .
|
|
|
|
|
Html::closeElement( 'div' ) .
|
|
|
|
|
Html::closeElement( 'div' ) .
|
2011-04-13 23:36:27 +00:00
|
|
|
Xml::closeElement( 'fieldset' ) .
|
2014-03-23 01:28:57 +00:00
|
|
|
Html::hidden(
|
|
|
|
|
'wpEditToken',
|
2014-08-01 14:31:50 +00:00
|
|
|
$user->getEditToken( array( 'delete', $title->getPrefixedText() ) )
|
2014-03-23 01:28:57 +00:00
|
|
|
) .
|
2011-04-13 23:36:27 +00:00
|
|
|
Xml::closeElement( 'form' );
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
if ( $user->isAllowed( 'editinterface' ) ) {
|
2014-08-07 15:34:57 +00:00
|
|
|
$dropdownTitle = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
|
2011-04-25 11:59:31 +00:00
|
|
|
$link = Linker::link(
|
2014-08-07 15:34:57 +00:00
|
|
|
$dropdownTitle,
|
2012-08-20 14:55:28 +00:00
|
|
|
wfMessage( 'delete-edit-reasonlist' )->escaped(),
|
2011-04-13 23:36:27 +00:00
|
|
|
array(),
|
|
|
|
|
array( 'action' => 'edit' )
|
|
|
|
|
);
|
|
|
|
|
$form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addHTML( $form );
|
2012-08-20 14:55:28 +00:00
|
|
|
|
|
|
|
|
$deleteLogPage = new LogPage( 'delete' );
|
|
|
|
|
$outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
|
2014-08-01 14:31:50 +00:00
|
|
|
LogEventsList::showLogExtract( $outputPage, 'delete', $title );
|
2011-04-13 23:36:27 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Perform a deletion and output success or failure messages
|
2014-03-23 01:28:57 +00:00
|
|
|
* @param string $reason
|
|
|
|
|
* @param bool $suppress
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function doDelete( $reason, $suppress = false ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
$error = '';
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
2012-05-14 01:20:05 +00:00
|
|
|
$status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error );
|
2014-03-23 01:28:57 +00:00
|
|
|
|
2012-05-14 01:20:05 +00:00
|
|
|
if ( $status->isGood() ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$deleted = $this->getTitle()->getPrefixedText();
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
|
|
|
|
|
$outputPage->setRobotPolicy( 'noindex,nofollow' );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2012-08-20 14:55:28 +00:00
|
|
|
$loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
|
2014-11-01 20:39:52 +00:00
|
|
|
|
2014-12-09 07:23:30 +00:00
|
|
|
Hooks::run( 'ArticleDeleteAfterSuccess', array( $this->getTitle(), $outputPage ) );
|
2014-11-01 20:39:52 +00:00
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->returnToMain( false );
|
2011-04-13 23:36:27 +00:00
|
|
|
} else {
|
2014-03-23 01:28:57 +00:00
|
|
|
$outputPage->setPageTitle(
|
|
|
|
|
wfMessage( 'cannotdelete-title',
|
|
|
|
|
$this->getTitle()->getPrefixedText() )
|
|
|
|
|
);
|
|
|
|
|
|
2011-04-13 23:36:27 +00:00
|
|
|
if ( $error == '' ) {
|
2012-08-29 08:07:10 +00:00
|
|
|
$outputPage->addWikiText(
|
|
|
|
|
"<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
|
2012-08-29 13:14:49 +00:00
|
|
|
);
|
2012-08-29 08:07:10 +00:00
|
|
|
$deleteLogPage = new LogPage( 'delete' );
|
2012-08-20 14:55:28 +00:00
|
|
|
$outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
|
|
|
|
LogEventsList::showLogExtract(
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage,
|
2011-04-13 23:36:27 +00:00
|
|
|
'delete',
|
2012-08-20 14:55:28 +00:00
|
|
|
$this->getTitle()
|
2011-04-13 23:36:27 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addHTML( $error );
|
2011-04-13 23:36:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2003-05-16 13:39:22 +00:00
|
|
|
/* Caching functions */
|
2003-12-11 20:16:34 +00:00
|
|
|
|
2004-09-03 00:20:26 +00:00
|
|
|
/**
|
|
|
|
|
* checkLastModified returns true if it has taken care of all
|
|
|
|
|
* output to the client that is necessary for this request.
|
|
|
|
|
* (that is, it has sent a cached version of the page)
|
2010-03-15 12:04:24 +00:00
|
|
|
*
|
2014-07-24 17:43:25 +00:00
|
|
|
* @return bool True if cached version send, false otherwise
|
2004-09-03 00:20:26 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function tryFileCache() {
|
2003-11-24 08:41:40 +00:00
|
|
|
static $called = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $called ) {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): called twice!?\n" );
|
2008-09-25 23:02:35 +00:00
|
|
|
return false;
|
2003-11-24 08:41:40 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2003-11-24 08:41:40 +00:00
|
|
|
$called = true;
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $this->isFileCacheable() ) {
|
2014-09-15 22:47:30 +00:00
|
|
|
$cache = new HTMLFileCache( $this->getTitle(), 'view' );
|
2011-09-29 08:18:20 +00:00
|
|
|
if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): about to load file\n" );
|
2011-09-29 08:18:20 +00:00
|
|
|
$cache->loadFromFileCache( $this->getContext() );
|
2003-12-11 20:16:34 +00:00
|
|
|
return true;
|
2003-05-16 13:39:22 +00:00
|
|
|
} else {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): starting buffer\n" );
|
2010-02-14 22:07:30 +00:00
|
|
|
ob_start( array( &$cache, 'saveToFileCache' ) );
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): not cacheable\n" );
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2008-09-25 23:02:35 +00:00
|
|
|
return false;
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-09-03 00:20:26 +00:00
|
|
|
/**
|
|
|
|
|
* Check if the page can be cached
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function isFileCacheable() {
|
2008-12-11 14:29:16 +00:00
|
|
|
$cacheable = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-09-29 08:18:20 +00:00
|
|
|
if ( HTMLFileCache::useFileCache( $this->getContext() ) ) {
|
|
|
|
|
$cacheable = $this->mPage->getID()
|
|
|
|
|
&& !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
|
2008-12-11 14:29:16 +00:00
|
|
|
// Extension may have reason to disable file caching on some pages.
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $cacheable ) {
|
2014-12-09 07:23:30 +00:00
|
|
|
$cacheable = Hooks::run( 'IsFileCacheable', array( &$this ) );
|
2008-09-25 23:02:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2007-04-25 13:07:29 +00:00
|
|
|
return $cacheable;
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-03 00:20:26 +00:00
|
|
|
/**#@-*/
|
2004-08-12 14:27:38 +00:00
|
|
|
|
2011-06-30 07:52:59 +00:00
|
|
|
/**
|
|
|
|
|
* Lightweight method to get the parser output for a page, checking the parser cache
|
|
|
|
|
* and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
|
|
|
|
|
* consider, so it's not appropriate to use there.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.16 (r52326) for LiquidThreads
|
|
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param int|null $oldid Revision ID or null
|
|
|
|
|
* @param User $user The relevant user
|
|
|
|
|
* @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
|
2011-06-30 07:52:59 +00:00
|
|
|
*/
|
|
|
|
|
public function getParserOutput( $oldid = null, User $user = null ) {
|
2012-08-20 17:28:20 +00:00
|
|
|
//XXX: bypasses mParserOptions and thus setParserOptions()
|
|
|
|
|
|
2012-08-11 19:44:12 +00:00
|
|
|
if ( $user === null ) {
|
|
|
|
|
$parserOptions = $this->getParserOptions();
|
|
|
|
|
} else {
|
|
|
|
|
$parserOptions = $this->mPage->makeParserOptions( $user );
|
|
|
|
|
}
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2011-11-17 20:21:54 +00:00
|
|
|
return $this->mPage->getParserOutput( $parserOptions, $oldid );
|
2007-01-10 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-06 13:55:52 +00:00
|
|
|
/**
|
|
|
|
|
* Override the ParserOptions used to render the primary article wikitext.
|
|
|
|
|
*
|
|
|
|
|
* @param ParserOptions $options
|
2014-07-24 17:43:25 +00:00
|
|
|
* @throws MWException If the parser options where already initialized.
|
2012-08-06 13:55:52 +00:00
|
|
|
*/
|
|
|
|
|
public function setParserOptions( ParserOptions $options ) {
|
|
|
|
|
if ( $this->mParserOptions ) {
|
|
|
|
|
throw new MWException( "can't change parser options after they have already been set" );
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 19:33:07 +00:00
|
|
|
// clone, so if $options is modified later, it doesn't confuse the parser cache.
|
|
|
|
|
$this->mParserOptions = clone $options;
|
2012-08-06 13:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-29 17:51:27 +00:00
|
|
|
/**
|
|
|
|
|
* Get parser options suitable for rendering the primary article wikitext
|
2012-02-10 15:37:33 +00:00
|
|
|
* @return ParserOptions
|
2011-09-29 17:51:27 +00:00
|
|
|
*/
|
|
|
|
|
public function getParserOptions() {
|
|
|
|
|
if ( !$this->mParserOptions ) {
|
2012-08-11 19:44:12 +00:00
|
|
|
$this->mParserOptions = $this->mPage->makeParserOptions( $this->getContext() );
|
2011-09-29 17:51:27 +00:00
|
|
|
}
|
|
|
|
|
// Clone to allow modifications of the return value without affecting cache
|
|
|
|
|
return clone $this->mParserOptions;
|
|
|
|
|
}
|
|
|
|
|
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Sets the context this Article is executed in
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
*
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param IContextSource $context
|
2011-06-29 22:09:51 +00:00
|
|
|
* @since 1.18
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function setContext( $context ) {
|
|
|
|
|
$this->mContext = $context;
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the context this Article is executed in
|
|
|
|
|
*
|
2011-09-15 15:19:49 +00:00
|
|
|
* @return IContextSource
|
2011-06-29 22:09:51 +00:00
|
|
|
* @since 1.18
|
|
|
|
|
*/
|
|
|
|
|
public function getContext() {
|
2011-09-15 15:19:49 +00:00
|
|
|
if ( $this->mContext instanceof IContextSource ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
return $this->mContext;
|
|
|
|
|
} else {
|
2014-03-23 01:28:57 +00:00
|
|
|
wfDebug( __METHOD__ . " called and \$mContext is null. " .
|
|
|
|
|
"Return RequestContext::getMain(); for sanity\n" );
|
2011-06-29 22:09:51 +00:00
|
|
|
return RequestContext::getMain();
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* Use PHP's magic __get handler to handle accessing of
|
|
|
|
|
* raw WikiPage fields for backwards compatibility.
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $fname Field name
|
2014-08-23 20:34:25 +00:00
|
|
|
* @return mixed
|
2011-06-29 22:09:51 +00:00
|
|
|
*/
|
|
|
|
|
public function __get( $fname ) {
|
|
|
|
|
if ( property_exists( $this->mPage, $fname ) ) {
|
|
|
|
|
#wfWarn( "Access to raw $fname field " . __CLASS__ );
|
|
|
|
|
return $this->mPage->$fname;
|
2008-03-19 11:19:00 +00:00
|
|
|
}
|
2011-08-16 16:03:29 +00:00
|
|
|
trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* Use PHP's magic __set handler to handle setting of
|
|
|
|
|
* raw WikiPage fields for backwards compatibility.
|
|
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $fname Field name
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param mixed $fvalue New value
|
2011-06-29 22:09:51 +00:00
|
|
|
*/
|
|
|
|
|
public function __set( $fname, $fvalue ) {
|
|
|
|
|
if ( property_exists( $this->mPage, $fname ) ) {
|
|
|
|
|
#wfWarn( "Access to raw $fname field of " . __CLASS__ );
|
|
|
|
|
$this->mPage->$fname = $fvalue;
|
|
|
|
|
// Note: extensions may want to toss on new fields
|
|
|
|
|
} elseif ( !in_array( $fname, array( 'mContext', 'mPage' ) ) ) {
|
|
|
|
|
$this->mPage->$fname = $fvalue;
|
|
|
|
|
} else {
|
2011-09-07 12:54:57 +00:00
|
|
|
trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE );
|
2008-03-19 11:19:00 +00:00
|
|
|
}
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
}
|
2009-12-26 20:03:33 +00:00
|
|
|
|
2010-03-15 12:04:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Use PHP's magic __call handler to transform instance calls to
|
|
|
|
|
* WikiPage functions for backwards compatibility.
|
2010-03-15 12:04:24 +00:00
|
|
|
*
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $fname Name of called method
|
|
|
|
|
* @param array $args Arguments to the method
|
2012-02-09 21:33:27 +00:00
|
|
|
* @return mixed
|
2009-12-26 20:03:33 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function __call( $fname, $args ) {
|
|
|
|
|
if ( is_callable( array( $this->mPage, $fname ) ) ) {
|
|
|
|
|
#wfWarn( "Call to " . __CLASS__ . "::$fname; please use WikiPage instead" );
|
|
|
|
|
return call_user_func_array( array( $this->mPage, $fname ), $args );
|
|
|
|
|
}
|
2011-08-16 16:03:29 +00:00
|
|
|
trigger_error( 'Inaccessible function via __call(): ' . $fname, E_USER_ERROR );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2009-06-23 21:52:39 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
// ****** B/C functions to work-around PHP silliness with __call and references ****** //
|
2011-10-26 03:44:47 +00:00
|
|
|
|
2011-12-18 16:01:31 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param array $limit
|
|
|
|
|
* @param array $expiry
|
|
|
|
|
* @param bool $cascade
|
|
|
|
|
* @param string $reason
|
|
|
|
|
* @param User $user
|
2011-12-18 16:01:31 +00:00
|
|
|
* @return Status
|
|
|
|
|
*/
|
2014-03-23 01:28:57 +00:00
|
|
|
public function doUpdateRestrictions( array $limit, array $expiry, &$cascade,
|
|
|
|
|
$reason, User $user
|
|
|
|
|
) {
|
2011-12-18 16:01:31 +00:00
|
|
|
return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param array $limit
|
|
|
|
|
* @param string $reason
|
|
|
|
|
* @param int $cascade
|
|
|
|
|
* @param array $expiry
|
2011-10-26 03:44:47 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2014-03-23 01:28:57 +00:00
|
|
|
public function updateRestrictions( $limit = array(), $reason = '',
|
|
|
|
|
&$cascade = 0, $expiry = array()
|
|
|
|
|
) {
|
2012-10-09 09:29:09 +00:00
|
|
|
return $this->mPage->doUpdateRestrictions(
|
|
|
|
|
$limit,
|
|
|
|
|
$expiry,
|
|
|
|
|
$cascade,
|
|
|
|
|
$reason,
|
|
|
|
|
$this->getContext()->getUser()
|
|
|
|
|
);
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2009-12-26 20:03:33 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $reason
|
|
|
|
|
* @param bool $suppress
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @param bool $commit
|
|
|
|
|
* @param string $error
|
2011-10-26 03:44:47 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2014-03-23 01:28:57 +00:00
|
|
|
public function doDeleteArticle( $reason, $suppress = false, $id = 0,
|
|
|
|
|
$commit = true, &$error = ''
|
|
|
|
|
) {
|
2011-06-29 22:09:51 +00:00
|
|
|
return $this->mPage->doDeleteArticle( $reason, $suppress, $id, $commit, $error );
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $fromP
|
|
|
|
|
* @param string $summary
|
|
|
|
|
* @param string $token
|
|
|
|
|
* @param bool $bot
|
|
|
|
|
* @param array $resultDetails
|
|
|
|
|
* @param User|null $user
|
2011-10-26 03:44:47 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2011-07-02 15:10:39 +00:00
|
|
|
public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$user = is_null( $user ) ? $this->getContext()->getUser() : $user;
|
2011-07-02 15:10:39 +00:00
|
|
|
return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2009-06-23 21:52:39 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $fromP
|
|
|
|
|
* @param string $summary
|
|
|
|
|
* @param bool $bot
|
|
|
|
|
* @param array $resultDetails
|
|
|
|
|
* @param User|null $guser
|
2011-10-26 03:44:47 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2011-07-02 15:10:39 +00:00
|
|
|
public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
|
2012-04-22 23:42:38 +00:00
|
|
|
$guser = is_null( $guser ) ? $this->getContext()->getUser() : $guser;
|
2011-07-02 15:10:39 +00:00
|
|
|
return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2009-06-23 21:52:39 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param bool $hasHistory
|
2011-10-26 03:44:47 +00:00
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2011-09-07 17:55:37 +00:00
|
|
|
public function generateReason( &$hasHistory ) {
|
2012-04-05 09:51:24 +00:00
|
|
|
$title = $this->mPage->getTitle();
|
|
|
|
|
$handler = ContentHandler::getForTitle( $title );
|
2012-03-20 09:57:41 +00:00
|
|
|
return $handler->getAutoDeleteReason( $title, $hasHistory );
|
2011-09-07 17:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
// ****** B/C functions for static methods ( __callStatic is PHP>=5.3 ) ****** //
|
2011-10-26 03:44:47 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array
|
2014-06-23 23:13:32 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated since 1.24, use WikiPage::selectFields() instead
|
2011-10-26 03:44:47 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function selectFields() {
|
2014-06-23 23:13:32 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.24' );
|
2011-06-29 22:09:51 +00:00
|
|
|
return WikiPage::selectFields();
|
|
|
|
|
}
|
2011-03-04 20:16:35 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title
|
2014-06-23 23:13:32 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated since 1.24, use WikiPage::onArticleCreate() instead
|
2011-10-26 03:44:47 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function onArticleCreate( $title ) {
|
2014-06-23 23:13:32 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.24' );
|
2011-10-29 01:53:28 +00:00
|
|
|
WikiPage::onArticleCreate( $title );
|
2009-06-23 21:52:39 +00:00
|
|
|
}
|
2010-06-28 07:17:16 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title
|
2014-06-23 23:13:32 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated since 1.24, use WikiPage::onArticleDelete() instead
|
2011-10-26 03:44:47 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function onArticleDelete( $title ) {
|
2014-06-23 23:13:32 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.24' );
|
2011-10-29 01:53:28 +00:00
|
|
|
WikiPage::onArticleDelete( $title );
|
2011-04-12 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param Title $title
|
2014-06-23 23:13:32 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated since 1.24, use WikiPage::onArticleEdit() instead
|
2011-10-26 03:44:47 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function onArticleEdit( $title ) {
|
2014-06-23 23:13:32 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.24' );
|
2011-10-29 01:53:28 +00:00
|
|
|
WikiPage::onArticleEdit( $title );
|
2011-04-12 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2014-04-23 09:46:22 +00:00
|
|
|
* @param string $oldtext
|
|
|
|
|
* @param string $newtext
|
|
|
|
|
* @param int $flags
|
2011-10-26 03:44:47 +00:00
|
|
|
* @return string
|
2012-10-05 13:03:24 +00:00
|
|
|
* @deprecated since 1.21, use ContentHandler::getAutosummary() instead
|
2011-10-26 03:44:47 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function getAutosummary( $oldtext, $newtext, $flags ) {
|
|
|
|
|
return WikiPage::getAutosummary( $oldtext, $newtext, $flags );
|
|
|
|
|
}
|
|
|
|
|
// ******
|
2007-07-22 14:45:12 +00:00
|
|
|
}
|