were removed.
* Article::getAutosummary() and WikiPage::getAutosummary() (deprecated in 1.21)
were removed.
-* Hooks ArticleViewCustom, EditPageGetDiffText and ShowRawCssJs (deprecated in 1.21)
- were removed.
+* Hook ArticleViewCustom (deprecated in 1.21) was removed. Use ArticleContentViewCustom
+ instead.
+* Hooks EditPageGetDiffText and ShowRawCssJs (deprecated in 1.21) were removed.
* Class RevisiondeleteAction (deprecated in 1.25) was removed.
* WikiPage::prepareTextForEdit() (deprecated in 1.21) was removed.
* WikiPage::getText() (deprecated in 1.21) was removed.
RewriteEngine On
RewriteBase /
RewriteRule ^/w/wiki\.phtml$ /w/index.php [R=301,L]
+* Hook ArticleAfterFetchContent (deprecated in 1.21) was removed.
+ Use ArticleAfterFetchContentObject instead.
+* Hook ArticleInsertComplete (deprecated in 1.21) was removed.
+ Use PageContentInsertComplete instead.
+* Hook ArticleSave (deprecated in 1.21) was removed.
+ Use PageContentSave instead.
+* Hook ArticleSaveComplete (deprecated in 1.21) was removed.
+ Use PageContentSaveComplete instead.
+* Hook EditFilterMerged (deprecated in 1.21) was removed.
+ Use EditFilterMergedContent instead.
+* Hook EditPageGetPreviewText (deprecated in 1.21) was removed.
+ Use EditPageGetPreviewContent instead.
+* Hook TitleIsCssOrJsPage (deprecated in 1.21) was removed.
+ Use ContentHandlerDefaultModelFor instead.
+* Hook TitleIsWikitextPage (deprecated in 1.21) was removed.
+ Use ContentHandlerDefaultModelFor instead.
== Compatibility ==
* The hook ContentHandlerDefaultModelFor may be used to override the page's default model.
* Pages in NS_MEDIAWIKI and NS_USER default to the CSS or JavaScript model if they end in .css or .js, respectively.
Pages in NS_MEDIAWIKI default to the wikitext model otherwise.
-* The hook TitleIsCssOrJsPage may be used to force a page to use the CSS or JavaScript model.
- This is a compatibility feature. The ContentHandlerDefaultModelFor hook should be used instead if possible.
-* The hook TitleIsWikitextPage may be used to force a page to use the wikitext model.
- This is a compatibility feature. The ContentHandlerDefaultModelFor hook should be used instead if possible.
* Otherwise, the wikitext model is used.
Note that is currently no mechanism to convert a page from one content model to another, and there is no guarantee that
AND in the final query)
$logTypes: Array of log types being queried
-'ArticleAfterFetchContent': DEPRECATED! Use ArticleAfterFetchContentObject
-instead.
-After fetching content of an article from the database.
-&$article: the article (object) being loaded from the database
-&$content: the content (string) of the article
-
'ArticleAfterFetchContentObject': After fetching content of an article from the
database.
&$article: the article (object) being loaded from the database
&$article: Article (object) that will be returned
$context: IContextSource (object)
-'ArticleInsertComplete': DEPRECATED! Use PageContentInsertComplete.
-After a new article is created.
-$wikiPage: WikiPage created
-$user: User creating the article
-$text: New content
-$summary: Edit summary/comment
-$isMinor: Whether or not the edit was marked as minor
-$isWatch: (No longer used)
-$section: (No longer used)
-$flags: Flags passed to WikiPage::doEditContent()
-$revision: New Revision of the article
-
'ArticleMergeComplete': After merging to article using Special:Mergehistory.
$targetTitle: target title (object)
$destTitle: destination title (object)
$revision: the revision the page was reverted back to
$current: the reverted revision
-'ArticleSave': DEPRECATED! Use PageContentSave instead.
-Before an article is saved.
-$wikiPage: the WikiPage (object) being saved
-$user: the user (object) saving the article
-$text: the new article text
-$summary: the article summary (comment)
-$isminor: minor flag
-$iswatch: watch flag
-$section: section #
-
-'ArticleSaveComplete': DEPRECATED! Use PageContentSaveComplete instead.
-After an article has been updated.
-$wikiPage: WikiPage modified
-$user: User performing the modification
-$text: New content
-$summary: Edit summary/comment
-$isMinor: Whether or not the edit was marked as minor
-$isWatch: (No longer used)
-$section: (No longer used)
-$flags: Flags passed to WikiPage::doEditContent()
-$revision: New Revision of the article
-$status: Status object about to be returned by doEditContent()
-$baseRevId: the rev ID (or false) this edit was based on
-$undidRevId: the rev ID (or 0) this edit undid
-
'ArticleUndelete': When one or more revisions of an article are restored.
&$title: Title corresponding to the article restored
$create: Whether or not the restoration caused the page to be created (i.e. it
&$error: Error message to return
$summary: Edit summary for page
-'EditFilterMerged': DEPRECATED! Use EditFilterMergedContent instead.
-Post-section-merge edit filter.
-$editor: EditPage instance (object)
-$text: content of the edit box
-&$error: error message to return
-$summary: Edit summary for page
'EditFilterMergedContent': Post-section-merge edit filter.
This may be triggered by the EditPage or any other facility that modifies page
$editPage: EditPage object
&$content: Content object to be previewed (may be replaced by hook function)
-'EditPageGetPreviewText': DEPRECATED! Use EditPageGetPreviewContent instead.
-Allow modifying the wikitext that will be previewed. Note that it is preferable
-to implement previews for different data types using the ContentHandler
-facility.
-$editPage: EditPage object
-&$toparse: wikitext that will be parsed
-
'EditPageNoSuchSection': When a section edit request is given for an
non-existent section
&$editpage: The current EditPage object
$title: Title object that is being checked
&$isKnown: Boolean|null; whether MediaWiki currently thinks this page is known
-'TitleIsCssOrJsPage': DEPRECATED! Use ContentHandlerDefaultModelFor instead.
-Called when determining if a page is a CSS or JS page.
-$title: Title object that is being checked
-&$result: Boolean; whether MediaWiki currently thinks this is a CSS/JS page.
- Hooks may change this value to override the return value of
- Title::isCssOrJsPage().
-
'TitleIsMovable': Called when determining if it is possible to move a page. Note
that this hook is not called for interwiki pages or pages in immovable
namespaces: for these, isMovable() always returns false.
Hooks may change this value to override the return value of
Title::isMovable().
-'TitleIsWikitextPage': DEPRECATED! Use ContentHandlerDefaultModelFor instead.
-Called when determining if a page is a wikitext or should
-be handled by separate handler (via ArticleViewCustom).
-$title: Title object that is being checked
-&$result: Boolean; whether MediaWiki currently thinks this is a wikitext page.
- Hooks may change this value to override the return value of
- Title::isWikitextPage()
'TitleMove': Before moving an article (title).
$old: old title
*/
protected function runPostMergeFilters( Content $content, Status $status, User $user ) {
// Run old style post-section-merge edit filter
- if ( !ContentHandler::runLegacyHooks( 'EditFilterMerged',
- [ $this, $content, &$this->hookError, $this->summary ],
- '1.21'
- ) ) {
- # Error messages etc. could be handled within the hook...
- $status->fatal( 'hookaborted' );
- $status->value = self::AS_HOOK_ERROR;
- return false;
- } elseif ( $this->hookError != '' ) {
+ if ( $this->hookError != '' ) {
# ...or the hook could be expecting us to produce an error
$status->fatal( 'hookaborted' );
$status->value = self::AS_HOOK_ERROR_EXPECTED;
}
$hook_args = [ $this, &$content ];
- ContentHandler::runLegacyHooks( 'EditPageGetPreviewText', $hook_args, '1.25' );
Hooks::run( 'EditPageGetPreviewContent', $hook_args );
$parserResult = $this->doPreviewParse( $content );
&& ( $this->hasContentModel( CONTENT_MODEL_CSS )
|| $this->hasContentModel( CONTENT_MODEL_JAVASCRIPT ) );
- # @note This hook is also called in ContentHandler::getDefaultModel.
- # It's called here again to make sure hook functions can force this
- # method to return true even outside the MediaWiki namespace.
-
- Hooks::run( 'TitleIsCssOrJsPage', [ $this, &$isCssOrJsPage ], '1.25' );
-
return $isCssOrJsPage;
}
$ext = $m[1];
}
- // Hook can force JS/CSS
- Hooks::run( 'TitleIsCssOrJsPage', [ $title, &$isCodePage ], '1.21' );
-
// Is this a user subpage containing code?
$isCodeSubpage = NS_USER == $ns
&& !$isCodePage
$isWikitext = is_null( $model ) || $model == CONTENT_MODEL_WIKITEXT;
$isWikitext = $isWikitext && !$isCodePage && !$isCodeSubpage;
- // Hook can override $isWikitext
- Hooks::run( 'TitleIsWikitextPage', [ $title, &$isWikitext ], '1.21' );
-
if ( !$isWikitext ) {
switch ( $ext ) {
case 'js':
return $this->supportsDirectEditing();
}
- /**
- * Call a legacy hook that uses text instead of Content objects.
- * Will log a warning when a matching hook function is registered.
- * If the textual representation of the content is changed by the
- * hook function, a new Content object is constructed from the new
- * text.
- *
- * @param string $event Event name
- * @param array $args Parameters passed to hook functions
- * @param string|null $deprecatedVersion Emit a deprecation notice
- * when the hook is run for the provided version
- *
- * @return bool True if no handler aborted the hook
- */
- public static function runLegacyHooks( $event, $args = [],
- $deprecatedVersion = null
- ) {
-
- if ( !Hooks::isRegistered( $event ) ) {
- return true; // nothing to do here
- }
-
- // convert Content objects to text
- $contentObjects = [];
- $contentTexts = [];
-
- foreach ( $args as $k => $v ) {
- if ( $v instanceof Content ) {
- /* @var Content $v */
-
- $contentObjects[$k] = $v;
-
- $v = $v->serialize();
- $contentTexts[$k] = $v;
- $args[$k] = $v;
- }
- }
-
- // call the hook functions
- $ok = Hooks::run( $event, $args, $deprecatedVersion );
-
- // see if the hook changed the text
- foreach ( $contentTexts as $k => $orig ) {
- /* @var Content $content */
-
- $modified = $args[$k];
- $content = $contentObjects[$k];
-
- if ( $modified !== $orig ) {
- // text was changed, create updated Content object
- $content = $content->getContentHandler()->unserializeContent( $modified );
- }
-
- $args[$k] = $content;
- }
-
- return $ok;
- }
-
/**
* Get fields definition for search index
*
$hook_args = [ &$wikiPage, &$user, &$content, &$summary,
$flags & EDIT_MINOR, null, null, &$flags, &$hookStatus ];
// Check if the hook rejected the attempted save
- if ( !Hooks::run( 'PageContentSave', $hook_args )
- || !ContentHandler::runLegacyHooks( 'ArticleSave', $hook_args, '1.21' )
- ) {
+ if ( !Hooks::run( 'PageContentSave', $hook_args ) ) {
if ( $hookStatus->isOK() ) {
// Hook returned false but didn't call fatal(); use generic message
$hookStatus->fatal( 'edit-hook-aborted' );
$params = [ &$wikiPage, &$user, $content, $summary, $flags & EDIT_MINOR,
null, null, &$flags, $revision, &$status, $meta['baseRevId'],
$meta['undidRevId'] ];
- ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params );
Hooks::run( 'PageContentSaveComplete', $params );
}
),
// Trigger post-create hook
$params = [ &$wikiPage, &$user, $content, $summary,
$flags & EDIT_MINOR, null, null, &$flags, $revision ];
- ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $params, '1.21' );
Hooks::run( 'PageContentInsertComplete', $params );
// Trigger post-save hook
$params = array_merge( $params, [ &$status, $meta['baseRevId'] ] );
- ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params, '1.21' );
Hooks::run( 'PageContentSaveComplete', $params );
-
}
),
DeferredUpdates::PRESEND
/*
* Hooks that are ignored
*/
- protected static $ignore = [ 'testRunLegacyHooks', 'Test' ];
+ protected static $ignore = [ 'Test' ];
public function __construct() {
parent::__construct();
$m = [];
preg_match_all(
// All functions which runs hooks
- '/(?:wfRunHooks|Hooks\:\:run|ContentHandler\:\:runLegacyHooks)\s*\(\s*' .
+ '/(?:wfRunHooks|Hooks\:\:run)\s*\(\s*' .
// First argument is the hook name as string
'([\'"])(.*?)\1' .
// Comma for second argument
$this->assertFalse( $handler->supportsDirectEditing(), 'direct editing is not supported' );
}
- /**
- * @covers ContentHandler::runLegacyHooks
- */
- public function testRunLegacyHooks() {
- Hooks::register( 'testRunLegacyHooks', __CLASS__ . '::dummyHookHandler' );
-
- $content = new WikitextContent( 'test text' );
- $ok = ContentHandler::runLegacyHooks(
- 'testRunLegacyHooks',
- [ 'foo', &$content, 'bar' ]
- );
-
- $this->assertTrue( $ok, "runLegacyHooks should have returned true" );
- $this->assertEquals( "TEST TEXT", $content->getNativeData() );
- }
-
public static function dummyHookHandler( $foo, &$text, $bar ) {
if ( $text === null || $text === false ) {
return false;