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
|
|
|
*/
|
2019-11-11 21:10:35 +00:00
|
|
|
|
2019-05-13 14:18:07 +00:00
|
|
|
use MediaWiki\Block\DatabaseBlock;
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
|
2019-09-07 09:27:30 +00:00
|
|
|
use MediaWiki\Linker\LinkRenderer;
|
2017-03-17 10:57:37 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2020-09-30 19:25:29 +00:00
|
|
|
use MediaWiki\Page\ParserOutputAccess;
|
2021-03-25 14:14:44 +00:00
|
|
|
use MediaWiki\Permissions\Authority;
|
2021-03-02 23:39:12 +00:00
|
|
|
use MediaWiki\Permissions\PermissionStatus;
|
2018-09-20 17:29:04 +00:00
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
2020-05-01 21:07:41 +00:00
|
|
|
use MediaWiki\Revision\RevisionStore;
|
2018-09-20 17:29:04 +00:00
|
|
|
use MediaWiki\Revision\SlotRecord;
|
2021-06-03 01:33:49 +00:00
|
|
|
use MediaWiki\User\UserIdentity;
|
2021-04-12 14:45:26 +00:00
|
|
|
use MediaWiki\User\UserNameUtils;
|
2021-08-13 14:38:24 +00:00
|
|
|
use MediaWiki\Watchlist\WatchlistManager;
|
2019-06-25 18:53:15 +00:00
|
|
|
use Wikimedia\IPUtils;
|
2020-09-07 09:30:43 +00:00
|
|
|
use Wikimedia\NonSerializable\NonSerializableTrait;
|
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
|
|
|
*
|
|
|
|
|
* 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-02 23:28:24 +00:00
|
|
|
*/
|
2013-02-07 20:46:02 +00:00
|
|
|
class Article implements Page {
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
use ProtectedHookAccessorTrait;
|
2020-09-07 09:30:43 +00:00
|
|
|
use NonSerializableTrait;
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
|
2018-08-16 15:45:10 +00:00
|
|
|
/**
|
|
|
|
|
* @var IContextSource|null The context this Article is executed in.
|
2018-08-14 16:37:30 +00:00
|
|
|
* If null, RequestContext::getMain() is used.
|
2020-03-19 03:23:43 +00:00
|
|
|
* @deprecated since 1.35, must be private, use {@link getContext}
|
2018-08-16 15:45:10 +00:00
|
|
|
*/
|
2011-04-25 11:59:31 +00:00
|
|
|
protected $mContext;
|
2011-04-12 23:00:49 +00:00
|
|
|
|
2020-03-19 03:23:43 +00:00
|
|
|
/** @var WikiPage The WikiPage object of this instance */
|
2011-06-29 22:09:51 +00:00
|
|
|
protected $mPage;
|
|
|
|
|
|
2018-08-14 16:37:30 +00:00
|
|
|
/**
|
|
|
|
|
* @var int|null The oldid of the article that was requested 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
|
|
|
|
2018-08-16 15:45:10 +00:00
|
|
|
/** @var Title|null Title from which we were redirected here, if any. */
|
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
|
|
|
|
2018-08-16 15:45:10 +00:00
|
|
|
/**
|
2018-08-14 16:37:30 +00:00
|
|
|
* @var Status|null represents the outcome of fetchRevisionRecord().
|
|
|
|
|
* $fetchResult->value is the RevisionRecord object, if the operation was successful.
|
|
|
|
|
*/
|
|
|
|
|
private $fetchResult = null;
|
|
|
|
|
|
2018-08-16 15:45:10 +00:00
|
|
|
/**
|
|
|
|
|
* @var ParserOutput|null|false The ParserOutput generated for viewing the page,
|
|
|
|
|
* initialized by view(). If no ParserOutput could be generated, this is set to false.
|
2018-08-14 16:37:30 +00:00
|
|
|
* @deprecated since 1.32
|
2018-08-16 15:45:10 +00:00
|
|
|
*/
|
2018-08-14 16:37:30 +00:00
|
|
|
public $mParserOutput = null;
|
2004-09-02 23:28:24 +00:00
|
|
|
|
2017-11-22 20:07:51 +00:00
|
|
|
/**
|
|
|
|
|
* @var bool Whether render() was called. With the way subclasses work
|
|
|
|
|
* here, there doesn't seem to be any other way to stop calling
|
|
|
|
|
* OutputPage::enableSectionEditLinks() and still have it work as it did before.
|
|
|
|
|
*/
|
2018-10-18 03:06:23 +00:00
|
|
|
protected $viewIsRenderAction = false;
|
2017-11-22 20:07:51 +00:00
|
|
|
|
2019-09-07 09:27:30 +00:00
|
|
|
/**
|
|
|
|
|
* @var LinkRenderer
|
|
|
|
|
*/
|
|
|
|
|
protected $linkRenderer;
|
|
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
/**
|
|
|
|
|
* @var RevisionStore
|
|
|
|
|
*/
|
|
|
|
|
private $revisionStore;
|
|
|
|
|
|
2021-08-13 14:38:24 +00:00
|
|
|
/**
|
|
|
|
|
* @var WatchlistManager
|
|
|
|
|
*/
|
|
|
|
|
private $watchlistManager;
|
|
|
|
|
|
2021-04-12 14:45:26 +00:00
|
|
|
/**
|
|
|
|
|
* @var UserNameUtils
|
|
|
|
|
*/
|
|
|
|
|
private $userNameUtils;
|
|
|
|
|
|
2020-07-23 09:41:58 +00:00
|
|
|
/**
|
2020-05-01 21:07:41 +00:00
|
|
|
* @var RevisionRecord|null Revision to be shown
|
|
|
|
|
*
|
2020-11-05 19:31:26 +00:00
|
|
|
* Initialized by getOldIDFromRequest() or fetchRevisionRecord(). While the output of
|
|
|
|
|
* Article::view is typically based on this revision, it may be replaced by extensions.
|
2020-05-01 21:07:41 +00:00
|
|
|
*/
|
|
|
|
|
private $mRevisionRecord = null;
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2020-03-05 15:05:35 +00:00
|
|
|
* @param Title $title
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param int|null $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 );
|
2020-02-15 00:43:48 +00:00
|
|
|
|
|
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
$this->linkRenderer = $services->getLinkRenderer();
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->revisionStore = $services->getRevisionStore();
|
2021-08-13 14:38:24 +00:00
|
|
|
$this->watchlistManager = $services->getWatchlistManager();
|
2021-04-12 14:45:26 +00:00
|
|
|
$this->userNameUtils = $services->getUserNameUtils();
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
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 );
|
2016-09-13 04:24:50 +00:00
|
|
|
return $t == null ? null : new static( $t );
|
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 ) {
|
2020-07-22 17:29:48 +00:00
|
|
|
if ( $title->getNamespace() === NS_MEDIA ) {
|
2018-08-14 16:37:30 +00:00
|
|
|
// XXX: This should not be here, but where should it go?
|
2011-05-22 18:38:04 +00:00
|
|
|
$title = Title::makeTitle( NS_FILE, $title->getDBkey() );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-28 03:51:00 +00:00
|
|
|
$page = null;
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
Hooks::runner()->onArticleFromTitle( $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;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 00:19:58 +00:00
|
|
|
/**
|
|
|
|
|
* Get the page this view was redirected from
|
|
|
|
|
* @return Title|null
|
|
|
|
|
* @since 1.28
|
|
|
|
|
*/
|
|
|
|
|
public function getRedirectedFrom() {
|
|
|
|
|
return $this->mRedirectedFrom;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function clear() {
|
2006-01-13 00:29:20 +00:00
|
|
|
$this->mRedirectedFrom = null; # Title object if set
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mRedirectUrl = false;
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mRevisionRecord = null;
|
2018-08-14 16:37:30 +00:00
|
|
|
$this->fetchResult = null;
|
|
|
|
|
|
|
|
|
|
// TODO hard-deprecate direct access to public fields
|
2011-06-29 22:09:51 +00:00
|
|
|
|
|
|
|
|
$this->mPage->clear();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-14 16:37:30 +00:00
|
|
|
/**
|
|
|
|
|
* @see getOldIDFromRequest()
|
|
|
|
|
* @see getRevIdFetched()
|
|
|
|
|
*
|
|
|
|
|
* @return int The oldid of the article that is was requested in the constructor or via the
|
|
|
|
|
* context's WebRequest.
|
2004-11-13 08:40:34 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getOldID() {
|
2020-01-09 23:48:34 +00:00
|
|
|
if ( $this->mOldId === null ) {
|
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() ) {
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mRevisionRecord = $this->mPage->getRevisionRecord();
|
2012-03-09 14:50:39 +00:00
|
|
|
} else {
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mRevisionRecord = $this->revisionStore->getRevisionById( $oldid );
|
|
|
|
|
if ( $this->mRevisionRecord !== null ) {
|
|
|
|
|
$revPageId = $this->mRevisionRecord->getPageId();
|
2012-03-09 14:50:39 +00:00
|
|
|
// Revision title doesn't match the page title given?
|
2020-05-01 21:07:41 +00:00
|
|
|
if ( $this->mPage->getId() != $revPageId ) {
|
2018-09-07 17:01:32 +00:00
|
|
|
$function = get_class( $this->mPage ) . '::newFromID';
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mPage = $function( $revPageId );
|
2012-03-09 14:50:39 +00:00
|
|
|
}
|
2004-10-02 21:36:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
$oldRev = $this->mRevisionRecord;
|
2021-08-10 21:59:39 +00:00
|
|
|
if ( $request->getRawVal( 'direction' ) === 'next' ) {
|
2019-08-27 02:45:33 +00:00
|
|
|
$nextid = 0;
|
|
|
|
|
if ( $oldRev ) {
|
2020-05-01 21:07:41 +00:00
|
|
|
$nextRev = $this->revisionStore->getNextRevision( $oldRev );
|
2019-08-27 02:45:33 +00:00
|
|
|
if ( $nextRev ) {
|
|
|
|
|
$nextid = $nextRev->getId();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $nextid ) {
|
|
|
|
|
$oldid = $nextid;
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mRevisionRecord = null;
|
2011-11-14 18:05:55 +00:00
|
|
|
} else {
|
|
|
|
|
$this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
|
|
|
|
|
}
|
2021-08-10 21:59:39 +00:00
|
|
|
} elseif ( $request->getRawVal( 'direction' ) === 'prev' ) {
|
2019-08-27 02:45:33 +00:00
|
|
|
$previd = 0;
|
|
|
|
|
if ( $oldRev ) {
|
2020-05-01 21:07:41 +00:00
|
|
|
$prevRev = $this->revisionStore->getPreviousRevision( $oldRev );
|
2019-08-27 02:45:33 +00:00
|
|
|
if ( $prevRev ) {
|
|
|
|
|
$previd = $prevRev->getId();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $previd ) {
|
|
|
|
|
$oldid = $previd;
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mRevisionRecord = 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
|
|
|
}
|
|
|
|
|
|
2018-08-14 16:37:30 +00:00
|
|
|
/**
|
|
|
|
|
* Fetches the revision to work on.
|
2020-11-05 19:31:26 +00:00
|
|
|
* The revision is loaded from the database. Refer to $this->fetchResult for the revision
|
|
|
|
|
* or any errors encountered while loading it.
|
2018-08-14 16:37:30 +00:00
|
|
|
*
|
2020-04-10 04:37:43 +00:00
|
|
|
* Public since 1.35
|
|
|
|
|
*
|
2018-08-14 16:37:30 +00:00
|
|
|
* @return RevisionRecord|null
|
|
|
|
|
*/
|
2020-04-10 04:37:43 +00:00
|
|
|
public function fetchRevisionRecord() {
|
2018-08-14 16:37:30 +00:00
|
|
|
if ( $this->fetchResult ) {
|
2020-05-01 21:07:41 +00:00
|
|
|
return $this->mRevisionRecord;
|
2012-04-05 09:51:24 +00:00
|
|
|
}
|
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
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
// $this->mRevisionRecord might already be fetched by getOldIDFromRequest()
|
|
|
|
|
if ( !$this->mRevisionRecord ) {
|
2018-08-14 16:37:30 +00:00
|
|
|
if ( !$oldid ) {
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mRevisionRecord = $this->mPage->getRevisionRecord();
|
2018-08-14 16:37:30 +00:00
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
if ( !$this->mRevisionRecord ) {
|
2018-08-14 16:37:30 +00:00
|
|
|
wfDebug( __METHOD__ . " failed to find page data for title " .
|
2020-06-01 05:00:39 +00:00
|
|
|
$this->getTitle()->getPrefixedText() );
|
2012-03-05 15:53:25 +00:00
|
|
|
|
2018-08-14 16:37:30 +00:00
|
|
|
// Just for sanity, output for this case is done by showMissingArticle().
|
|
|
|
|
$this->fetchResult = Status::newFatal( 'noarticletext' );
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2020-05-01 21:07:41 +00:00
|
|
|
$this->mRevisionRecord = $this->revisionStore->getRevisionById( $oldid );
|
2018-08-14 16:37:30 +00:00
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
if ( !$this->mRevisionRecord ) {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . " failed to load revision, rev_id $oldid" );
|
2018-08-14 16:37:30 +00:00
|
|
|
|
|
|
|
|
$this->fetchResult = Status::newFatal( 'missing-revision', $oldid );
|
|
|
|
|
return null;
|
2012-04-05 09:51:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-08-14 16:37:30 +00:00
|
|
|
}
|
|
|
|
|
|
2021-02-24 15:46:13 +00:00
|
|
|
if ( !$this->mRevisionRecord->userCan( RevisionRecord::DELETED_TEXT, $this->getContext()->getAuthority() ) ) {
|
2021-05-07 09:44:30 +00:00
|
|
|
wfDebug( __METHOD__ . " failed to retrieve content of revision " . $this->mRevisionRecord->getId() );
|
2018-08-14 16:37:30 +00:00
|
|
|
|
|
|
|
|
// Just for sanity, output for this case is done by showDeletedRevisionHeader().
|
2020-10-05 16:49:30 +00:00
|
|
|
// title used in wikilinks, should not contain whitespaces
|
2021-05-07 09:44:30 +00:00
|
|
|
$this->fetchResult = new Status;
|
|
|
|
|
$title = $this->getTitle()->getPrefixedDBkey();
|
|
|
|
|
|
|
|
|
|
if ( $this->mRevisionRecord->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ) {
|
|
|
|
|
$this->fetchResult->fatal( 'rev-suppressed-text' );
|
|
|
|
|
} else {
|
|
|
|
|
$this->fetchResult->fatal( 'rev-deleted-text-permission', $title );
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-14 16:37:30 +00:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 19:31:26 +00:00
|
|
|
$this->fetchResult = Status::newGood( $this->mRevisionRecord );
|
2020-05-01 21:07:41 +00:00
|
|
|
return $this->mRevisionRecord;
|
2018-08-14 16:37:30 +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
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
return $this->mPage->exists() &&
|
|
|
|
|
$this->mRevisionRecord &&
|
|
|
|
|
$this->mRevisionRecord->isCurrent();
|
2005-06-29 23:44:03 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
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
|
|
|
*
|
2018-08-14 16:37:30 +00:00
|
|
|
* Before fetchRevisionRecord was called, this returns the page's latest revision,
|
|
|
|
|
* regardless of what getOldID() returns.
|
|
|
|
|
*
|
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() {
|
2018-08-14 16:37:30 +00:00
|
|
|
if ( $this->fetchResult && $this->fetchResult->isOK() ) {
|
|
|
|
|
return $this->fetchResult->value->getId();
|
2011-06-29 22:09:51 +00:00
|
|
|
} 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() {
|
2020-11-10 14:51:26 +00:00
|
|
|
global $wgUseFileCache;
|
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();
|
2021-04-18 15:49:35 +00:00
|
|
|
# Another check in case getOldID() is altering the title
|
2021-03-02 23:39:12 +00:00
|
|
|
$permissionStatus = PermissionStatus::newEmpty();
|
|
|
|
|
if ( !$this->getContext()->getAuthority()
|
|
|
|
|
->authorizeRead( 'read', $this->getTitle(), $permissionStatus )
|
|
|
|
|
) {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . ": denied on secondary read check" );
|
2021-03-02 23:39:12 +00:00
|
|
|
throw new PermissionsError( 'read', $permissionStatus );
|
2011-11-14 18:05:55 +00:00
|
|
|
}
|
|
|
|
|
|
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 );
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . ": redirecting due to oldid" );
|
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' ) ) {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . ": showing diff page" );
|
2011-06-29 22:09:51 +00:00
|
|
|
$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
|
2021-09-29 20:58:59 +00:00
|
|
|
$outputPage->setPreventClickjacking( false );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2021-10-27 22:26:16 +00:00
|
|
|
$skin = $outputPage->getSkin();
|
|
|
|
|
$skinOptions = $skin->getOptions();
|
|
|
|
|
|
2011-09-29 17:51:27 +00:00
|
|
|
$parserOptions = $this->getParserOptions();
|
2021-10-27 22:26:16 +00:00
|
|
|
$poOptions = [
|
|
|
|
|
'skin' => $skin,
|
|
|
|
|
'injectTOC' => $skinOptions['toc'],
|
|
|
|
|
];
|
2020-12-01 17:53:48 +00:00
|
|
|
# Allow extensions to vary parser options used for article rendering
|
|
|
|
|
Hooks::runner()->onArticleParserOptions( $this, $parserOptions );
|
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 );
|
2017-11-22 20:07:51 +00:00
|
|
|
$poOptions['enableSectionEditLinks'] = false;
|
2020-07-08 16:40:04 +00:00
|
|
|
$outputPage->prependHTML(
|
|
|
|
|
Html::warningBox(
|
|
|
|
|
$outputPage->msg( 'printableversion-deprecated-warning' )->escaped()
|
|
|
|
|
)
|
|
|
|
|
);
|
2019-08-23 23:53:15 +00:00
|
|
|
} elseif ( $this->viewIsRenderAction || !$this->isCurrent() ||
|
2021-03-02 23:39:12 +00:00
|
|
|
!$this->getContext()->getAuthority()->probablyCan( 'edit', $this->getTitle() )
|
2017-11-22 20:07:51 +00:00
|
|
|
) {
|
|
|
|
|
$poOptions['enableSectionEditLinks'] = 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
|
2019-08-31 22:43:23 +00:00
|
|
|
if ( $oldid === 0 && $this->mPage->checkTouched() ) {
|
2016-08-24 06:53:31 +00:00
|
|
|
# Try to stream the output from file cache
|
|
|
|
|
if ( $wgUseFileCache && $this->tryFileCache() ) {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( __METHOD__ . ": done file cache" );
|
2011-06-29 22:09:51 +00:00
|
|
|
# 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
|
|
|
|
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
|
|
|
|
2021-09-21 14:34:30 +00:00
|
|
|
if ( $this->viewIsRenderAction ) {
|
|
|
|
|
$poOptions += [ 'absoluteURLs' => true ];
|
|
|
|
|
}
|
2020-11-10 14:51:26 +00:00
|
|
|
$continue =
|
|
|
|
|
$this->generateContentOutput( $user, $parserOptions, $oldid, $outputPage, $poOptions );
|
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
|
|
|
|
2020-11-10 14:51:26 +00:00
|
|
|
if ( !$continue ) {
|
|
|
|
|
return;
|
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() ) {
|
2021-05-13 20:15:25 +00:00
|
|
|
$outputPage->setHTMLTitle( $msg->page( $this->getTitle() )->text() );
|
2011-02-17 17:06:06 +00:00
|
|
|
}
|
2010-04-11 13:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-23 04:10:13 +00:00
|
|
|
# Use adaptive TTLs for CDN so delayed/failed purges are noticed less often.
|
|
|
|
|
# This could use getTouched(), but that could be scary for major template edits.
|
|
|
|
|
$outputPage->adaptCdnTTL( $this->mPage->getTimestamp(), IExpiringStore::TTL_DAY );
|
|
|
|
|
|
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();
|
2018-08-14 16:37:30 +00:00
|
|
|
$this->mPage->doViewUpdates( $user, $oldid ); // FIXME: test this
|
2011-09-24 21:12:26 +00:00
|
|
|
|
2017-04-29 19:00:04 +00:00
|
|
|
# Load the postEdit module if the user just saved this revision
|
|
|
|
|
# See also EditPage::setPostEditCookie
|
|
|
|
|
$request = $this->getContext()->getRequest();
|
|
|
|
|
$cookieKey = EditPage::POST_EDIT_COOKIE_KEY_PREFIX . $this->getRevIdFetched();
|
|
|
|
|
$postEdit = $request->getCookie( $cookieKey );
|
|
|
|
|
if ( $postEdit ) {
|
|
|
|
|
# Clear the cookie. This also prevents caching of the response.
|
|
|
|
|
$request->response()->clearCookie( $cookieKey );
|
|
|
|
|
$outputPage->addJsConfigVars( 'wgPostEdit', $postEdit );
|
2018-08-14 16:37:30 +00:00
|
|
|
$outputPage->addModules( 'mediawiki.action.view.postEdit' ); // FIXME: test this
|
2017-04-29 19:00: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
|
|
|
}
|
|
|
|
|
|
2020-11-10 14:51:26 +00:00
|
|
|
/**
|
|
|
|
|
* Determines the desired ParserOutput and passes it to $outputPage.
|
|
|
|
|
*
|
2021-03-25 14:14:44 +00:00
|
|
|
* @param Authority $performer
|
2020-11-10 14:51:26 +00:00
|
|
|
* @param ParserOptions $parserOptions
|
|
|
|
|
* @param int $oldid
|
|
|
|
|
* @param OutputPage $outputPage
|
|
|
|
|
* @param array $textOptions
|
|
|
|
|
*
|
|
|
|
|
* @return bool True if further processing like footer generation should be applied,
|
|
|
|
|
* false to skip further processing.
|
|
|
|
|
*/
|
|
|
|
|
private function generateContentOutput(
|
2021-03-25 14:14:44 +00:00
|
|
|
Authority $performer,
|
2020-11-10 14:51:26 +00:00
|
|
|
ParserOptions $parserOptions,
|
|
|
|
|
int $oldid,
|
|
|
|
|
OutputPage $outputPage,
|
|
|
|
|
array $textOptions
|
|
|
|
|
): bool {
|
|
|
|
|
# Should the parser cache be used?
|
2020-12-07 19:48:33 +00:00
|
|
|
$useParserCache = true;
|
2020-11-10 14:51:26 +00:00
|
|
|
$pOutput = null;
|
2020-12-07 19:48:33 +00:00
|
|
|
$parserOutputAccess = MediaWikiServices::getInstance()->getParserOutputAccess();
|
2020-11-10 14:51:26 +00:00
|
|
|
|
|
|
|
|
// NOTE: $outputDone and $useParserCache may be changed by the hook
|
|
|
|
|
$this->getHookRunner()->onArticleViewHeader( $this, $outputDone, $useParserCache );
|
|
|
|
|
if ( $outputDone ) {
|
|
|
|
|
if ( $outputDone instanceof ParserOutput ) {
|
|
|
|
|
$pOutput = $outputDone;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $pOutput ) {
|
|
|
|
|
$this->doOutputMetaData( $pOutput, $outputPage );
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Early abort if the page doesn't exist
|
|
|
|
|
if ( !$this->mPage->exists() ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing missing article" );
|
|
|
|
|
$this->showMissingArticle();
|
2021-03-25 14:14:44 +00:00
|
|
|
$this->mPage->doViewUpdates( $performer );
|
2020-11-10 14:51:26 +00:00
|
|
|
return false; // skip all further output to OutputPage
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-07 19:48:33 +00:00
|
|
|
// Try the latest parser cache
|
|
|
|
|
// NOTE: try latest-revision cache first to avoid loading revision.
|
|
|
|
|
if ( $useParserCache && !$oldid ) {
|
2020-11-10 14:51:26 +00:00
|
|
|
$pOutput = $parserOutputAccess->getCachedParserOutput(
|
|
|
|
|
$this->getPage(),
|
|
|
|
|
$parserOptions,
|
|
|
|
|
null,
|
|
|
|
|
ParserOutputAccess::OPT_NO_AUDIENCE_CHECK // we already checked
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( $pOutput ) {
|
2020-12-09 03:09:26 +00:00
|
|
|
$this->doOutputFromParserCache( $pOutput, $outputPage, $textOptions );
|
2020-11-10 14:51:26 +00:00
|
|
|
$this->doOutputMetaData( $pOutput, $outputPage );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rev = $this->fetchRevisionRecord();
|
|
|
|
|
if ( !$this->fetchResult->isOK() ) {
|
|
|
|
|
$this->showViewError( $this->fetchResult->getWikiText(
|
|
|
|
|
false, false, $this->getContext()->getLanguage()
|
|
|
|
|
) );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Are we looking at an old revision
|
|
|
|
|
if ( $oldid ) {
|
|
|
|
|
$this->setOldSubtitle( $oldid );
|
|
|
|
|
|
|
|
|
|
if ( !$this->showDeletedRevisionHeader() ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": cannot view deleted revision" );
|
|
|
|
|
return false; // skip all further output to OutputPage
|
|
|
|
|
}
|
2020-12-07 19:48:33 +00:00
|
|
|
|
|
|
|
|
// Try the old revision parser cache
|
|
|
|
|
// NOTE: Repeating cache check for old revision to avoid fetching $rev
|
|
|
|
|
// before it's absolutely necessary.
|
|
|
|
|
if ( $useParserCache ) {
|
|
|
|
|
$pOutput = $parserOutputAccess->getCachedParserOutput(
|
|
|
|
|
$this->getPage(),
|
|
|
|
|
$parserOptions,
|
|
|
|
|
$rev,
|
|
|
|
|
ParserOutputAccess::OPT_NO_AUDIENCE_CHECK // we already checked in fetchRevisionRevord
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( $pOutput ) {
|
2020-12-09 03:09:26 +00:00
|
|
|
$this->doOutputFromParserCache( $pOutput, $outputPage, $textOptions );
|
2020-12-07 19:48:33 +00:00
|
|
|
$this->doOutputMetaData( $pOutput, $outputPage );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-10 14:51:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Ensure that UI elements requiring revision ID have
|
|
|
|
|
# the correct version information.
|
|
|
|
|
$outputPage->setRevisionId( $this->getRevIdFetched() );
|
|
|
|
|
# Preload timestamp to avoid a DB hit
|
2021-05-12 13:14:34 +00:00
|
|
|
$outputPage->setRevisionTimestamp( $rev->getTimestamp() );
|
2020-11-10 14:51:26 +00:00
|
|
|
|
|
|
|
|
# Pages containing custom CSS or JavaScript get special treatment
|
|
|
|
|
if ( $this->getTitle()->isSiteConfigPage() || $this->getTitle()->isUserConfigPage() ) {
|
|
|
|
|
$dir = $this->getContext()->getLanguage()->getDir();
|
|
|
|
|
$lang = $this->getContext()->getLanguage()->getHtmlCode();
|
|
|
|
|
|
|
|
|
|
$outputPage->wrapWikiMsg(
|
|
|
|
|
"<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
|
|
|
|
|
'clearyourcache'
|
|
|
|
|
);
|
2021-03-26 16:33:51 +00:00
|
|
|
$outputPage->addModuleStyles( 'mediawiki.action.styles' );
|
2020-11-10 14:51:26 +00:00
|
|
|
} elseif ( !$this->getHookRunner()->onArticleRevisionViewCustom(
|
|
|
|
|
$rev,
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
$oldid,
|
|
|
|
|
$outputPage )
|
|
|
|
|
) {
|
|
|
|
|
// NOTE: sync with hooks called in DifferenceEngine::renderNewRevision()
|
|
|
|
|
// Allow extensions do their own custom view for certain pages
|
|
|
|
|
$this->doOutputMetaData( $pOutput, $outputPage );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Run the parse, protected by a pool counter
|
|
|
|
|
wfDebug( __METHOD__ . ": doing uncached parse" );
|
|
|
|
|
|
|
|
|
|
if ( !$rev ) {
|
|
|
|
|
// No revision, abort! Shouldn't happen.
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$opt = 0;
|
|
|
|
|
|
|
|
|
|
// we already checked the cache in case 2, don't check again.
|
|
|
|
|
$opt |= ParserOutputAccess::OPT_NO_CHECK_CACHE;
|
|
|
|
|
|
|
|
|
|
// we already checked in fetchRevisionRecord()
|
|
|
|
|
$opt |= ParserOutputAccess::OPT_NO_AUDIENCE_CHECK;
|
|
|
|
|
|
|
|
|
|
if ( !$rev->getId() || !$useParserCache ) {
|
|
|
|
|
// fake revision or uncacheable options
|
|
|
|
|
$opt |= ParserOutputAccess::OPT_NO_CACHE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$renderStatus = $parserOutputAccess->getParserOutput(
|
|
|
|
|
$this->getPage(),
|
|
|
|
|
$parserOptions,
|
|
|
|
|
$rev,
|
|
|
|
|
$opt
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->doOutputFromRenderStatus(
|
|
|
|
|
$rev,
|
|
|
|
|
$renderStatus,
|
|
|
|
|
$outputPage,
|
|
|
|
|
$textOptions
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( !$renderStatus->isOK() ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pOutput = $renderStatus->getValue();
|
|
|
|
|
$this->doOutputMetaData( $pOutput, $outputPage );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param ?ParserOutput $pOutput
|
|
|
|
|
* @param OutputPage $outputPage
|
|
|
|
|
*/
|
|
|
|
|
private function doOutputMetaData( ?ParserOutput $pOutput, OutputPage $outputPage ) {
|
|
|
|
|
# Adjust title for main page & pages with displaytitle
|
|
|
|
|
if ( $pOutput ) {
|
|
|
|
|
$this->adjustDisplayTitle( $pOutput );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check for any __NOINDEX__ tags on the page using $pOutput
|
|
|
|
|
$policy = $this->getRobotPolicy( 'view', $pOutput ?: null );
|
|
|
|
|
$outputPage->setIndexPolicy( $policy['index'] );
|
|
|
|
|
$outputPage->setFollowPolicy( $policy['follow'] ); // FIXME: test this
|
|
|
|
|
|
|
|
|
|
$this->mParserOutput = $pOutput;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param ParserOutput $pOutput
|
|
|
|
|
* @param OutputPage $outputPage
|
|
|
|
|
* @param array $textOptions
|
|
|
|
|
*/
|
|
|
|
|
private function doOutputFromParserCache(
|
|
|
|
|
ParserOutput $pOutput,
|
|
|
|
|
OutputPage $outputPage,
|
|
|
|
|
array $textOptions
|
|
|
|
|
) {
|
|
|
|
|
# Ensure that UI elements requiring revision ID have
|
|
|
|
|
# the correct version information.
|
2021-05-11 13:23:03 +00:00
|
|
|
$outputPage->setRevisionId( $pOutput->getCacheRevisionId() ?? $this->getRevIdFetched() );
|
2021-09-15 01:00:06 +00:00
|
|
|
# Ensure that the skin has the necessary ToC information
|
|
|
|
|
# (and do this before OutputPage::addParserOutput() calls the
|
|
|
|
|
# OutputPageParserOutput hook)
|
|
|
|
|
$outputPage->setSections( $pOutput->getSections() );
|
2021-10-27 22:26:16 +00:00
|
|
|
$outputPage->addParserOutput( $pOutput, $textOptions );
|
2020-11-10 14:51:26 +00:00
|
|
|
# Preload timestamp to avoid a DB hit
|
|
|
|
|
$cachedTimestamp = $pOutput->getTimestamp();
|
|
|
|
|
if ( $cachedTimestamp !== null ) {
|
|
|
|
|
$outputPage->setRevisionTimestamp( $cachedTimestamp );
|
|
|
|
|
$this->mPage->setTimestamp( $cachedTimestamp );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param RevisionRecord|null $rev
|
|
|
|
|
* @param Status $renderStatus
|
|
|
|
|
* @param OutputPage $outputPage
|
|
|
|
|
* @param array $textOptions
|
|
|
|
|
*/
|
|
|
|
|
private function doOutputFromRenderStatus(
|
|
|
|
|
?RevisionRecord $rev,
|
|
|
|
|
Status $renderStatus,
|
|
|
|
|
OutputPage $outputPage,
|
|
|
|
|
array $textOptions
|
|
|
|
|
) {
|
|
|
|
|
global $wgCdnMaxageStale;
|
|
|
|
|
$ok = $renderStatus->isOK();
|
|
|
|
|
|
|
|
|
|
$pOutput = $ok ? $renderStatus->getValue() : null;
|
|
|
|
|
|
|
|
|
|
// Cache stale ParserOutput object with a short expiry
|
|
|
|
|
if ( $ok && $renderStatus->hasMessage( 'view-pool-dirty-output' ) ) {
|
|
|
|
|
$outputPage->setCdnMaxage( $wgCdnMaxageStale );
|
|
|
|
|
$outputPage->setLastModified( $pOutput->getCacheTime() );
|
|
|
|
|
$staleReason = $renderStatus->hasMessage( 'view-pool-contention' )
|
|
|
|
|
? $this->getContext()->msg( 'view-pool-contention' )
|
|
|
|
|
: $this->getContext()->msg( 'view-pool-timeout' );
|
|
|
|
|
$outputPage->addHTML( "<!-- parser cache is expired, " .
|
|
|
|
|
"sending anyway due to $staleReason-->\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$renderStatus->isOK() ) {
|
|
|
|
|
$this->showViewError( $renderStatus->getWikiText(
|
|
|
|
|
false, 'view-pool-error', $this->getContext()->getLanguage()
|
|
|
|
|
) );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $pOutput ) {
|
|
|
|
|
$outputPage->addParserOutput( $pOutput, $textOptions );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->getRevisionRedirectTarget( $rev ) ) {
|
|
|
|
|
$outputPage->addSubtitle( "<span id=\"redirectsub\">" .
|
|
|
|
|
$this->getContext()->msg( 'redirectpagesub' )->parse() . "</span>" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-14 16:37:30 +00:00
|
|
|
/**
|
|
|
|
|
* @param RevisionRecord $revision
|
|
|
|
|
* @return null|Title
|
|
|
|
|
*/
|
|
|
|
|
private function getRevisionRedirectTarget( RevisionRecord $revision ) {
|
|
|
|
|
// TODO: find a *good* place for the code that determines the redirect target for
|
|
|
|
|
// a given revision!
|
|
|
|
|
// NOTE: Use main slot content. Compare code in DerivedPageDataUpdater::revisionIsRedirect.
|
2018-09-24 21:10:08 +00:00
|
|
|
$content = $revision->getContent( SlotRecord::MAIN );
|
2018-08-14 16:37:30 +00:00
|
|
|
return $content ? $content->getRedirectTarget() : null;
|
|
|
|
|
}
|
|
|
|
|
|
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 ) {
|
2016-11-09 06:24:57 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
|
|
|
|
|
2011-09-24 21:12:26 +00:00
|
|
|
# Adjust the title if it was set by displaytitle, -{T|}- or language conversion
|
|
|
|
|
$titleText = $pOutput->getTitleText();
|
|
|
|
|
if ( strval( $titleText ) !== '' ) {
|
2016-11-09 06:24:57 +00:00
|
|
|
$out->setPageTitle( $titleText );
|
|
|
|
|
$out->setDisplayTitle( $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.
|
|
|
|
|
*/
|
2015-01-04 07:02:49 +00:00
|
|
|
protected 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' ) );
|
2021-08-10 21:59:39 +00:00
|
|
|
$purge = $request->getRawVal( 'action' ) === 'purge';
|
2012-04-22 23:42:38 +00:00
|
|
|
$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();
|
|
|
|
|
|
2020-04-10 04:37:43 +00:00
|
|
|
$rev = $this->fetchRevisionRecord();
|
2012-08-24 18:49:19 +00:00
|
|
|
|
|
|
|
|
if ( !$rev ) {
|
2020-04-12 08:43:57 +00:00
|
|
|
// T213621: $rev maybe null due to either lack of permission to view the
|
|
|
|
|
// revision or actually not existing. So let's try loading it from the id
|
2020-11-14 01:52:36 +00:00
|
|
|
$rev = $this->revisionStore->getRevisionById( $oldid );
|
2020-04-12 08:43:57 +00:00
|
|
|
if ( $rev ) {
|
|
|
|
|
// Revision exists but $user lacks permission to diff it.
|
|
|
|
|
// Do nothing here.
|
|
|
|
|
// The $rev will later be used to create standard diff elements however.
|
|
|
|
|
} else {
|
|
|
|
|
$this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
|
|
|
|
|
$msg = $this->getContext()->msg( 'difference-missing-revision' )
|
|
|
|
|
->params( $oldid )
|
|
|
|
|
->numParams( 1 )
|
|
|
|
|
->parseAsBlock();
|
|
|
|
|
$this->getContext()->getOutput()->addHTML( $msg );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-08-24 18:49:19 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-10 04:37:43 +00:00
|
|
|
$contentHandler = MediaWikiServices::getInstance()
|
|
|
|
|
->getContentHandlerFactory()
|
|
|
|
|
->getContentHandler(
|
|
|
|
|
$rev->getSlot( SlotRecord::MAIN, RevisionRecord::RAW )->getModel()
|
|
|
|
|
);
|
2014-03-23 01:28:57 +00:00
|
|
|
$de = $contentHandler->createDifferenceEngine(
|
|
|
|
|
$this->getContext(),
|
|
|
|
|
$oldid,
|
|
|
|
|
$diff,
|
|
|
|
|
$rcid,
|
|
|
|
|
$purge,
|
|
|
|
|
$unhide
|
|
|
|
|
);
|
2019-10-29 23:30:32 +00:00
|
|
|
$de->setSlotDiffOptions( [
|
|
|
|
|
'diff-type' => $request->getVal( 'diff-type' )
|
|
|
|
|
] );
|
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
|
|
|
$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-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
|
2020-10-28 10:01:33 +00:00
|
|
|
* @return string[] 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
|
|
|
*/
|
2018-07-27 20:20:39 +00:00
|
|
|
public function getRobotPolicy( $action, ParserOutput $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
|
|
|
|
2017-02-20 22:44:19 +00:00
|
|
|
# Don't index user and user talk pages for blocked users (T13443)
|
2020-07-22 17:29:48 +00:00
|
|
|
if ( ( $ns === NS_USER || $ns === NS_USER_TALK ) && !$this->getTitle()->isSubpage() ) {
|
2013-01-11 10:30:21 +00:00
|
|
|
$specificTarget = null;
|
|
|
|
|
$vagueTarget = null;
|
|
|
|
|
$titleText = $this->getTitle()->getText();
|
2019-06-25 18:53:15 +00:00
|
|
|
if ( IPUtils::isValid( $titleText ) ) {
|
2013-01-11 10:30:21 +00:00
|
|
|
$vagueTarget = $titleText;
|
|
|
|
|
} else {
|
|
|
|
|
$specificTarget = $titleText;
|
|
|
|
|
}
|
2019-05-13 14:18:07 +00:00
|
|
|
if ( DatabaseBlock::newFromTarget( $specificTarget, $vagueTarget ) instanceof DatabaseBlock ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2013-01-11 10:30:21 +00:00
|
|
|
'follow' => 'nofollow'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2009-01-14 23:42:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2016-03-19 00:08:06 +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
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2010-05-30 14:28:54 +00:00
|
|
|
'follow' => 'nofollow'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
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
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2010-05-30 14:28:54 +00:00
|
|
|
'follow' => 'follow'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
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
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2013-04-20 22:49:30 +00:00
|
|
|
'index' => 'noindex',
|
2010-05-30 14:28:54 +00:00
|
|
|
'follow' => 'follow'
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
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,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ '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()] ) ) {
|
2017-02-20 22:44:19 +00:00
|
|
|
# (T16900) 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 ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [];
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$policy = explode( ',', $policy );
|
|
|
|
|
$policy = array_map( 'trim', $policy );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$arr = [];
|
2010-02-14 22:07:30 +00:00
|
|
|
foreach ( $policy as $var ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
if ( in_array( $var, [ 'index', 'noindex' ] ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$arr['index'] = $var;
|
2016-02-17 09:09:32 +00:00
|
|
|
} elseif ( in_array( $var, [ '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;
|
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
|
|
|
|
2015-01-28 18:02:42 +00:00
|
|
|
$context = $this->getContext();
|
|
|
|
|
$outputPage = $context->getOutput();
|
|
|
|
|
$request = $context->getRequest();
|
2014-07-08 00:50:37 +00:00
|
|
|
$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.
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
if ( $this->getHookRunner()->onArticleViewRedirect( $this ) ) {
|
2019-09-07 09:27:30 +00:00
|
|
|
$redir = $this->linkRenderer->makeKnownLink(
|
2009-06-06 22:42:48 +00:00
|
|
|
$this->mRedirectedFrom,
|
|
|
|
|
null,
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[ '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\">" .
|
2015-01-28 18:02:42 +00:00
|
|
|
$context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
|
2014-11-22 09:35:58 +00:00
|
|
|
. "</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
|
2016-02-17 09:09:32 +00:00
|
|
|
$outputPage->addJsConfigVars( [
|
2014-07-08 00:50:37 +00:00
|
|
|
'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2014-07-08 00:50:37 +00:00
|
|
|
$outputPage->addModules( 'mediawiki.action.view.redirect' );
|
2009-02-13 16:17:39 +00:00
|
|
|
|
|
|
|
|
// Add a <link rel="canonical"> tag
|
2015-06-24 03:21:16 +00:00
|
|
|
$outputPage->setCanonicalUrl( $this->getTitle()->getCanonicalURL() );
|
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\">" .
|
2015-01-28 18:02:42 +00:00
|
|
|
$context->msg( 'redirectedfrom' )->rawParams( $redir )->parse()
|
2014-11-22 09:35:58 +00:00
|
|
|
. "</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
|
2016-02-17 09:09:32 +00:00
|
|
|
$outputPage->addJsConfigVars( [
|
2014-07-08 00:50:37 +00:00
|
|
|
'wgInternalRedirectTargetUrl' => $redirectTargetUrl,
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2014-07-08 00:50:37 +00:00
|
|
|
$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() {
|
2019-03-29 20:12:24 +00:00
|
|
|
if ( $this->getTitle()->isTalkPage() && !wfMessage( 'talkpageheader' )->isDisabled() ) {
|
|
|
|
|
$this->getContext()->getOutput()->wrapWikiMsg(
|
|
|
|
|
"<div class=\"mw-talkpageheader\">\n$1\n</div>",
|
|
|
|
|
[ '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
|
2020-07-22 17:29:48 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() === NS_USER_TALK
|
2019-06-25 18:53:15 +00:00
|
|
|
&& IPUtils::isValid( $this->getTitle()->getText() )
|
2014-03-23 01:28:57 +00:00
|
|
|
) {
|
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
|
|
|
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$this->getHookRunner()->onArticleViewFooter( $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.
|
2020-05-23 01:30:33 +00:00
|
|
|
*
|
2012-10-03 01:33:55 +00:00
|
|
|
* Side effect: When the patrol link is build, this method will call
|
2021-09-29 20:58:59 +00:00
|
|
|
* OutputPage::setPreventClickjacking(true) and load a JS module.
|
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() {
|
2017-11-20 23:50:22 +00:00
|
|
|
global $wgUseNPPatrol, $wgUseRCPatrol, $wgUseFilePatrol;
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2018-07-11 08:08:48 +00:00
|
|
|
// Allow hooks to decide whether to not output this at all
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
if ( !$this->getHookRunner()->onArticleShowPatrolFooter( $this ) ) {
|
2018-07-11 08:08:48 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
2012-05-07 23:30:48 +00:00
|
|
|
$user = $this->getContext()->getUser();
|
2016-02-16 23:28:22 +00:00
|
|
|
$title = $this->getTitle();
|
2013-06-09 01:41:48 +00:00
|
|
|
$rc = false;
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2021-03-02 23:39:12 +00:00
|
|
|
if ( !$this->getContext()->getAuthority()->probablyCan( 'patrol', $title )
|
2016-02-16 23:28:22 +00:00
|
|
|
|| !( $wgUseRCPatrol || $wgUseNPPatrol
|
|
|
|
|
|| ( $wgUseFilePatrol && $title->inNamespace( NS_FILE ) ) )
|
2014-03-23 01:28:57 +00:00
|
|
|
) {
|
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
|
|
|
}
|
|
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
if ( $this->mRevisionRecord
|
|
|
|
|
&& !RecentChange::isInRCLifespan( $this->mRevisionRecord->getTimestamp(), 21600 )
|
2014-03-23 01:28:57 +00:00
|
|
|
) {
|
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
|
|
|
|
2015-09-17 18:28:53 +00:00
|
|
|
// Check for cached results
|
2017-05-25 07:47:27 +00:00
|
|
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
|
|
|
|
$key = $cache->makeKey( 'unpatrollable-page', $title->getArticleID() );
|
2015-09-17 18:28:53 +00:00
|
|
|
if ( $cache->get( $key ) ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-05 19:55:19 +00:00
|
|
|
$dbr = wfGetDB( DB_REPLICA );
|
2013-06-09 01:41:48 +00:00
|
|
|
$oldestRevisionTimestamp = $dbr->selectField(
|
|
|
|
|
'revision',
|
|
|
|
|
'MIN( rev_timestamp )',
|
2016-02-16 23:28:22 +00:00
|
|
|
[ 'rev_page' => $title->getArticleID() ],
|
2013-06-09 01:41:48 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
2012-12-29 02:53:18 +00:00
|
|
|
|
2016-01-13 13:25:03 +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).
|
|
|
|
|
$recentPageCreation = false;
|
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
|
2016-01-13 13:25:03 +00:00
|
|
|
$recentPageCreation = true;
|
2012-12-29 02:53:18 +00:00
|
|
|
$rc = RecentChange::newFromConds(
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2012-12-29 02:53:18 +00:00
|
|
|
'rc_new' => 1,
|
|
|
|
|
'rc_timestamp' => $oldestRevisionTimestamp,
|
2016-02-16 23:28:22 +00:00
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_cur_id' => $title->getArticleID()
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-09-29 17:31:55 +00:00
|
|
|
__METHOD__
|
2012-12-29 02:53:18 +00:00
|
|
|
);
|
2015-05-17 15:36:29 +00:00
|
|
|
if ( $rc ) {
|
|
|
|
|
// Use generic patrol message for new pages
|
|
|
|
|
$markPatrolledMsg = wfMessage( 'markaspatrolledtext' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-13 13:25:03 +00:00
|
|
|
// File patrol: Get the timestamp of the latest upload for this page,
|
|
|
|
|
// check whether it is within the RC lifespan and if it is, we try
|
|
|
|
|
// to get the recentchanges row belonging to that entry
|
|
|
|
|
// (with rc_type = RC_LOG, rc_log_type = upload).
|
|
|
|
|
$recentFileUpload = false;
|
|
|
|
|
if ( ( !$rc || $rc->getAttribute( 'rc_patrolled' ) ) && $wgUseFilePatrol
|
2016-02-16 23:28:22 +00:00
|
|
|
&& $title->getNamespace() === NS_FILE ) {
|
2015-05-17 15:36:29 +00:00
|
|
|
// Retrieve timestamp of most recent upload
|
|
|
|
|
$newestUploadTimestamp = $dbr->selectField(
|
|
|
|
|
'image',
|
|
|
|
|
'MAX( img_timestamp )',
|
2016-02-16 23:28:22 +00:00
|
|
|
[ 'img_name' => $title->getDBkey() ],
|
2015-05-17 15:36:29 +00:00
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
if ( $newestUploadTimestamp
|
|
|
|
|
&& RecentChange::isInRCLifespan( $newestUploadTimestamp, 21600 )
|
|
|
|
|
) {
|
|
|
|
|
// 6h tolerance because the RC might not be cleaned out regularly
|
2016-01-13 13:25:03 +00:00
|
|
|
$recentFileUpload = true;
|
2015-05-17 15:36:29 +00:00
|
|
|
$rc = RecentChange::newFromConds(
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-05-17 15:36:29 +00:00
|
|
|
'rc_type' => RC_LOG,
|
|
|
|
|
'rc_log_type' => 'upload',
|
|
|
|
|
'rc_timestamp' => $newestUploadTimestamp,
|
|
|
|
|
'rc_namespace' => NS_FILE,
|
2016-02-16 23:28:22 +00:00
|
|
|
'rc_cur_id' => $title->getArticleID()
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2018-04-19 19:01:26 +00:00
|
|
|
__METHOD__
|
2015-05-17 15:36:29 +00:00
|
|
|
);
|
|
|
|
|
if ( $rc ) {
|
|
|
|
|
// Use patrol message specific to files
|
|
|
|
|
$markPatrolledMsg = wfMessage( 'markaspatrolledtext-file' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-13 13:25:03 +00:00
|
|
|
if ( !$recentPageCreation && !$recentFileUpload ) {
|
|
|
|
|
// Page creation and latest upload (for files) is too old to be in RC
|
|
|
|
|
|
|
|
|
|
// We definitely can't patrol so cache the information
|
|
|
|
|
// When a new file version is uploaded, the cache is cleared
|
2015-09-17 18:28:53 +00:00
|
|
|
$cache->set( $key, '1' );
|
2016-01-13 13:25:03 +00:00
|
|
|
|
|
|
|
|
return false;
|
2012-12-29 02:53:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$rc ) {
|
2015-07-29 18:23:09 +00:00
|
|
|
// Don't cache: This can be hit if the page gets accessed very fast after
|
2016-09-05 20:21:26 +00:00
|
|
|
// its creation / latest upload or in case we have high replica DB lag. In case
|
2016-01-13 13:25:03 +00:00
|
|
|
// the revision is too old, we will already return above.
|
2015-07-29 18:23:09 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $rc->getAttribute( 'rc_patrolled' ) ) {
|
|
|
|
|
// Patrolled RC entry around
|
2012-12-29 02:53:18 +00:00
|
|
|
|
|
|
|
|
// Cache the information we gathered above in case we can't patrol
|
|
|
|
|
// Don't cache in case we can patrol as this could change
|
2015-09-17 18:28:53 +00:00
|
|
|
$cache->set( $key, '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
|
|
|
|
2021-05-25 15:39:48 +00:00
|
|
|
if ( $rc->getPerformerIdentity()->equals( $user ) ) {
|
2016-01-13 13:25:03 +00:00
|
|
|
// Don't show a patrol link for own creations/uploads. If the user could
|
2013-07-20 19:24:20 +00:00
|
|
|
// patrol them, they already would be patrolled
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 20:58:59 +00:00
|
|
|
$outputPage->setPreventClickjacking( true );
|
2021-03-02 23:39:12 +00:00
|
|
|
if ( $this->getContext()->getAuthority()->isAllowed( 'writeapi' ) ) {
|
2020-05-23 01:30:33 +00:00
|
|
|
$outputPage->addModules( 'mediawiki.misc-authed-curate' );
|
2013-05-28 12:00:52 +00:00
|
|
|
}
|
2009-07-15 09:48:25 +00:00
|
|
|
|
2019-09-07 09:27:30 +00:00
|
|
|
$link = $this->linkRenderer->makeKnownLink(
|
2016-02-16 23:28:22 +00:00
|
|
|
$title,
|
2019-09-07 09:27:30 +00:00
|
|
|
$markPatrolledMsg->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2012-08-20 14:55:28 +00:00
|
|
|
'action' => 'markpatrolled',
|
2016-10-26 16:14:21 +00:00
|
|
|
'rcid' => $rc->getAttribute( 'rc_id' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2012-08-20 14:55:28 +00:00
|
|
|
);
|
|
|
|
|
|
2021-08-14 09:15:36 +00:00
|
|
|
$outputPage->addModuleStyles( 'mediawiki.action.styles' );
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage->addHTML(
|
2015-10-27 08:31:00 +00:00
|
|
|
"<div class='patrollink' data-mw='interface'>" .
|
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
|
|
|
|
2015-05-17 15:36:29 +00:00
|
|
|
/**
|
|
|
|
|
* Purge the cache used to check if it is worth showing the patrol footer
|
|
|
|
|
* For example, it is done during re-uploads when file patrol is used.
|
|
|
|
|
* @param int $articleID ID of the article to purge
|
|
|
|
|
* @since 1.27
|
|
|
|
|
*/
|
|
|
|
|
public static function purgePatrolFooterCache( $articleID ) {
|
2017-05-25 07:47:27 +00:00
|
|
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
|
|
|
|
$cache->delete( $cache->makeKey( 'unpatrollable-page', $articleID ) );
|
2015-05-17 15:36:29 +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();
|
|
|
|
|
|
2018-08-05 17:58:51 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
|
2020-12-18 05:29:39 +00:00
|
|
|
$contextUser = $this->getContext()->getUser();
|
|
|
|
|
|
2010-02-10 13:08:24 +00:00
|
|
|
# Show info in user (talk) namespace. Does the user exist? Is he blocked?
|
2020-07-22 17:29:48 +00:00
|
|
|
if ( $title->getNamespace() === NS_USER
|
|
|
|
|
|| $title->getNamespace() === NS_USER_TALK
|
2014-03-23 01:28:57 +00:00
|
|
|
) {
|
2016-02-17 19:54:59 +00:00
|
|
|
$rootPart = explode( '/', $title->getText() )[0];
|
2017-03-30 19:53:50 +00:00
|
|
|
$user = User::newFromName( $rootPart, false /* allow IP users */ );
|
2021-04-12 14:45:26 +00:00
|
|
|
$ip = $this->userNameUtils->isIP( $rootPart );
|
2019-05-13 14:18:07 +00:00
|
|
|
$block = DatabaseBlock::newFromTarget( $user, $user );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2020-12-17 23:10:11 +00:00
|
|
|
if ( $user && $user->isRegistered() && $user->isHidden() &&
|
2021-03-02 23:39:12 +00:00
|
|
|
!$this->getContext()->getAuthority()->isAllowed( 'hideuser' )
|
SECURITY: Act like users don't exist if hidden from viewer
When viewing Special:Contributions for a hidden user and
a missing user, or the user page of a hidden user and a
missing user, if the viewer cannot see hidden users
the output should be the same for hidden users and
missing users.
To that end
* In OutputPage.php, only set the `wgRelevantUserName` javascript
variable if the user is not hidden, or the viewer can see hidden
users
* In Article.php, show the `userpage-userdoesnotexist-view` on user
pages of hidden users if the viewer cannot see hidden users
* In Skin.php, do not add user-specific sidebar links (contributions,
logs, mute, etc.) if the user is hidden and the viewer cannot see
hidden users
* In SpecialContributions.php, stop calling Skin::setRelevantUser
for non-existing users, so that callers of Skin::getRelevantUser
can ignore users that are hidden from the viewer without creating
divergent behavior
* In SpecialContributions.php, for users that do exist but are
hidden from the viewer, don't show `sp-contributions-footer`,
but do show `contributions-userdoesnotexist`
Bug: T120883
Change-Id: I83b723402f315447bc4b50992e28620e3daace8f
2020-12-10 23:13:56 +00:00
|
|
|
) {
|
|
|
|
|
// T120883 if the user is hidden and the viewer cannot see hidden
|
|
|
|
|
// users, pretend like it does not exist at all.
|
|
|
|
|
$user = false;
|
|
|
|
|
}
|
2021-05-23 18:06:52 +00:00
|
|
|
|
2020-12-17 23:10:11 +00:00
|
|
|
if ( !( $user && $user->isRegistered() ) && !$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>",
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
|
2018-11-30 05:14:38 +00:00
|
|
|
} elseif (
|
2020-01-09 23:48:34 +00:00
|
|
|
$block !== null &&
|
2019-05-13 14:18:07 +00:00
|
|
|
$block->getType() != DatabaseBlock::TYPE_AUTO &&
|
2021-05-23 18:06:52 +00:00
|
|
|
(
|
|
|
|
|
$block->isSitewide() ||
|
|
|
|
|
$user->isBlockedFrom( $title, true )
|
|
|
|
|
)
|
2018-11-30 05:14:38 +00:00
|
|
|
) {
|
|
|
|
|
// Show log extract if the user is sitewide blocked or is partially
|
|
|
|
|
// blocked and not allowed to edit their user page or user talk page
|
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',
|
2018-08-05 17:58:51 +00:00
|
|
|
$services->getNamespaceInfo()->getCanonicalName( NS_USER ) . ':' .
|
2021-04-16 12:55:24 +00:00
|
|
|
$block->getTargetName(),
|
2010-02-10 13:08:24 +00:00
|
|
|
'',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2010-02-10 13:08:24 +00:00
|
|
|
'lim' => 1,
|
|
|
|
|
'showIfEmpty' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
'msgKey' => [
|
2010-02-19 10:37:20 +00:00
|
|
|
'blocked-notice-logextract',
|
|
|
|
|
$user->getName() # Support GENDER in notice
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
|
|
|
|
]
|
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
|
|
|
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$this->getHookRunner()->onShowMissingArticle( $this );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2015-09-18 05:37:16 +00:00
|
|
|
# Show delete and move logs if there were any such events.
|
|
|
|
|
# The logging query can DOS the site when bots/crawlers cause 404 floods,
|
|
|
|
|
# so be careful showing this. 404 pages must be cheap as they are hard to cache.
|
2019-07-06 07:08:39 +00:00
|
|
|
$dbCache = ObjectCache::getInstance( 'db-replicated' );
|
|
|
|
|
$key = $dbCache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
|
2020-12-17 23:10:11 +00:00
|
|
|
$isRegistered = $contextUser->isRegistered();
|
2017-10-30 12:30:37 +00:00
|
|
|
$sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
|
2020-12-18 05:29:39 +00:00
|
|
|
|
2020-12-17 23:10:11 +00:00
|
|
|
if ( $isRegistered || $dbCache->get( $key ) || $sessionExists ) {
|
2017-07-22 16:46:36 +00:00
|
|
|
$logTypes = [ 'delete', 'move', 'protect' ];
|
2017-02-22 17:55:56 +00:00
|
|
|
|
|
|
|
|
$dbr = wfGetDB( DB_REPLICA );
|
|
|
|
|
|
|
|
|
|
$conds = [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ];
|
2015-09-18 05:37:16 +00:00
|
|
|
// Give extensions a chance to hide their (unrelated) log entries
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$this->getHookRunner()->onArticle__MissingArticleConditions( $conds, $logTypes );
|
2015-09-18 05:37:16 +00:00
|
|
|
LogEventsList::showLogExtract(
|
|
|
|
|
$outputPage,
|
|
|
|
|
$logTypes,
|
|
|
|
|
$title,
|
|
|
|
|
'',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-09-18 05:37:16 +00:00
|
|
|
'lim' => 10,
|
|
|
|
|
'conds' => $conds,
|
|
|
|
|
'showIfEmpty' => false,
|
2020-12-17 23:10:11 +00:00
|
|
|
'msgKey' => [ $isRegistered || $sessionExists
|
2015-09-18 05:37:16 +00:00
|
|
|
? 'moveddeleted-notice'
|
|
|
|
|
: 'moveddeleted-notice-recent'
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
|
|
|
|
]
|
2015-09-18 05:37:16 +00:00
|
|
|
);
|
|
|
|
|
}
|
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.
|
2015-05-24 12:31:11 +00:00
|
|
|
$this->getContext()->getRequest()->response()->statusHeader( 404 );
|
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
|
|
|
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$hookResult = $this->getHookRunner()->onBeforeDisplayNoArticleText( $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();
|
2015-07-17 23:25:24 +00:00
|
|
|
if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI && $title->hasSourceText() ) {
|
2020-11-15 15:57:24 +00:00
|
|
|
$text = $this->getTitle()->getDefaultMessageText() ?? '';
|
|
|
|
|
$outputPage->addWikiTextAsContent( $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
|
|
|
} else {
|
2015-04-08 16:19:55 +00:00
|
|
|
if ( $oldid ) {
|
2020-05-04 09:22:37 +00:00
|
|
|
// T251066: Try loading the revision from the archive table.
|
|
|
|
|
// Show link to view it if it exists and the user has permission to view it.
|
2021-08-30 17:08:41 +00:00
|
|
|
$pa = new PageArchive( $title );
|
2020-05-04 09:22:37 +00:00
|
|
|
$revRecord = $pa->getArchivedRevisionRecord( $oldid );
|
2021-02-24 15:46:13 +00:00
|
|
|
if ( $revRecord && $revRecord->userCan(
|
2020-05-04 09:22:37 +00:00
|
|
|
RevisionRecord::DELETED_TEXT,
|
2021-02-24 15:46:13 +00:00
|
|
|
$this->getContext()->getAuthority()
|
2020-05-04 09:22:37 +00:00
|
|
|
) ) {
|
|
|
|
|
$text = wfMessage(
|
|
|
|
|
'missing-revision-permission', $oldid,
|
|
|
|
|
$revRecord->getTimestamp(),
|
|
|
|
|
$title->getPrefixedDBkey()
|
|
|
|
|
)->plain();
|
|
|
|
|
} else {
|
|
|
|
|
$text = wfMessage( 'missing-revision', $oldid )->plain();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-24 14:10:43 +00:00
|
|
|
} elseif ( $this->getContext()->getAuthority()->probablyCan( 'edit', $title )
|
2015-04-08 16:19:55 +00:00
|
|
|
) {
|
2020-12-17 23:10:11 +00:00
|
|
|
$message = $isRegistered ? 'noarticletext' : 'noarticletextanon';
|
2015-04-08 16:19:55 +00:00
|
|
|
$text = wfMessage( $message )->plain();
|
|
|
|
|
} else {
|
|
|
|
|
$text = wfMessage( 'noarticletext-nopermission' )->plain();
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2015-08-02 23:08:37 +00:00
|
|
|
$dir = $this->getContext()->getLanguage()->getDir();
|
2018-03-07 13:16:02 +00:00
|
|
|
$lang = $this->getContext()->getLanguage()->getHtmlCode();
|
2018-09-25 15:02:07 +00:00
|
|
|
$outputPage->addWikiTextAsInterface( Xml::openElement( 'div', [
|
2015-08-02 23:08:37 +00:00
|
|
|
'class' => "noarticletext mw-content-$dir",
|
|
|
|
|
'dir' => $dir,
|
|
|
|
|
'lang' => $lang,
|
2016-02-17 09:09:32 +00:00
|
|
|
] ) . "\n$text\n</div>" );
|
2015-04-08 16:19:55 +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
|
|
|
}
|
2006-06-13 11:37:09 +00:00
|
|
|
|
2020-11-05 19:31:26 +00:00
|
|
|
/**
|
|
|
|
|
* Show error text for errors generated in Article::view().
|
|
|
|
|
* @param string $errortext localized wikitext error message
|
|
|
|
|
*/
|
|
|
|
|
private function showViewError( string $errortext ) {
|
|
|
|
|
$outputPage = $this->getContext()->getOutput();
|
|
|
|
|
$outputPage->setPageTitle( $this->getContext()->msg( 'errorpagetitle' ) );
|
|
|
|
|
$outputPage->enableClientCache( false );
|
|
|
|
|
$outputPage->setRobotPolicy( 'noindex,nofollow' );
|
|
|
|
|
$outputPage->clearHTML();
|
|
|
|
|
$outputPage->wrapWikiTextAsInterface( 'errorbox', $errortext );
|
|
|
|
|
}
|
|
|
|
|
|
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() {
|
2020-05-01 21:07:41 +00:00
|
|
|
if ( !$this->mRevisionRecord->isDeleted( RevisionRecord::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
|
|
|
}
|
2012-04-22 23:42:38 +00:00
|
|
|
$outputPage = $this->getContext()->getOutput();
|
2012-07-16 09:03:02 +00:00
|
|
|
$user = $this->getContext()->getUser();
|
2020-10-05 16:49:30 +00:00
|
|
|
// Used in wikilinks, should not contain whitespaces
|
|
|
|
|
$titleText = $this->getTitle()->getPrefixedDBkey();
|
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...
|
2021-02-24 15:46:13 +00:00
|
|
|
if ( !$this->mRevisionRecord->userCan(
|
2020-03-11 01:41:49 +00:00
|
|
|
RevisionRecord::DELETED_TEXT,
|
2021-02-24 15:46:13 +00:00
|
|
|
$this->getContext()->getAuthority()
|
2020-03-11 01:41:49 +00:00
|
|
|
) ) {
|
2020-12-09 19:38:59 +00:00
|
|
|
$outputPage->addHtml(
|
|
|
|
|
Html::warningBox(
|
|
|
|
|
$outputPage->msg( 'rev-deleted-text-permission', $titleText )->parse(),
|
|
|
|
|
'plainlinks'
|
|
|
|
|
)
|
|
|
|
|
);
|
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" );
|
2020-05-01 21:07:41 +00:00
|
|
|
$msg = $this->mRevisionRecord->isDeleted( RevisionRecord::DELETED_RESTRICTED ) ?
|
2009-07-30 18:01:41 +00:00
|
|
|
'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
|
2020-12-09 19:38:59 +00:00
|
|
|
$outputPage->addHtml(
|
|
|
|
|
Html::warningBox(
|
|
|
|
|
$outputPage->msg( $msg, $link )->parse(),
|
|
|
|
|
'plainlinks'
|
|
|
|
|
)
|
|
|
|
|
);
|
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 {
|
2019-12-04 06:49:47 +00:00
|
|
|
$msg = $this->mRevisionRecord->isDeleted( RevisionRecord::DELETED_RESTRICTED )
|
|
|
|
|
? [ 'rev-suppressed-text-view', $titleText ]
|
|
|
|
|
: [ 'rev-deleted-text-view', $titleText ];
|
2020-12-09 19:38:59 +00:00
|
|
|
$outputPage->addHtml(
|
|
|
|
|
Html::warningBox(
|
|
|
|
|
$outputPage->msg( $msg[0], $msg[1] )->parse(),
|
|
|
|
|
'plainlinks'
|
|
|
|
|
)
|
|
|
|
|
);
|
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 ) {
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
if ( !$this->getHookRunner()->onDisplayOldSubtitle( $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
|
2016-02-17 09:09:32 +00:00
|
|
|
$extraParams = [];
|
2012-03-09 20:37:44 +00:00
|
|
|
if ( $unhide ) {
|
2011-11-11 15:58:17 +00:00
|
|
|
$extraParams['unhide'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-01 21:07:41 +00:00
|
|
|
if ( $this->mRevisionRecord && $this->mRevisionRecord->getId() === $oldid ) {
|
|
|
|
|
$revisionRecord = $this->mRevisionRecord;
|
2012-03-09 20:26:08 +00:00
|
|
|
} else {
|
2020-05-01 21:07:41 +00:00
|
|
|
$revisionRecord = $this->revisionStore->getRevisionById( $oldid );
|
2012-03-09 20:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-24 00:36:10 +00:00
|
|
|
$timestamp = $revisionRecord->getTimestamp();
|
2011-11-11 15:58:17 +00:00
|
|
|
|
|
|
|
|
$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...
|
2020-04-24 00:36:10 +00:00
|
|
|
$userlinks = Linker::revUserTools( $revisionRecord, !$unhide );
|
2011-11-11 15:58:17 +00:00
|
|
|
|
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();
|
2021-04-19 16:55:41 +00:00
|
|
|
$outputPage->addModuleStyles( [
|
|
|
|
|
'mediawiki.action.styles',
|
|
|
|
|
'mediawiki.interface.helpers.styles'
|
|
|
|
|
] );
|
2021-03-26 16:33:51 +00:00
|
|
|
|
2020-04-24 00:36:10 +00:00
|
|
|
$revisionUser = $revisionRecord->getUser();
|
2016-08-02 18:45:22 +00:00
|
|
|
$revisionInfo = "<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 )
|
2020-04-24 00:36:10 +00:00
|
|
|
->params(
|
|
|
|
|
$revisionRecord->getId(),
|
|
|
|
|
$tddate,
|
|
|
|
|
$tdtime,
|
|
|
|
|
$revisionUser ? $revisionUser->getName() : ''
|
|
|
|
|
)
|
2020-04-18 00:21:26 +00:00
|
|
|
->rawParams( Linker::revComment(
|
2020-04-24 00:36:10 +00:00
|
|
|
$revisionRecord,
|
2020-04-18 00:21:26 +00:00
|
|
|
true,
|
|
|
|
|
true
|
|
|
|
|
) )
|
2014-10-11 19:11:57 +00:00
|
|
|
->parse() .
|
2016-08-02 18:45:22 +00:00
|
|
|
"</div>";
|
2011-11-11 15:58:17 +00:00
|
|
|
|
|
|
|
|
$lnk = $current
|
2015-01-29 16:01:58 +00:00
|
|
|
? $context->msg( 'currentrevisionlink' )->escaped()
|
2019-09-07 09:27:30 +00:00
|
|
|
: $this->linkRenderer->makeKnownLink(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2019-09-07 09:27:30 +00:00
|
|
|
$context->msg( 'currentrevisionlink' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
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()
|
2019-09-07 09:27:30 +00:00
|
|
|
: $this->linkRenderer->makeKnownLink(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2019-09-07 09:27:30 +00:00
|
|
|
$context->msg( 'diff' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2011-11-11 15:58:17 +00:00
|
|
|
'diff' => 'cur',
|
|
|
|
|
'oldid' => $oldid
|
2016-02-17 09:09:32 +00:00
|
|
|
] + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
);
|
2020-05-01 21:07:41 +00:00
|
|
|
$prevExist = (bool)$this->revisionStore->getPreviousRevision( $revisionRecord );
|
2019-08-27 02:45:33 +00:00
|
|
|
$prevlink = $prevExist
|
2019-09-07 09:27:30 +00:00
|
|
|
? $this->linkRenderer->makeKnownLink(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2019-09-07 09:27:30 +00:00
|
|
|
$context->msg( 'previousrevision' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2011-11-11 15:58:17 +00:00
|
|
|
'direction' => 'prev',
|
|
|
|
|
'oldid' => $oldid
|
2016-02-17 09:09:32 +00:00
|
|
|
] + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
)
|
2015-01-29 16:01:58 +00:00
|
|
|
: $context->msg( 'previousrevision' )->escaped();
|
2019-08-27 02:45:33 +00:00
|
|
|
$prevdiff = $prevExist
|
2019-09-07 09:27:30 +00:00
|
|
|
? $this->linkRenderer->makeKnownLink(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2019-09-07 09:27:30 +00:00
|
|
|
$context->msg( 'diff' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2011-11-11 15:58:17 +00:00
|
|
|
'diff' => 'prev',
|
|
|
|
|
'oldid' => $oldid
|
2016-02-17 09:09:32 +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()
|
2019-09-07 09:27:30 +00:00
|
|
|
: $this->linkRenderer->makeKnownLink(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2019-09-07 09:27:30 +00:00
|
|
|
$context->msg( 'nextrevision' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2011-11-11 15:58:17 +00:00
|
|
|
'direction' => 'next',
|
|
|
|
|
'oldid' => $oldid
|
2016-02-17 09:09:32 +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()
|
2019-09-07 09:27:30 +00:00
|
|
|
: $this->linkRenderer->makeKnownLink(
|
2011-11-11 15:58:17 +00:00
|
|
|
$this->getTitle(),
|
2019-09-07 09:27:30 +00:00
|
|
|
$context->msg( 'diff' )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[],
|
|
|
|
|
[
|
2011-11-11 15:58:17 +00:00
|
|
|
'diff' => 'next',
|
|
|
|
|
'oldid' => $oldid
|
2016-02-17 09:09:32 +00:00
|
|
|
] + $extraParams
|
2011-11-11 15:58:17 +00:00
|
|
|
);
|
|
|
|
|
|
2020-04-18 00:21:26 +00:00
|
|
|
$cdel = Linker::getRevDeleteLink(
|
|
|
|
|
$user,
|
2020-04-24 00:36:10 +00:00
|
|
|
$revisionRecord,
|
2020-04-18 00:21:26 +00:00
|
|
|
$this->getTitle()
|
|
|
|
|
);
|
2011-12-28 18:41:36 +00:00
|
|
|
if ( $cdel !== '' ) {
|
2011-11-11 15:58:17 +00:00
|
|
|
$cdel .= ' ';
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-02 18:45:22 +00:00
|
|
|
// the outer div is need for styling the revision info and nav in MobileFrontend
|
2019-09-09 22:07:12 +00:00
|
|
|
$outputPage->addSubtitle( "<div class=\"mw-revision warningbox\">" . $revisionInfo .
|
2016-08-02 18:45:22 +00:00
|
|
|
"<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
|
2016-08-02 18:45:22 +00:00
|
|
|
)->escaped() . "</div></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
|
2017-01-26 13:43:19 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated since 1.30
|
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
|
2019-09-07 09:27:30 +00:00
|
|
|
* @param Title|Title[] $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 ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$target = [ $target ];
|
2009-01-21 20:42:32 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2019-09-07 09:27:30 +00:00
|
|
|
$linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
|
|
|
|
|
|
2014-09-05 14:12:04 +00:00
|
|
|
$html = '<ul class="redirectText">';
|
|
|
|
|
/** @var Title $title */
|
|
|
|
|
foreach ( $target as $title ) {
|
2019-09-07 09:27:30 +00:00
|
|
|
if ( $forceKnown ) {
|
|
|
|
|
$link = $linkRenderer->makeKnownLink(
|
|
|
|
|
$title,
|
|
|
|
|
$title->getFullText(),
|
|
|
|
|
[],
|
|
|
|
|
// Make sure wiki page redirects are not followed
|
|
|
|
|
$title->isRedirect() ? [ 'redirect' => 'no' ] : []
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$link = $linkRenderer->makeLink(
|
|
|
|
|
$title,
|
|
|
|
|
$title->getFullText(),
|
|
|
|
|
[],
|
|
|
|
|
// Make sure wiki page redirects are not followed
|
|
|
|
|
$title->isRedirect() ? [ 'redirect' => 'no' ] : []
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$html .= '<li>' . $link . '</li>';
|
2008-11-28 14:29:25 +00:00
|
|
|
}
|
2015-01-30 14:59:56 +00:00
|
|
|
$html .= '</ul>';
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2015-01-29 21:00:02 +00:00
|
|
|
$redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->escaped();
|
2014-09-05 13:54:14 +00:00
|
|
|
|
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
|
|
|
|
2015-05-02 11:37:19 +00:00
|
|
|
/**
|
|
|
|
|
* Adds help link with an icon via page indicators.
|
|
|
|
|
* Link target can be overridden by a local message containing a wikilink:
|
|
|
|
|
* the message key is: 'namespace-' + namespace number + '-helppage'.
|
|
|
|
|
* @param string $to Target MediaWiki.org page title or encoded URL.
|
|
|
|
|
* @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
|
|
|
|
|
* @since 1.25
|
|
|
|
|
*/
|
|
|
|
|
public function addHelpLink( $to, $overrideBaseUrl = false ) {
|
2015-05-15 12:52:08 +00:00
|
|
|
$out = $this->getContext()->getOutput();
|
2020-08-23 08:02:44 +00:00
|
|
|
$msg = $out->msg( 'namespace-' . $this->getTitle()->getNamespace() . '-helppage' );
|
|
|
|
|
|
2015-05-02 11:37:19 +00:00
|
|
|
if ( !$msg->isDisabled() ) {
|
2020-08-23 08:02:44 +00:00
|
|
|
$title = Title::newFromText( $msg->plain() );
|
|
|
|
|
if ( $title instanceof Title ) {
|
|
|
|
|
$out->addHelpLink( $title->getLocalURL(), true );
|
|
|
|
|
}
|
2015-05-02 11:37:19 +00:00
|
|
|
} else {
|
2015-05-15 12:52:08 +00:00
|
|
|
$out->addHelpLink( $to, $overrideBaseUrl );
|
2015-05-02 11:37:19 +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 );
|
2018-10-18 03:06:23 +00:00
|
|
|
// We later set 'enableSectionEditLinks=false' based on this; also used by ImagePage
|
|
|
|
|
$this->viewIsRenderAction = true;
|
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
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2021-08-12 13:43:04 +00:00
|
|
|
* Perform a deletion and output success or failure messages.
|
|
|
|
|
*
|
|
|
|
|
* @deprecated since 1.37 Use WikiPage::doDeleteArticleReal if you only need to delete the article. If you also need
|
|
|
|
|
* things to happen with OutputPage, you may want to check the hooks in DeleteAction instead.
|
|
|
|
|
*
|
2014-03-23 01:28:57 +00:00
|
|
|
* @param string $reason
|
|
|
|
|
* @param bool $suppress
|
2018-08-28 22:01:48 +00:00
|
|
|
* @param bool $immediate false allows deleting over time via the job queue
|
|
|
|
|
* @throws FatalError
|
|
|
|
|
* @throws MWException
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2018-08-28 22:01:48 +00:00
|
|
|
public function doDelete( $reason, $suppress = false, $immediate = false ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
$error = '';
|
2015-06-28 19:50:01 +00:00
|
|
|
$context = $this->getContext();
|
|
|
|
|
$outputPage = $context->getOutput();
|
|
|
|
|
$user = $context->getUser();
|
2020-03-31 02:44:56 +00:00
|
|
|
$status = $this->mPage->doDeleteArticleReal(
|
|
|
|
|
$reason, $user, $suppress, null, $error,
|
|
|
|
|
null, [], 'delete', $immediate
|
|
|
|
|
);
|
2014-03-23 01:28:57 +00:00
|
|
|
|
2018-08-28 22:01:48 +00:00
|
|
|
if ( $status->isOK() ) {
|
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
|
|
|
|
2018-08-28 22:01:48 +00:00
|
|
|
if ( $status->isGood() ) {
|
|
|
|
|
$loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
|
|
|
|
|
$outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$this->getHookRunner()->onArticleDeleteAfterSuccess( $this->getTitle(), $outputPage );
|
2018-08-28 22:01:48 +00:00
|
|
|
} else {
|
|
|
|
|
$outputPage->addWikiMsg( 'delete-scheduled', wfEscapeWikiText( $deleted ) );
|
|
|
|
|
}
|
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 == '' ) {
|
2018-10-17 14:28:05 +00:00
|
|
|
$outputPage->wrapWikiTextAsInterface(
|
|
|
|
|
'error mw-error-cannotdelete',
|
2018-09-18 20:01:56 +00:00
|
|
|
$status->getWikiText( false, false, $context->getLanguage() )
|
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 ) {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): called twice!?" );
|
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() ) ) {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): about to load file" );
|
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 {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): starting buffer" );
|
2016-02-17 09:09:32 +00:00
|
|
|
ob_start( [ &$cache, 'saveToFileCache' ] );
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): not cacheable" );
|
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
|
2017-08-20 11:20:59 +00:00
|
|
|
* @param int $mode One of the HTMLFileCache::MODE_* constants (since 1.28)
|
2004-09-03 00:20:26 +00:00
|
|
|
* @return bool
|
|
|
|
|
*/
|
2016-09-14 20:36:34 +00:00
|
|
|
public function isFileCacheable( $mode = HTMLFileCache::MODE_NORMAL ) {
|
2008-12-11 14:29:16 +00:00
|
|
|
$cacheable = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2016-09-14 20:36:34 +00:00
|
|
|
if ( HTMLFileCache::useFileCache( $this->getContext(), $mode ) ) {
|
2016-03-19 00:08:06 +00:00
|
|
|
$cacheable = $this->mPage->getId()
|
2011-09-29 08:18:20 +00:00
|
|
|
&& !$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 ) {
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$cacheable = $this->getHookRunner()->onIsFileCacheable( $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
|
|
|
|
2019-08-05 17:00:00 +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
|
2018-09-18 01:29:55 +00:00
|
|
|
* and so on. Doesn't consider most of the stuff that Article::view() is forced to
|
2011-06-30 07:52:59 +00:00
|
|
|
* 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
|
2021-06-03 01:33:49 +00:00
|
|
|
* @param UserIdentity|null $user The relevant user
|
2014-04-23 09:46:22 +00:00
|
|
|
* @return ParserOutput|bool ParserOutput or false if the given revision ID is not found
|
2011-06-30 07:52:59 +00:00
|
|
|
*/
|
2021-06-03 01:33:49 +00:00
|
|
|
public function getParserOutput( $oldid = null, UserIdentity $user = null ) {
|
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
|
|
|
}
|
|
|
|
|
|
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() {
|
2020-11-14 16:04:13 +00:00
|
|
|
return $this->mPage->makeParserOptions( $this->getContext() );
|
2011-09-29 17:51:27 +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
|
|
|
* 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. " .
|
2020-06-01 05:00:39 +00:00
|
|
|
"Return RequestContext::getMain(); for sanity" );
|
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
|
|
|
/**
|
2020-03-19 03:23:43 +00:00
|
|
|
* @deprecated since 1.35, use Article::getPage() instead
|
2020-05-01 21:07:41 +00:00
|
|
|
*
|
2011-06-29 22:09:51 +00:00
|
|
|
* Use PHP's magic __get handler to handle accessing of
|
2021-04-21 04:35:50 +00:00
|
|
|
* raw WikiPage fields for backwards compatibility
|
2011-06-29 22:09:51 +00:00
|
|
|
*
|
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 ) {
|
Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.
However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."
So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().
Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-12 04:18:35 +00:00
|
|
|
wfDeprecatedMsg( "Accessing Article::\$$fname is deprecated since MediaWiki 1.35",
|
|
|
|
|
'1.35' );
|
2020-05-01 21:07:41 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( property_exists( $this->mPage, $fname ) ) {
|
|
|
|
|
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
|
|
|
/**
|
2020-03-19 03:23:43 +00:00
|
|
|
* @deprecated since 1.35, use Article::getPage() instead
|
2020-05-01 21:07:41 +00:00
|
|
|
*
|
2011-06-29 22:09:51 +00:00
|
|
|
* Use PHP's magic __set handler to handle setting of
|
2021-04-21 04:35:50 +00:00
|
|
|
* raw WikiPage fields for backwards compatibility
|
2011-06-29 22:09:51 +00:00
|
|
|
*
|
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 ) {
|
Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.
However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."
So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().
Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-12 04:18:35 +00:00
|
|
|
wfDeprecatedMsg( "Setting Article::\$$fname is deprecated since MediaWiki 1.35",
|
|
|
|
|
'1.35' );
|
2020-05-01 21:07:41 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( property_exists( $this->mPage, $fname ) ) {
|
|
|
|
|
$this->mPage->$fname = $fvalue;
|
|
|
|
|
// Note: extensions may want to toss on new fields
|
2016-02-17 09:09:32 +00:00
|
|
|
} elseif ( !in_array( $fname, [ 'mContext', 'mPage' ] ) ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$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
|
|
|
|
2016-02-02 16:48:20 +00:00
|
|
|
/**
|
|
|
|
|
* Call to WikiPage function for backwards compatibility.
|
2016-05-18 13:49:26 +00:00
|
|
|
* @see ContentHandler::getActionOverrides
|
2019-11-11 21:10:35 +00:00
|
|
|
* @return array
|
2016-02-02 16:48:20 +00:00
|
|
|
*/
|
|
|
|
|
public function getActionOverrides() {
|
|
|
|
|
return $this->mPage->getActionOverrides();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-03-19 03:23:43 +00:00
|
|
|
* @deprecated since 1.35, use WikiPage::getTimestamp instead
|
2016-02-02 16:48:20 +00:00
|
|
|
* @see WikiPage::getTimestamp
|
2019-11-11 21:10:35 +00:00
|
|
|
* @return string
|
2016-02-02 16:48:20 +00:00
|
|
|
*/
|
|
|
|
|
public function getTimestamp() {
|
2020-03-19 03:23:43 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.35' );
|
2016-02-02 16:48:20 +00:00
|
|
|
return $this->mPage->getTimestamp();
|
|
|
|
|
}
|
2007-07-22 14:45:12 +00:00
|
|
|
}
|