Merge "Reduce public methods of EditPage"

This commit is contained in:
jenkins-bot 2020-11-18 03:58:36 +00:00 committed by Gerrit Code Review
commit 5d4b38f0fc
2 changed files with 9 additions and 17 deletions

View file

@ -1187,7 +1187,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();
@ -1575,17 +1575,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.
@ -3254,7 +3243,7 @@ class EditPage implements IEditObject {
* @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] ) );
@ -3471,7 +3460,7 @@ class EditPage implements IEditObject {
*
* @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 )
);
@ -4584,7 +4573,7 @@ class EditPage implements IEditObject {
* 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() {