Skip to content

Commit

Permalink
Remove use of deprecated Html*Helper::init() methods
Browse files Browse the repository at this point in the history
HtmlOutputRendererHelper::init() and HtmlInputTransformHelper::init()
have been deprecated.

This is a replay of Id63d93db801d0bfb3fdb4c69bf7dfeea4e68ea8f and
I8b5cd59f839446709ffd0ce1b78c1bba40195ae0, which got merged prematurely
before their Depends-On was merged.

Depends-On: I1e1213597c6be012f2bc024c2b370c968ff3b472
Change-Id: Ie762dc34523eed79bc537143394b04e64f004b53
  • Loading branch information
cscott committed Jul 19, 2024
1 parent 7adfd73 commit 90a0a76
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions includes/DirectParsoidClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ private function getHtmlOutputRendererHelper(
bool $stash = false,
string $flavor = self::FLAVOR_DEFAULT
): HtmlOutputRendererHelper {
$helper = $this->helperFactory->newHtmlOutputRendererHelper();

// TODO: remove this once we no longer need a User object for rate limiting (T310476).
if ( $this->performer instanceof User ) {
$user = $this->performer;
} else {
$user = User::newFromIdentity( $this->performer->getUser() );
}

$helper->init( $page, [], $user, $revision );
$helper = $this->helperFactory->newHtmlOutputRendererHelper( $page, [], $user, $revision );

// Ensure we get a compatible version, not just the default
$helper->setOutputProfileVersion( self::PARSOID_VERSION );
Expand Down Expand Up @@ -89,26 +87,31 @@ private function getHtmlInputTransformHelper(
string $etag = null,
Bcp47Code $pageLanguage = null
): HtmlInputTransformHelper {
$helper = $this->helperFactory->newHtmlInputTransformHelper();

// Fake REST body
$body = [
'html' => [
'body' => $html,
]
];

$metrics = MediaWikiServices::getInstance()->getParsoidSiteConfig()->metrics();
if ( $metrics ) {
$helper->setMetrics( $metrics );
}

if ( $oldid || $etag ) {
$body['original']['revid'] = $oldid;
$body['original']['renderid'] = $etag;
}

$helper->init( $page, $body, [], null, $pageLanguage );
$helper = $this->helperFactory->newHtmlInputTransformHelper(
/* envOptions: */ [],
$page,
$body,
/* parameters: */ [],
/* originalRevision: */ null,
$pageLanguage
);

$metrics = MediaWikiServices::getInstance()->getParsoidSiteConfig()->metrics();
if ( $metrics ) {
$helper->setMetrics( $metrics );
}

return $helper;
}
Expand Down

0 comments on commit 90a0a76

Please sign in to comment.