De-globalize EditPage.php and use RequestContext instead
Closed, ResolvedPublic

Description

EditPage uses a ton of global objects ($wgOut, $wgUser, etc.). These should be replaced with the appropriate RequestContext function instead.

A getContext() function and $this->context member variable were added in rMW841c4076574b: EditPage: Add getContext() function.

Then, four commits were made to switch global objects out for context equivalents (1000 line chunks):

These were reverted in rMW5ce43a986133: Revert serie of "EditPage: Use context instead of globals" due to breakage in LiquidThreads: T143889: Replies impossible: The content format json is not supported by the content model.

We need to check other Wikimedia-deployed extensions and then re-apply the de-globalization change.

  • $wgAjaxEditStash: 2 uses
  • $wgAllowUserCss: 2 uses
  • $wgAllowUserJs: 2 uses
  • $wgBrowserBlackList: 3 uses - gone with T67297: Remove $wgBrowserBlackList and associated EditPage methods
  • $wgContentHandlerUseDB: 3 uses
  • $wgContLang: 5 uses - OK, no context based replacement
  • $wgEnableUploads: 1 use - static
  • $wgForeignFileRepos: 2 uses - static
  • $wgLang
  • $wgMaxArticleSize: 4 uses
  • $wgOut: 2 uses - remaining uses will go away with T30856: Remove classic edit toolbar from core
  • $wgParser: 8 uses - OK, no context based replacement
  • $wgPreviewOnOpenNamespaces: 3 uses
  • $wgRawHtml: 2 uses
  • $wgRequest: 13 uses
  • $wgRightsText: 3 uses - static
  • $wgSpamRegex: 4 uses - static
  • $wgSummarySpamRegex: 3 uses - static
  • $wgTitle: 3 uses - only as fallback. Follow-up is T176526: Remove $wgTitle fallback from EditPage
  • $wgUseMediaWikiUIEverywhere: 2 uses
  • $wgUser
Legoktm created this task.Aug 31 2016, 7:46 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 31 2016, 7:46 AM

grep on tin:

1​legoktm@tin:/srv/mediawiki-staging/php-1.28.0-wmf.17/extensions$ ack-grep "EditPage" --php
2​ContentTranslation/ContentTranslation.hooks.php
3​194: * Hook: EditPage::showEditForm:initial
4​196: public static function newArticleCampaign( EditPage $newPage, OutputPage $out ) {
5
6​MobileFrontend/includes/skins/SkinMinerva.php
7​963: $menu['edit'] = $this->createEditPageAction();
8​988: protected function createEditPageAction() {
9
10​LiquidThreads/classes/View.php
11​514: $e = new EditPage( $article );
12​631: $e = new EditPage( $article );
13​744: $e = new EditPage( $article );
14​847: $e = new EditPage( $article );
15​1808: // as it would involve rewriting EditPage, which I do NOT intend to do.
16​2075: Hooks::run( 'EditPageBeforeEditToolbar', array( &$html ) );
17
18​LiquidThreads/classes/Hooks.php
19​306: * @param $editPage EditPage
20
21​LiquidThreads/api/ApiThreadAction.php
22​3:class ApiThreadAction extends ApiEditPage {
23
24​TemplateSandbox/TemplateSandbox.hooks.php
25​4: * Hook for EditPage::importFormData to parse our new form fields, and if
26​10: * @param EditPage $editpage
27​47: * @param EditPage $editpage
28​124: ' [[#' . EditPage::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' .
29​178: * Hook for EditPage::showStandardInputs:options to add our form fields to
30​181: * @param EditPage $editpage
31
32​TemplateSandbox/SpecialTemplateSandbox.php
33​106: if ( is_callable( 'EditPage::getPreviewLimitReport' ) ) {
34​108: EditPage::getPreviewLimitReport( $this->output ) ) );
35
36​EventLogging/includes/JsonSchemaHooks.php
37​61: * @param EditPage $editor
38
39​WikimediaMessages/WikimediaMessages.hooks.php
40​158: public static function onEditPageCopyrightWarning( $title, &$msg ) {
41
42​ProofreadPage/includes/index/EditProofreadIndexPage.php
43​23:class EditProofreadIndexPage extends EditPage {
44
45​ProofreadPage/includes/page/EditPagePage.php
46​7:use EditPage;
47​17:class EditPagePage extends EditPage {
48​49: * @see EditPage::isSectionEditSupported
49​56: * @see EditPage::isSupportedContentModel
50​65: * @see EditPage::showContentForm
51​75: * @see EditPage::showContentForm
52​143: * @see EditPage::getCheckBoxes
53​192: * @see EditPage::importContentFormData
54​209: * @see EditPage::internalAttemptSave
55
56​ProofreadPage/includes/page/PageSubmitAction.php
57​21: $editor = new EditPagePage( $this->page, $pagePage, Context::getDefaultContext() );
58
59​ProofreadPage/includes/page/PageEditAction.php
60​21: $editor = new EditPagePage( $this->page, $pagePage, Context::getDefaultContext() );
61
62​ProofreadPage/ProofreadPage.body.php
63​627: $ourStatus->value = EditPage::AS_HOOK_ERROR;
64
65​GlobalCssJs/GlobalCssJs.hooks.php
66​115: * @param EditPage $editPage
67​119: static function onEditPageshowEditForminitial( EditPage $editPage, OutputPage $output ) {
68
69​SemanticForms/includes/SF_AutoeditAPI.php
70​340: protected function setupEditPage( $targetContent ) {
71​354: $editor = new EditPage( $article );
72​412: Hooks::run( 'EditPage::showEditForm:initial', array( &$editor, &$wgOut ) );
73​432: protected function doStore( EditPage $editor ) {
74​476: case EditPage::AS_HOOK_ERROR_EXPECTED: // A hook function returned an error
75​481: Hooks::register('EditPageBeforeEditButtons', function( &$editor, &$buttons, &$tabindex ){
76​495: case EditPage::AS_CONTENT_TOO_BIG: // Content too big (> $wgMaxArticleSize)
77​496: case EditPage::AS_ARTICLE_WAS_DELETED: // article was deleted while editting and param wpRecreate == false or form was not posted
78​497: case EditPage::AS_CONFLICT_DETECTED: // (non-resolvable) edit conflict
79​498: case EditPage::AS_SUMMARY_NEEDED: // no edit summary given and the user has forceeditsummary set and the user is not editting in his own userspace or talkspace and wpIgnoreBlankSummary == false
80​499: case EditPage::AS_TEXTBOX_EMPTY: // user tried to create a new section without content
81​500: case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED: // article is too big (> $wgMaxArticleSize), after merging in the new section
82​501: case EditPage::AS_END: // WikiPage::doEdit() was unsuccessfull
83​505: case EditPage::AS_HOOK_ERROR: // Article update aborted by a hook function
84​513:// case EditPage::AS_PARSE_ERROR: // can't parse content
85​518: case EditPage::AS_SUCCESS_NEW_ARTICLE: // Article successfully created
86​534: case EditPage::AS_SUCCESS_UPDATE: // Article successfully updated
87​562: case EditPage::AS_BLANK_ARTICLE: // user tried to create a blank page
88​571: case EditPage::AS_SPAM_ERROR: // summary contained spam according to one of the regexes in $wgSummarySpamRegex
89​580: case EditPage::AS_BLOCKED_PAGE_FOR_USER: // User is blocked from editting editor page
90​583: case EditPage::AS_IMAGE_REDIRECT_ANON: // anonymous user is not allowed to upload (User::isAllowed('upload') == false)
91​584: case EditPage::AS_IMAGE_REDIRECT_LOGGED: // logged in user is not allowed to upload (User::isAllowed('upload') == false)
92​587: case EditPage::AS_READ_ONLY_PAGE_ANON: // editor anonymous user is not allowed to edit editor page
93​588: case EditPage::AS_READ_ONLY_PAGE_LOGGED: // editor logged in user is not allowed to edit editor page
94​591: case EditPage::AS_READ_ONLY_PAGE: // wiki is in readonly mode (wfReadOnly() == true)
95​594: case EditPage::AS_RATE_LIMITED: // rate limiter for action 'edit' was tripped
96​597: case EditPage::AS_NO_CREATE_PERMISSION: // user tried to create editor page, but is not allowed to do that ( Title->usercan('create') == false )
97​992: $editor = $this->setupEditPage( $targetContent );
98
99​SemanticForms/includes/SF_Hooks.php
100​74: $GLOBALS['wgEditPageFrameOptions'] = 'SAMEORIGIN';
101​305: public static function showFormPreview( EditPage $editpage, WebRequest $request ) {
102
103​SemanticForms/includes/SF_FormUtils.php
104​99: // this code borrowed from /includes/EditPage.php
105​263: // Much of this function is based on MediaWiki's EditPage::showEditForm()
106​299: // based on MediaWiki's EditPage::getPreloadedText()
107
108​SemanticForms/includes/SF_FormPrinter.php
109​702: // $userCanEditPage = ( $wgUser->isAllowed( 'edit' ) && $this->mPageTitle->userCan( 'edit' ) );
110​709: $userCanEditPage = count( $permissionErrors ) == 0;
111​710: Hooks::run( 'sfUserCanEditPage', array( $this->mPageTitle, &$userCanEditPage ) );
112​713: if ( $is_query || $userCanEditPage ) {
113​718: // Based on code in MediaWiki's EditPage.php.
114​947: // borrowed from EditPage::showEditTools()
115
116​SemanticForms/includes/forminputs/SF_TextAreaInput.php
117​166: $editPage = new EditPage( $article );
118
119​SemanticForms/SemanticForms.php
120​148:$GLOBALS['wgHooks']['EditPage::importFormData'][] = 'SFHooks::showFormPreview';
121​264:$GLOBALS['wgEditPageFrameOptions'] = 'SAMEORIGIN';
122
123​Math/Math.hooks.php
124​391: static function onEditPageBeforeEditToolbar( &$toolbar ) {
125
126​Wikidata/extensions/Wikibase/repo/includes/EditEntity.php
127​772: * @note Keep in sync with logic in EditPage!
128​791: * @note Keep in sync with logic in EditPage!
129
130​Wikidata/extensions/Wikibase/repo/includes/Api/ResultBuilder.php
131​1114: // like core's ApiEditPage
132
133​Wikidata/extensions/Wikibase/repo/includes/Store/Sql/WikiPageEntityStore.php
134​323: * @see EditPage::userWasLastToEdit()
135​364: * @note keep in sync with logic in EditPage
136
137​Wikidata/extensions/Wikibase/repo/includes/Actions/EditEntityAction.php
138​446: * Generate standard summary input and label (wgSummary), compatible to EditPage.
139
140​Wikidata/extensions/Wikibase/repo/Wikibase.hooks.php
141​6:use ApiEditPage;
142​550: * This implementation causes the execution of ApiEditPage (action=edit) to fail
143​565: if ( $module instanceof ApiEditPage ) {
144​575: // trying to use ApiEditPage on an entity namespace
145
146​Wikidata/extensions/Wikibase/repo/tests/phpunit/includes/Api/EditPageTest.php
147​21: * @group EditPageTest
148​27:class EditPageTest extends WikibaseApiTestCase {
149​37: $item->setLabel( "en", "EditPageTest" );
150​40: $item->setLabel( "de", "EditPageTest" );
151
152​Wikidata/extensions/Wikibase/lib/includes/Store/EntityStore.php
153​104: * @see EditPage::userWasLastToEdit()
154
155​Wikidata/extensions/Wikibase/lib/tests/phpunit/MockRepository.php
156​565: * @see EditPage::userWasLastToEdit
157
158​Wikidata/vendor/composer/autoload_classmap.php
159​1302: 'Wikibase\\Test\\Repo\\Api\\EditPageTest' => $baseDir . '/extensions/Wikibase/repo/tests/phpunit/includes/Api/EditPageTest.php',
160
161​SpamBlacklist/SpamBlacklistHooks.php
162​65: // Always return true, EditPage will look at $status->isOk().
163​119: * @param $editPage EditPage
164
165​WikimediaEvents/WikimediaEventsHooks.php
166​375: * @see https://www.mediawiki.org/wiki/Manual:Hooks/EditPageBeforeConflictDiff
167​377: * @param EditPage &$editor
168​381: public static function onEditPageBeforeConflictDiff( &$editor, &$out ) {
169
170​UploadWizard/includes/CampaignHooks.php
171​126: * @param EditPage $editor
172
173​Translate/tag/PageTranslationHooks.php
174​389: * edit conflict if there wasn't tpSyntaxCheckForEditPage.
175
176​Translate/utils/TranslationHelpers.php
177​635: $jsEdit = TranslationEditPage::jsEdit( $target, $groupId, 'dialog' );
178
179​Translate/utils/MessageTable.php
180​193: $linkAttribs += TranslationEditPage::jsEdit( $title, $this->group->getId() );
181
182​Translate/utils/TranslationEditPage.php
183​15:class TranslationEditPage {
184​32: * @return TranslationEditPage
185
186​Translate/specials/SpecialTranslate.php
187​61: $editpage = TranslationEditPage::newFromRequest( $request );
188
189​Translate/TranslateEditAddons.php
190​22: public static function suppressIntro( EditPage $editPage ) {
191​63: * Hook: EditPage::showEditForm:initial
192​65: public static function addTools( EditPage $object ) {
193​79: * Hook: EditPageBeforeEditButtons
194​81: public static function buttonHack( EditPage $editpage, &$buttons, $tabindex ) {
195​127: * @param EditPage $editpage
196​130: private static function editBoxes( EditPage $editpage ) {
197
198​Translate/Translate.php
199​101:$wgHooks['EditPage::showEditForm:initial'][] = 'TranslateEditAddons::addTools';
200​104:$wgHooks['EditPageBeforeEditButtons'][] = 'TranslateEditAddons::buttonHack';
201
202​Translate/Autoload.php
203​105:$al['TranslationEditPage'] = "$dir/utils/TranslationEditPage.php";
204
205​MoodBar/MoodBar.hooks.php
206​109: if ( class_exists('EditPageTracking') ) {
207​110: return ((bool)EditPageTracking::getFirstEditPage( $skin->getUser() ) );
208
209​MassMessage/includes/SpecialMassMessage.php
210​150: $m['message']['help'] = EditPage::getCopyrightWarning( $this->getPageTitle( false ), 'parse' );
211​263: * The preview generation code was hacked up from EditPage.php
212​285: // Parser stuff. Taken from EditPage::getPreviewText()
213​292: // Hooks not being run: EditPageGetPreviewContent, EditPageGetPreviewText
214
215​MassMessage/includes/SpecialEditMassMessageList.php
216​104: // Edit notices; modified from EditPage::showHeader()
217​111: // Protection warnings; modified from EditPage::showHeader()
218​212: return EditPage::getCopyrightWarning( $this->title, 'parse' );
219
220​ConfirmEdit/includes/ConfirmEditHooks.php
221​82: static function confirmEditPage( $editpage, $buttons, $tabindex ) {
222​221: * @param EditPage $editor
223​227: public static function onAlternateEditPreview( EditPage $editor, &$content, &$html, &$po ) {
224
225​ConfirmEdit/SimpleCaptcha/Captcha.php
226​180: * Show error message for missing or incorrect captcha on EditPage.
227​181: * @param EditPage $editPage
228​199: * @param EditPage $editPage
229​909: $status->value = EditPage::AS_HOOK_ERROR_EXPECTED;
230​1064: return $module instanceof ApiEditPage || $module instanceof ApiCreateAccount;
231
232​WikiEditor/WikiEditor.hooks.php
233​173: * EditPage::showEditForm:initial hook
234​177: * @param EditPage $editPage the current EditPage object.
235​231: * EditPage::showEditForm:fields hook
236​235: * @param EditPage $editPage the current EditPage object.
237​265: * EditPageBeforeEditToolbar hook
238​272: public static function EditPageBeforeEditToolbar( &$toolbar ) {
239​395: * This is attached to the MediaWiki 'EditPage::attemptSave' hook.
240​397: * @param EditPage $editPage
241​401: public static function editPageAttemptSave( EditPage $editPage ) {
242​416: * This is attached to the MediaWiki 'EditPage::attemptSave:after' hook.
243​418: * @param EditPage $editPage
244​422: public static function editPageAttemptSaveAfter( EditPage $editPage, Status $status ) {
245​439: if ( $status->value === EditPage::AS_CONFLICT_DETECTED ) {
246​441: } elseif ( $status->value === EditPage::AS_ARTICLE_WAS_DELETED ) {
247
248​TemplateData/TemplateData.hooks.php
249​84: // Specify format the same way the API and EditPage do to avoid extra parsing
250​102: * @param EditPage $editPage
251​106: public static function onEditPage( $editPage, $output ) {
252
253​Scribunto/Scribunto.php
254​71:$wgHooks['EditPageBeforeEditChecks'][] = 'ScribuntoHooks::beforeEditChecks';
255​72:$wgHooks['EditPage::showReadOnlyForm:initial'][] = 'ScribuntoHooks::showReadOnlyFormInitial';
256​73:$wgHooks['EditPageBeforeEditButtons'][] = 'ScribuntoHooks::beforeEditButtons';
257
258​Scribunto/common/Hooks.php
259​325: * EditPageBeforeEditChecks hook
260​327: * @param EditPage $editor
261​332: public static function beforeEditChecks( EditPage &$editor, &$checkboxes, &$tabindex ) {
262​342: * EditPage::showReadOnlyForm:initial hook
263​344: * @param EditPage $editor
264​347: public static function showReadOnlyFormInitial( EditPage $editor, OutputPage $output ) {
265​356: * EditPageBeforeEditButtons hook
266​358: * @param EditPage $editor
267​363: public static function beforeEditButtons( EditPage &$editor, array &$buttons, &$tabindex ) {
268​371: * @param EditPage $editor
269​377: public static function validateScript( EditPage $editor, $text, &$error, $summary ) {
270
271​TitleBlacklist/TitleBlacklist.hooks.php
272​245: * @param $editor EditPage
273
274​FlaggedRevs/backend/FlaggedRevs.hooks.php
275​391: # Get edit timestamp. Existance already validated by EditPage.php.
276
277​FlaggedRevs/frontend/FlaggedRevsUI.setup.php
278​39: $hooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsUIHooks::addToEditView';
279​42: $hooks['EditPageBeforeEditButtons'][] = 'FlaggedRevsUIHooks::onBeforeEditButtons';
280​44: $hooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsUIHooks::addReviewCheck';
281​45: $hooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsUIHooks::addRevisionIDField';
282​47: $hooks['EditPageNoSuchSection'][] = 'FlaggedRevsUIHooks::onNoSuchSection';
283
284​FlaggedRevs/frontend/FlaggablePageView.php
285​922: // HACK: EditPage invokes addToEditView() before this function, so $this->noticesDone
286​923: // will only be true if we're being called by EditPage, in which case we need to do nothing
287​929: // HACK fake EditPage
288​930: $editPage = new EditPage( new Article( $title, $oldid ) );
289​970: public function addToEditView( EditPage $editPage ) {
290​1076: public function addToNoSuchSection( EditPage $editPage, &$s ) {
291​1776: $extraQuery .= wfArrayToCgi( $params ); // note: EditPage will add initial "&"
292​1785: public function changeSaveButton( EditPage $editPage, array &$buttons ) {
293​1810: * @param EditPage $editPage
294​1813: protected function editWillRequireReview( EditPage $editPage ) {
295​1826: * @param EditPage $editPage
296​1829: protected function editRequiresReview( EditPage $editPage ) {
297​1841: * @param EditPage $editPage
298​1844: protected function editWillBeAutoreviewed( EditPage $editPage ) {
299​1873: public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex ) {
300​1922: public function addRevisionIDField( EditPage $editPage, OutputPage $out ) {
301​1935: * @param EditPage $editPage
302​1939: protected static function getBaseRevId( EditPage $editPage, WebRequest $request ) {
303​1968: * @param EditPage $editPage
304​1972: protected static function getAltBaseRevId( EditPage $editPage, WebRequest $request ) {
305
306​VisualEditor/VisualEditorDataModule.php
307​52: // Copyright warning (based on EditPage::getCopyrightWarning)
308​62: // EditPage supports customisation based on title, we can't support that
309​64: Hooks::run( 'EditPageCopyrightWarning', [ $title, &$copywarnMsgArgs ] );
310
311​VisualEditor/ApiVisualEditor.php
312​480: // HACK of course this code is partly duplicated from EditPage.php :(
313​517: // HACK: Build a fake EditPage so we can get checkboxes from it
314​519: $ep = new EditPage( $article );
315
316​VisualEditor/VisualEditor.hooks.php
317​390: * @param $editPage EditPage
318​394: public static function onEditPageShowEditFormFields( EditPage $editPage, OutputPage $output ) {

From that grep, I've already checked or submitted patches for everything but SemanticForms and FlaggedRevs. Both of which look kind of scary.

New grep:

1​Math/Math.hooks.php
2​401: static function onEditPageBeforeEditToolbar( &$toolbar ) {
3
4​CodeEditor/CodeEditor.hooks.php
5​45: * @param EditPage $editpage
6
7​ParserMigration/includes/EditAction.php
8​15: $page = new MigrationEditPage( $this->getContext(), $this->getTitle() );
9
10​ParserMigration/includes/MigrationEditPage.php
11​5:class MigrationEditPage extends \EditPage {
12
13​JsonConfig/includes/JCSingleton.php
14​669: $editor = new \EditPage( $article );
15​732: public static function onEditPageCopyrightWarning( $title, &$msg ) {
16
17​TemplateSandbox/SpecialTemplateSandbox.php
18​103: EditPage::getPreviewLimitReport( $this->output ) ) );
19
20​TemplateSandbox/TemplateSandbox.hooks.php
21​4: * Hook for EditPage::importFormData to parse our new form fields, and if
22​10: * @param EditPage $editpage
23​47: * @param EditPage $editpage
24​53: public static function templateSandboxPreview( EditPage $editpage, &$content, &$out,
25​130: ' [[#' . EditPage::EDITFORM_ID . '|' . $lang->getArrow() . ' ' .
26​179: * Hook for EditPage::showStandardInputs:options to add our form fields to
27​182: * @param EditPage $editpage
28
29​FlaggedRevs/backend/FlaggedRevs.hooks.php
30​400: # Get edit timestamp. Existance already validated by EditPage.php.
31
32​FlaggedRevs/FlaggedRevs.php
33​557:$wgHooks['EditPage::showEditForm:initial'][] = 'FlaggedRevsUIHooks::addToEditView';
34​560:$wgHooks['EditPageBeforeEditButtons'][] = 'FlaggedRevsUIHooks::onBeforeEditButtons';
35​563: $wgHooks['EditPageBeforeEditChecks'][] = 'FlaggedRevsUIHooks::onEditPageBeforeEditChecks';
36​565: $wgHooks['EditPageGetCheckboxesDefinition'][] =
37​566: 'FlaggedRevsUIHooks::onEditPageGetCheckboxesDefinition';
38​568:$wgHooks['EditPage::showEditForm:fields'][] = 'FlaggedRevsUIHooks::addRevisionIDField';
39​570:$wgHooks['EditPageNoSuchSection'][] = 'FlaggedRevsUIHooks::onNoSuchSection';
40
41​FlaggedRevs/frontend/FlaggedRevsUI.hooks.php
42​684: public static function onEditPageBeforeEditChecks( $editPage, &$checks, &$tabindex ) {
43​690: public static function onEditPageGetCheckboxesDefinition( $editPage, &$checkboxes ) {
44
45​FlaggedRevs/frontend/FlaggablePageView.php
46​951: // HACK: EditPage invokes addToEditView() before this function, so $this->noticesDone
47​952: // will only be true if we're being called by EditPage, in which case we need to do nothing
48​958: // HACK fake EditPage
49​959: $editPage = new EditPage( new Article( $title, $oldid ) );
50​1005: * @param EditPage $editPage
51​1008: public function addToEditView( EditPage $editPage ) {
52​1116: public function addToNoSuchSection( EditPage $editPage, &$s ) {
53​1833: $extraQuery .= wfArrayToCgi( $params ); // note: EditPage will add initial "&"
54​1842: public function changeSaveButton( EditPage $editPage, array &$buttons ) {
55​1872: * @param EditPage $editPage
56​1875: protected function editWillRequireReview( EditPage $editPage ) {
57​1888: * @param EditPage $editPage
58​1891: protected function editRequiresReview( EditPage $editPage ) {
59​1903: * @param EditPage $editPage
60​1906: protected function editWillBeAutoreviewed( EditPage $editPage ) {
61​1935: public function addReviewCheck( EditPage $editPage, array &$checkboxes, &$tabindex = null ) {
62​2001: public function addRevisionIDField( EditPage $editPage, OutputPage $out ) {
63​2014: * @param EditPage $editPage
64​2018: protected static function getBaseRevId( EditPage $editPage, WebRequest $request ) {
65​2047: * @param EditPage $editPage
66​2051: protected static function getAltBaseRevId( EditPage $editPage, WebRequest $request ) {
67
68​ContentTranslation/ContentTranslation.hooks.php
69​208: * Hook: EditPage::showEditForm:initial
70​210: public static function newArticleCampaign( EditPage $newPage, OutputPage $out ) {
71
72​Wikidata/vendor/composer/autoload_classmap.php
73​1347: 'Wikibase\\Repo\\Tests\\Api\\EditPageTest' => $baseDir . '/extensions/Wikibase/repo/tests/phpunit/includes/Api/EditPageTest.php',
74
75​Wikidata/vendor/composer/autoload_static.php
76​1638: 'Wikibase\\Repo\\Tests\\Api\\EditPageTest' => __DIR__ . '/../..' . '/extensions/Wikibase/repo/tests/phpunit/includes/Api/EditPageTest.php',
77
78​Wikidata/extensions/Wikibase/lib/includes/Store/EntityStore.php
79​99: * @see EditPage::userWasLastToEdit()
80
81​Wikidata/extensions/Wikibase/lib/tests/phpunit/MockRepository.php
82​557: * @see EditPage::userWasLastToEdit
83
84​Wikidata/extensions/Wikibase/repo/Wikibase.hooks.php
85​6:use ApiEditPage;
86​511: * This implementation causes the execution of ApiEditPage (action=edit) to fail
87​526: if ( $module instanceof ApiEditPage ) {
88​538: // trying to use ApiEditPage on an entity namespace
89
90​Wikidata/extensions/Wikibase/repo/includes/Api/ResultBuilder.php
91​1074: // like core's ApiEditPage
92
93​Wikidata/extensions/Wikibase/repo/includes/EditEntity.php
94​732: * @note Keep in sync with logic in EditPage!
95​751: * @note Keep in sync with logic in EditPage!
96
97​Wikidata/extensions/Wikibase/repo/includes/Store/Sql/WikiPageEntityStore.php
98​351: * @see EditPage::userWasLastToEdit()
99​395: * @note keep in sync with logic in EditPage
100
101​Wikidata/extensions/Wikibase/repo/includes/Actions/EditEntityAction.php
102​385: * Generate standard summary input and label (wgSummary), compatible to EditPage.
103
104​Wikidata/extensions/Wikibase/repo/tests/phpunit/includes/Api/EditPageTest.php
105​26:class EditPageTest extends WikibaseApiTestCase {
106​36: $item->setLabel( "en", "EditPageTest" );
107​39: $item->setLabel( "de", "EditPageTest" );
108
109​Wikidata/extensions/Wikibase/client/includes/Hooks/EditActionHookHandler.php
110​5:use EditPage;
111​84: public function handle( EditPage $editor ) {
112
113​Wikidata/extensions/Wikibase/client/WikibaseClient.hooks.php
114​8:use EditPage;
115​326: * @param EditPage $editor
116​330: public static function onEditAction( EditPage $editor, OutputPage $output, &$tabindex ) {
117
118​Wikidata/extensions/Wikibase/client/tests/phpunit/includes/Hooks/EditActionHookHandlerTest.php
119​5:use EditPage;
120​42: $editor = $this->getEditPage();
121​192: * @return EditPage
122​194: private function getEditPage() {
123​197: $editor = $this->getMockBuilder( EditPage::class )
124
125​Wikidata/extensions/Wikibase/client/WikibaseClient.php
126​139: $wgHooks['EditPage::showStandardInputs:options'][] = '\Wikibase\ClientHooks::onEditAction';
127
128​CollaborationKit/includes/CollaborationHubContentEditor.php
129​10:class CollaborationHubContentEditor extends EditPage {
130
131​CollaborationKit/includes/CollaborationListContentEditor.php
132​5: * Extends the notorious EditPage class.
133​11:class CollaborationListContentEditor extends EditPage {
134
135​SpamBlacklist/SpamBlacklistHooks.php
136​69: // Always return true, EditPage will look at $status->isOk().
137​125: * @param $editPage EditPage
138
139​TemplateData/TemplateData.hooks.php
140​83: // Specify format the same way the API and EditPage do to avoid extra parsing
141​101: * @param EditPage $editPage
142​105: public static function onEditPage( $editPage, $output ) {
143
144​TwoColConflict/includes/TwoColConflictPage.php
145​8:class TwoColConflictPage extends EditPage {
146
147​TwoColConflict/includes/TwoColConflictHooks.php
148​41: * @param EditPage $editPage
149​44: public static function onAttemptSaveAfter( EditPage $editPage, Status $status ) {
150​51: if ( $status->value == EditPage::AS_SUCCESS_UPDATE ) {
151
152​MassMessage/includes/SpecialMassMessage.php
153​150: $m['message']['help'] = EditPage::getCopyrightWarning( $this->getPageTitle( false ), 'parse' );
154​262: * The preview generation code was hacked up from EditPage.php
155​284: // Parser stuff. Taken from EditPage::getPreviewText()
156​291: // Hooks not being run: EditPageGetPreviewContent, EditPageGetPreviewText
157
158​MassMessage/includes/SpecialEditMassMessageList.php
159​104: // Edit notices; modified from EditPage::showHeader()
160​111: // Protection warnings; modified from EditPage::showHeader()
161​212: return EditPage::getCopyrightWarning( $this->title, 'parse' );
162
163​WikiEditor/WikiEditor.hooks.php
164​158: * EditPage::showEditForm:initial hook
165​162: * @param EditPage $editPage the current EditPage object.
166​214: * EditPage::showEditForm:fields hook
167​218: * @param EditPage $editPage the current EditPage object.
168​248: * EditPageBeforeEditToolbar hook
169​255: public static function EditPageBeforeEditToolbar( &$toolbar ) {
170​381: * This is attached to the MediaWiki 'EditPage::attemptSave' hook.
171​383: * @param EditPage $editPage
172​386: public static function editPageAttemptSave( EditPage $editPage ) {
173​401: * This is attached to the MediaWiki 'EditPage::attemptSave:after' hook.
174​403: * @param EditPage $editPage
175​407: public static function editPageAttemptSaveAfter( EditPage $editPage, Status $status ) {
176​424: if ( $status->value === EditPage::AS_CONFLICT_DETECTED ) {
177​426: } elseif ( $status->value === EditPage::AS_ARTICLE_WAS_DELETED ) {
178
179​WikimediaEvents/WikimediaEventsHooks.php
180​393: * @see https://www.mediawiki.org/wiki/Manual:Hooks/EditPageBeforeConflictDiff
181​395: * @param EditPage &$editor
182​399: public static function onEditPageBeforeConflictDiff( &$editor, &$out ) {
183
184​VisualEditor/VisualEditor.hooks.php
185​173: private static function isSupportedEditPage( Title $title, User $user, WebRequest $req ) {
186​245: if ( self::isSupportedEditPage( $title, $user, $req ) ) {
187​489: * @param EditPage $editPage The edit page view.
188​493: public static function onEditPageShowEditFormFields( EditPage $editPage, OutputPage $output ) {
189
190​VisualEditor/ApiVisualEditor.php
191​307: // From EditPage#showCustomIntro
192​391: // HACK of course this code is partly duplicated from EditPage.php :(
193​437: // HACK: Build a fake EditPage so we can get checkboxes from it
194​440: $editPage = new EditPage( $article );
195
196​VisualEditor/VisualEditorDataModule.php
197​63: 'copyrightwarning' => EditPage::getCopyrightWarning(
198
199​ConfirmEdit/includes/ConfirmEditHooks.php
200​59: static function confirmEditPage( $editpage, $buttons, $tabindex ) {
201​180: * @param EditPage $editor
202​186: public static function onAlternateEditPreview( EditPage $editor, &$content, &$html, &$po ) {
203
204​ConfirmEdit/SimpleCaptcha/Captcha.php
205​189: * Show error message for missing or incorrect captcha on EditPage.
206​190: * @param EditPage $editPage
207​208: * @param EditPage $editPage
208​806: $status->value = EditPage::AS_HOOK_ERROR_EXPECTED;
209​894: return $module instanceof ApiEditPage;
210
211​WikimediaMessages/WikimediaMessages.hooks.php
212​161: public static function onEditPageCopyrightWarning( $title, &$msg ) {
213
214​TitleBlacklist/TitleBlacklist.hooks.php
215​256: * @param EditPage $editor
216
217​Newsletter/includes/NewsletterEditPage.php
218​8:class NewsletterEditPage {
219
220​Newsletter/includes/specials/SpecialNewsletter.php
221​365: $reasonSpamMatch = EditPage::matchSummarySpamRegex( $data['summary'] );
222
223​Newsletter/Newsletter.hooks.php
224​168: * @param EditPage $editPage
225​171: public static function onAlternateEdit( EditPage $editPage ) {
226​202: $editPage = new NewsletterEditPage( $article->getContext(), $newsletter );
227​207: $editPage = new NewsletterEditPage( $article->getContext() );
228
229​Scribunto/common/Hooks.php
230​312: * EditPage::showStandardInputs:options hook
231​314: * @param EditPage $editor
232​319: public static function showStandardInputsOptions( EditPage $editor, OutputPage $output, &$tab ) {
233​328: * EditPage::showReadOnlyForm:initial hook
234​330: * @param EditPage $editor
235​333: public static function showReadOnlyFormInitial( EditPage $editor, OutputPage $output ) {
236​342: * EditPageBeforeEditButtons hook
237​344: * @param EditPage $editor
238​349: public static function beforeEditButtons( EditPage &$editor, array &$buttons, &$tabindex ) {
239
240​Translate/Autoload.php
241​104:$al['TranslationEditPage'] = "$dir/utils/TranslationEditPage.php";
242
243​Translate/TranslateEditAddons.php
244​22: public static function suppressIntro( EditPage $editPage ) {
245​85: * Hook: EditPage::showEditForm:initial
246​87: public static function addTools( EditPage $object ) {
247​101: * Hook: EditPageBeforeEditButtons
248​103: public static function buttonHack( EditPage $editpage, &$buttons, $tabindex ) {
249​174: * @param EditPage $editpage
250​177: private static function editBoxes( EditPage $editpage ) {
251
252​Translate/tag/PageTranslationHooks.php
253​403: * edit conflict if there wasn't tpSyntaxCheckForEditPage.
254
255​Translate/Translate.php
256​101:$wgHooks['EditPage::showEditForm:initial'][] = 'TranslateEditAddons::addTools';
257​104:$wgHooks['EditPageBeforeEditButtons'][] = 'TranslateEditAddons::buttonHack';
258
259​Translate/utils/TranslationEditPage.php
260​15:class TranslationEditPage {
261​32: * @return TranslationEditPage
262
263​Translate/utils/TranslationHelpers.php
264​633: $jsEdit = TranslationEditPage::jsEdit( $target, $groupId, 'dialog' );
265
266​Translate/utils/MessageTable.php
267​193: $linkAttribs += TranslationEditPage::jsEdit( $title, $this->group->getId() );
268
269​Translate/specials/SpecialTranslate.php
270​63: $editpage = TranslationEditPage::newFromRequest( $request );
271
272​ProofreadPage/includes/page/PageSubmitAction.php
273​21: $editor = new EditPagePage( $this->page, $pagePage, Context::getDefaultContext() );
274
275​ProofreadPage/includes/page/EditPagePage.php
276​7:use EditPage;
277​17:class EditPagePage extends EditPage {
278​49: * @see EditPage::isSectionEditSupported
279​56: * @see EditPage::isSupportedContentModel
280​65: * @see EditPage::showContentForm
281​75: * @see EditPage::showContentForm
282​148: * @see EditPage::getCheckBoxes
283​199: * @see EditPage::importContentFormData
284​217: * @see EditPage::internalAttemptSave
285
286​ProofreadPage/includes/page/PageEditAction.php
287​21: $editor = new EditPagePage( $this->page, $pagePage, Context::getDefaultContext() );
288
289​ProofreadPage/includes/index/EditIndexPage.php
290​6:use EditPage;
291​19:class EditIndexPage extends EditPage {
292​33: * @see EditPage::isSectionEditSupported
293​40: * @see EditPage::isSupportedContentModel
294​47: * @see EditPage::showContentForm
295​138: * @see EditPage::importContentFormData
296​192: * @see EditPage::internalAttemptSave
297
298​LiquidThreads/classes/Hooks.php
299​313: * Handle EditPageGetCheckboxesDefinition hook
300​315: * @param $editPage EditPage
301
302​LiquidThreads/classes/View.php
303​543: $e = new EditPage( $article );
304​661: $e = new EditPage( $article );
305​775: $e = new EditPage( $article );
306​880: $e = new EditPage( $article );
307​1851: // as it would involve rewriting EditPage, which I do NOT intend to do.
308​2132: Hooks::run( 'EditPageBeforeEditToolbar', [ &$html ] );
309
310​LiquidThreads/api/ApiThreadAction.php
311​3:class ApiThreadAction extends ApiEditPage {
312
313​GlobalCssJs/GlobalCssJs.hooks.php
314​113: * @param EditPage $editPage
315​117: static function onEditPageshowEditForminitial( EditPage $editPage, OutputPage $output ) {

I've gotten as far as WikiEditor in that grep and submitted a set of patches to TwoColConflict.

Change 375951 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@master] EditPage: Don't use $wgOut

https://gerrit.wikimedia.org/r/375951

Change 375951 merged by jenkins-bot:
[mediawiki/core@master] EditPage: Don't use $wgOut

https://gerrit.wikimedia.org/r/375951

Change 378340 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@master] EditPage: Don't use $wgUser

https://gerrit.wikimedia.org/r/378340

Change 378340 merged by jenkins-bot:
[mediawiki/core@master] EditPage: Don't use $wgUser

https://gerrit.wikimedia.org/r/378340

Change 379163 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@master] EditPage: Don't use $wgRequest

https://gerrit.wikimedia.org/r/379163

The last remaining usage of $wgOut will go away with T30856: Remove classic edit toolbar from core so I'm tempted to leave it for now.

Change 379166 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@master] EditPage: Try to avoid using $wgTitle

https://gerrit.wikimedia.org/r/379166

Legoktm updated the task description. (Show Details)Sep 20 2017, 4:57 AM

Change 379163 merged by jenkins-bot:
[mediawiki/core@master] EditPage: Don't use $wgRequest

https://gerrit.wikimedia.org/r/379163

Change 379166 merged by jenkins-bot:
[mediawiki/core@master] EditPage: Try to avoid using $wgTitle

https://gerrit.wikimedia.org/r/379166

Change 379462 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@master] EditPage: Stop using globals for configuration in non-static functions

https://gerrit.wikimedia.org/r/379462

With the above patch I think we're as close to finishing this task as reasonably possible. The rest of the code is static or globals without a replacement ($wgContLang, $wgParser).

Change 379462 merged by jenkins-bot:
[mediawiki/core@master] EditPage: Stop using globals for configuration in non-static functions

https://gerrit.wikimedia.org/r/379462

Change 379858 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@REL1_30] EditPage: Don't use $wgRequest

https://gerrit.wikimedia.org/r/379858

Change 379859 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@REL1_30] EditPage: Try to avoid using $wgTitle

https://gerrit.wikimedia.org/r/379859

Change 379863 had a related patch set uploaded (by Legoktm; owner: Legoktm):
[mediawiki/core@REL1_30] EditPage: Stop using globals for configuration in non-static functions

https://gerrit.wikimedia.org/r/379863

Change 379858 merged by jenkins-bot:
[mediawiki/core@REL1_30] EditPage: Don't use $wgRequest

https://gerrit.wikimedia.org/r/379858

Change 379859 merged by jenkins-bot:
[mediawiki/core@REL1_30] EditPage: Try to avoid using $wgTitle

https://gerrit.wikimedia.org/r/379859

Legoktm updated the task description. (Show Details)Sep 22 2017, 9:32 PM
Legoktm updated the task description. (Show Details)Sep 22 2017, 9:38 PM
Legoktm closed this task as Resolved.

There are still some global config variables left, but those require further refactoring (most of which is already planned). The only global context variable left is $wgTitle, and that's only in fallback mode. T176526: Remove $wgTitle fallback from EditPage is tracked to kill it entirely.

Change 379863 merged by jenkins-bot:
[mediawiki/core@REL1_30] EditPage: Stop using globals for configuration in non-static functions

https://gerrit.wikimedia.org/r/379863