aboutsummaryrefslogtreecommitdiffstats
path: root/includes/content
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2023-05-06 22:01:10 +0200
committerDannyS712 <dannys712.wiki@gmail.com>2023-05-11 06:17:38 +0000
commite04d3a28f6c4341b7185a7f121bdfa90372a43df (patch)
tree54f2337f22977dda7e541a94fbdaf437a7894715 /includes/content
parent9878c4c67a9de08242573f5f5fa149128d80499e (diff)
downloadmediawikicore-e04d3a28f6c4341b7185a7f121bdfa90372a43df.tar.gz
mediawikicore-e04d3a28f6c4341b7185a7f121bdfa90372a43df.zip
Replace internal Hooks::runner
The Hooks class contains deprecated functions and the whole class is going to get removed, so remove the convenience function and inline the code. Bug: T335536 Change-Id: I8ef3468a64a0199996f26ef293543fcacdf2797f
Diffstat (limited to 'includes/content')
-rw-r--r--includes/content/AbstractContent.php9
-rw-r--r--includes/content/ContentHandler.php6
-rw-r--r--includes/content/WikitextContent.php4
3 files changed, 13 insertions, 6 deletions
diff --git a/includes/content/AbstractContent.php b/includes/content/AbstractContent.php
index c8749553203c..3a5bdde05cef 100644
--- a/includes/content/AbstractContent.php
+++ b/includes/content/AbstractContent.php
@@ -31,6 +31,7 @@ use MediaWiki\Content\Renderer\ContentParseParams;
use MediaWiki\Content\Transform\PreloadTransformParamsValue;
use MediaWiki\Content\Transform\PreSaveTransformParamsValue;
use MediaWiki\Content\ValidationParams;
+use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MediaWikiServices;
use MediaWiki\Parser\MagicWord;
use MediaWiki\Title\Title;
@@ -531,7 +532,8 @@ abstract class AbstractContent implements Content {
$lossy = ( $lossy === 'lossy' ); // string flag, convert to boolean for convenience
$result = false;
- Hooks::runner()->onConvertContent( $this, $toModel, $lossy, $result );
+ ( new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) )
+ ->onConvertContent( $this, $toModel, $lossy, $result );
return $result;
}
@@ -580,7 +582,8 @@ abstract class AbstractContent implements Content {
$po = new ParserOutput();
$options->registerWatcher( [ $po, 'recordOption' ] );
- if ( Hooks::runner()->onContentGetParserOutput(
+ $hookRunner = new HookRunner( MediaWikiServices::getInstance()->getHookContainer() );
+ if ( $hookRunner->onContentGetParserOutput(
$this, $title, $revId, $options, $generateHtml, $po )
) {
// Save and restore the old value, just in case something is reusing
@@ -591,7 +594,7 @@ abstract class AbstractContent implements Content {
$options->setRedirectTarget( $oldRedir );
}
- Hooks::runner()->onContentAlterParserOutput( $this, $title, $po );
+ $hookRunner->onContentAlterParserOutput( $this, $title, $po );
$options->registerWatcher( null );
return $po;
diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php
index aee6710efca5..fae00e141624 100644
--- a/includes/content/ContentHandler.php
+++ b/includes/content/ContentHandler.php
@@ -31,6 +31,7 @@ use MediaWiki\Content\Renderer\ContentParseParams;
use MediaWiki\Content\Transform\PreloadTransformParams;
use MediaWiki\Content\Transform\PreSaveTransformParams;
use MediaWiki\Content\ValidationParams;
+use MediaWiki\HookContainer\HookRunner;
use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MainConfigNames;
@@ -1735,9 +1736,10 @@ abstract class ContentHandler {
$scopedCallback = $parserOptions->setupFakeRevision( $title, $content, $parserOptions->getUserIdentity() );
}
+ $hookRunner = new HookRunner( $services->getHookContainer() );
$po = new ParserOutput();
$parserOptions->registerWatcher( [ $po, 'recordOption' ] );
- if ( Hooks::runner()->onContentGetParserOutput(
+ if ( $hookRunner->onContentGetParserOutput(
// FIXME $cpoParams->getRevId() may be null here?
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable
$content, $title, $cpoParams->getRevId(), $parserOptions, $cpoParams->getGenerateHtml(), $po )
@@ -1761,7 +1763,7 @@ abstract class ContentHandler {
$parserOptions->setRedirectTarget( $oldRedir );
}
- Hooks::runner()->onContentAlterParserOutput( $content, $title, $po );
+ $hookRunner->onContentAlterParserOutput( $content, $title, $po );
$parserOptions->registerWatcher( null );
if ( isset( $scopedCallback ) ) {
ScopedCallback::consume( $scopedCallback );
diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php
index 22b8a1fb33bb..028c3ef9f860 100644
--- a/includes/content/WikitextContent.php
+++ b/includes/content/WikitextContent.php
@@ -25,6 +25,7 @@
* @author Daniel Kinzler
*/
+use MediaWiki\HookContainer\HookRunner;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Parser\MagicWord;
@@ -106,7 +107,8 @@ class WikitextContent extends TextContent {
# Inserting a new section
$subject = strval( $sectionTitle ) !== '' ? wfMessage( 'newsectionheaderdefaultlevel' )
->plaintextParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : '';
- if ( Hooks::runner()->onPlaceNewSection( $this, $oldtext, $subject, $text ) ) {
+ $hookRunner = ( new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ) );
+ if ( $hookRunner->onPlaceNewSection( $this, $oldtext, $subject, $text ) ) {
$text = strlen( trim( $oldtext ) ) > 0
? "{$oldtext}\n\n{$subject}{$text}"
: "{$subject}{$text}";