From 0f60a6d6ce435b9122d4ec059f6b74978c057834 Mon Sep 17 00:00:00 2001 From: Florian Date: Fri, 1 Apr 2016 21:56:56 +0200 Subject: [PATCH] Remove (WikiPage|Article)::replaceSection() Bug: T122754 Change-Id: I1415c8de7be3b9d952fad265b439dd820e284fb2 Depends-On: I3d37f7e778d569970ed749c22ba49a63cc4ba0ec --- RELEASE-NOTES-1.27 | 2 ++ includes/EditPage.php | 4 +-- includes/page/Article.php | 13 ------- includes/page/WikiPage.php | 38 -------------------- tests/phpunit/includes/page/WikiPageTest.php | 16 --------- 5 files changed, 4 insertions(+), 69 deletions(-) diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27 index ab200b8554..a08fc56524 100644 --- a/RELEASE-NOTES-1.27 +++ b/RELEASE-NOTES-1.27 @@ -388,6 +388,8 @@ changes to languages because of Phabricator reports. way. Run `composer install` to install it and other dev dependencies to run unit tests. * wl_id field added to the watchlist table. * Revision::getRawText() was removed (deprecated since 1.21). +* WikiPage::replaceSection() was removed (deprecated since 1.21). +* Article::replaceSection() was removed (deprecated since 1.21). == Compatibility == diff --git a/includes/EditPage.php b/includes/EditPage.php index b3bb07aa37..352253163c 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1175,7 +1175,7 @@ class EditPage { * Get the content of the wanted revision, without section extraction. * * The result of this function can be used to compare user's input with - * section replaced in its context (using WikiPage::replaceSection()) + * section replaced in its context (using WikiPage::replaceSectionAtRev()) * to the original text of the edit. * * This differs from Article::getContent() that when a missing revision is @@ -1982,7 +1982,7 @@ class EditPage { } elseif ( $this->section != '' ) { # Try to get a section anchor from the section source, redirect # to edited section if header found. - # XXX: Might be better to integrate this into Article::replaceSection + # XXX: Might be better to integrate this into Article::replaceSectionAtRev # for duplicate heading checking and maybe parsing. $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches ); # We can't deal with anchors, includes, html etc in the header for now, diff --git a/includes/page/Article.php b/includes/page/Article.php index 7592017ca3..c4ccadecda 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -2551,19 +2551,6 @@ class Article implements Page { return $this->mPage->protectDescriptionLog( $limit, $expiry ); } - /** - * Call to WikiPage function for backwards compatibility. - * @see WikiPage::replaceSection - */ - public function replaceSection( $sectionId, $text, $sectionTitle = '', - $edittime = null - ) { - ContentHandler::deprecated( __METHOD__, '1.21' ); - return $this->mPage->replaceSection( $sectionId, $text, $sectionTitle, - $edittime - ); - } - /** * Call to WikiPage function for backwards compatibility. * @see WikiPage::replaceSectionAtRev diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 0e3512b5ae..48f2a7fd77 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -1383,44 +1383,6 @@ class WikiPage implements Page, IDBAccessObject { return false; } - /** - * @param string|number|null|bool $sectionId Section identifier as a number or string - * (e.g. 0, 1 or 'T-1'), null/false or an empty string for the whole page - * or 'new' for a new section. - * @param string $text New text of the section. - * @param string $sectionTitle New section's subject, only if $section is "new". - * @param string $edittime Revision timestamp or null to use the current revision. - * - * @throws MWException - * @return string|null New complete article text, or null if error. - * - * @deprecated since 1.21, use replaceSectionAtRev() instead - */ - public function replaceSection( $sectionId, $text, $sectionTitle = '', - $edittime = null - ) { - ContentHandler::deprecated( __METHOD__, '1.21' ); - - // NOTE: keep condition in sync with condition in replaceSectionContent! - if ( strval( $sectionId ) === '' ) { - // Whole-page edit; let the whole text through - return $text; - } - - if ( !$this->supportsSections() ) { - throw new MWException( "sections not supported for content model " . - $this->getContentHandler()->getModelID() ); - } - - // could even make section title, but that's not required. - $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); - - $newContent = $this->replaceSectionContent( $sectionId, $sectionContent, $sectionTitle, - $edittime ); - - return ContentHandler::getContentText( $newContent ); - } - /** * Returns true if this page's content model supports sections. * diff --git a/tests/phpunit/includes/page/WikiPageTest.php b/tests/phpunit/includes/page/WikiPageTest.php index d488eee413..10e0f5962a 100644 --- a/tests/phpunit/includes/page/WikiPageTest.php +++ b/tests/phpunit/includes/page/WikiPageTest.php @@ -767,22 +767,6 @@ more stuff ]; } - /** - * @dataProvider dataReplaceSection - * @covers WikiPage::replaceSection - */ - public function testReplaceSection( $title, $model, $text, $section, $with, - $sectionTitle, $expected - ) { - $this->hideDeprecated( "WikiPage::replaceSection" ); - - $page = $this->createPage( $title, $text, $model ); - $text = $page->replaceSection( $section, $with, $sectionTitle ); - $text = trim( $text ); - - $this->assertEquals( $expected, $text ); - } - /** * @dataProvider dataReplaceSection * @covers WikiPage::replaceSectionContent -- 2.20.1