Reduce public methods of EditPage

Make private the methods only needed
in the class (and tests), no need for deprecation
because they are not used in any extension per
codesearch. Remove EditPage::setPreloadedContent
entirely, since it is unused.

Bug: T252907
Change-Id: Id47421e01da51d57842390682ace2c33eec3b467
This commit is contained in:
DannyS712 2020-11-10 23:36:02 +00:00
parent d5e294bde9
commit 5654c9559a
2 changed files with 9 additions and 17 deletions

View file

@ -1176,7 +1176,7 @@ class EditPage implements IEditObject {
* Called on the first invocation, e.g. when a user clicks an edit link
* @return bool If the requested section is valid
*/
public function initialiseForm() {
private function initialiseForm() {
$this->edittime = $this->page->getTimestamp();
$this->editRevId = $this->page->getLatest();
@ -1564,17 +1564,6 @@ class EditPage implements IEditObject {
return $content;
}
/**
* Use this method before edit() to preload some content into the edit box
*
* @param Content $content
*
* @since 1.21
*/
public function setPreloadedContent( Content $content ) {
$this->mPreloadContent = $content;
}
/**
* Get the contents to be preloaded into the box, either set by
* an earlier setPreloadText() or by loading the given page.
@ -3300,7 +3289,7 @@ ERROR;
* @param string $text
* @return string|bool String or false
*/
public static function extractSectionTitle( $text ) {
private static function extractSectionTitle( $text ) {
if ( preg_match( "/^(=+)(.+)\\1\\s*(\n|$)/i", $text, $matches ) ) {
return MediaWikiServices::getInstance()->getParser()
->stripSectionName( trim( $matches[2] ) );
@ -3517,7 +3506,7 @@ ERROR;
*
* @return OOUI\FieldLayout OOUI FieldLayout with Label and Input
*/
public function getSummaryInputWidget( $summary = "", $labelText = null, $inputAttrs = null ) {
private function getSummaryInputWidget( $summary = "", $labelText = null, $inputAttrs = null ) {
$inputAttrs = OOUI\Element::configFromHtmlAttributes(
$this->getSummaryInputAttributes( $inputAttrs )
);
@ -4630,7 +4619,7 @@ ERROR;
* Creates a basic error page which informs the user that
* they have attempted to edit a nonexistent section.
*/
public function noSuchSectionPage() {
private function noSuchSectionPage() {
$out = $this->context->getOutput();
$out->prepareErrorPage( $this->context->msg( 'nosuchsectiontitle' ) );

View file

@ -1,6 +1,7 @@
<?php
use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
/**
* @group Editing
@ -37,8 +38,10 @@ class EditPageTest extends MediaWikiLangTestCase {
* @covers EditPage::extractSectionTitle
*/
public function testExtractSectionTitle( $section, $title ) {
$extracted = EditPage::extractSectionTitle( $section );
$this->assertEquals( $title, $extracted );
$this->assertEquals(
$title,
TestingAccessWrapper::newFromClass( EditPage::class )->extractSectionTitle( $section )
);
}
public static function provideExtractSectionTitle() {