Brion VIBBER has submitted this change and it was merged.
Change subject: Allow creation of empty MediaWiki: pages
......................................................................
Allow creation of empty MediaWiki: pages
This is useful now since it's possible to disable messages by blanking
them (see bug 14176).
Instead disallow creation of page contents equivalent to the default
message to serve the same purpose as disallowing blanking did (prevent
edits which wouldn't change anything anyway; the edit form is even
prefilled with the default contents).
Bug: 50124
Change-Id: I070036f341b866cda67eb928c5b74ad2ce6c527c
---
M includes/EditPage.php
M tests/phpunit/includes/EditPageTest.php
2 files changed, 93 insertions(+), 9 deletions(-)
Approvals:
Brion VIBBER: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 84bb493..96cc908 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -1507,8 +1507,17 @@
return $status;
}
- # Don't save a new article if it's blank.
- if ( $this->textbox1 == '' ) {
+ // Don't save a new page if it's blank or if it's a
MediaWiki:
+ // message with content equivalent to default (allow
empty pages
+ // in this case to disable messages, see bug 50124)
+ $defaultMessageText =
$this->mTitle->getDefaultMessageText();
+ if( $this->mTitle->getNamespace() === NS_MEDIAWIKI &&
$defaultMessageText !== false ) {
+ $defaultText = $defaultMessageText;
+ } else {
+ $defaultText = '';
+ }
+
+ if ( $this->textbox1 === $defaultText ) {
$status->setResult( false,
self::AS_BLANK_ARTICLE );
wfProfileOut( __METHOD__ );
return $status;
diff --git a/tests/phpunit/includes/EditPageTest.php
b/tests/phpunit/includes/EditPageTest.php
index 00eba30..3544e5c 100644
--- a/tests/phpunit/includes/EditPageTest.php
+++ b/tests/phpunit/includes/EditPageTest.php
@@ -173,15 +173,90 @@
}
public function testCreatePage() {
- $text = "Hello World!";
- $edit = array(
- 'wpTextbox1' => $text,
- 'wpSummary' => 'just testing',
+ $this->assertEdit(
+ 'EditPageTest_testCreatePage',
+ null,
+ null,
+ array(
+ 'wpTextbox1' => "Hello World!",
+ ),
+ EditPage::AS_SUCCESS_NEW_ARTICLE,
+ "Hello World!",
+ "expected article being created"
+ )->doDeleteArticleReal( 'EditPageTest_testCreatePage' );
+
+ $this->assertEdit(
+ 'EditPageTest_testCreatePage',
+ null,
+ null,
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ null,
+ "expected article not being created if empty"
);
- $this->assertEdit( 'EditPageTest_testCreatePafe', null, null,
$edit,
- EditPage::AS_SUCCESS_NEW_ARTICLE, $text,
- "expected successfull creation with given text" );
+
+ $this->assertEdit(
+ 'MediaWiki:January',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "Not January",
+ ),
+ EditPage::AS_SUCCESS_NEW_ARTICLE,
+ "Not January",
+ "expected MediaWiki: page being created"
+ )->doDeleteArticleReal( 'EditPageTest_testCreatePage' );
+
+ $this->assertEdit(
+ 'MediaWiki:EditPageTest_testCreatePage',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ null,
+ "expected not-registered MediaWiki: page not being
created if empty"
+ );
+
+ $this->assertEdit(
+ 'MediaWiki:January',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_SUCCESS_NEW_ARTICLE,
+ "",
+ "expected registered MediaWiki: page being created even
if empty"
+ )->doDeleteArticleReal( 'EditPageTest_testCreatePage' );
+
+ $this->assertEdit(
+ 'MediaWiki:Ipb-default-expiry',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ "",
+ "expected registered MediaWiki: page whose default
content is empty not being created if empty"
+ );
+
+ $this->assertEdit(
+ 'MediaWiki:January',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "January",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ null,
+ "expected MediaWiki: page not being created if text
equals default message"
+ );
}
public function testUpdatePage() {
--
To view, visit https://gerrit.wikimedia.org/r/71332
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I070036f341b866cda67eb928c5b74ad2ce6c527c
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matmarex <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: IAlex <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: Matmarex <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits