[MediaWiki-commits] [Gerrit] Enable the creation of empty pages - change (mediawiki/core)

2014-07-25 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Enable the creation of empty pages
..


Enable the creation of empty pages

This change enables the direct creation of empty pages without needing
to use a work-around (such as {{subst:ns:0}}). A warning is added as
the message blankarticle to request confirmation that the empty page
was meant to be blank. A automatic edit summary has been added when
creating a blank page. The message is: autosumm-newblank.

The API has been updated to permit the creation of empty pages, when
text is null, but not non-existant.

Unit tests have also been added to test these features.

Bug: 57238
Bug: 65206
Change-Id: I3457c36a909d1dbfaeed04a1f0568c69e0ef3386
---
M RELEASE-NOTES-1.24
M includes/EditPage.php
M includes/api/ApiEditPage.php
M includes/content/ContentHandler.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M tests/phpunit/includes/EditPageTest.php
M tests/phpunit/includes/api/ApiEditPageTest.php
8 files changed, 46 insertions(+), 15 deletions(-)

Approvals:
  Parent5446: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index cd24ef0..fa24dad 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -161,6 +161,7 @@
   wrong constraints.
 * (bug 67870) wfShellExec() cuts off stdout at multiples of 8192 bytes.
 * $wgRunJobsAsync now works with private wikis (e.g. read requires login).
+* (bugs 57238, 65206) Blank pages can now be directly created.
 
 === Web API changes in 1.24 ===
 * action=parse API now supports prop=modules, which provides the list of
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 5864c9b..50225cc 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -99,7 +99,7 @@
const AS_NO_CREATE_PERMISSION = 223;
 
/**
-* Status: user tried to create a blank page
+* Status: user tried to create a blank page and wpIgnoreBlankArticle 
== false
 */
const AS_BLANK_ARTICLE = 224;
 
@@ -243,6 +243,12 @@
 
/** @var bool */
protected $allowBlankSummary = false;
+
+   /** @var bool */
+   protected $blankArticle = false;
+
+   /** @var bool */
+   protected $allowBlankArticle = false;
 
/** @var string */
protected $autoSumm = '';
@@ -850,6 +856,8 @@
}
 
$this-autoSumm = $request-getText( 'wpAutoSummary' );
+
+   $this-allowBlankArticle = $request-getBool( 
'wpIgnoreBlankArticle' );
} else {
# Not a posted form? Start with nothing.
wfDebug( __METHOD__ . : Not a posted form.\n );
@@ -1390,6 +1398,7 @@
case self::AS_TEXTBOX_EMPTY:
case self::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case self::AS_END:
+   case self::AS_BLANK_ARTICLE:
return true;
 
case self::AS_HOOK_ERROR:
@@ -1423,10 +1432,6 @@
}
}
$wgOut-redirect( $this-mTitle-getFullURL( 
$extraQuery ) . $sectionanchor );
-   return false;
-
-   case self::AS_BLANK_ARTICLE:
-   $wgOut-redirect( 
$this-getContextTitle()-getFullURL() );
return false;
 
case self::AS_SPAM_ERROR:
@@ -1767,7 +1772,9 @@
$defaultText = '';
}
 
-   if ( $this-textbox1 === $defaultText ) {
+   if ( !$this-allowBlankArticle  $this-textbox1 === 
$defaultText ) {
+   $this-blankArticle = true;
+   $status-fatal( 'blankarticle' );
$status-setResult( false, 
self::AS_BLANK_ARTICLE );
wfProfileOut( __METHOD__ );
return $status;
@@ -2521,6 +2528,10 @@
$wgOut-addHTML( EditPage::getEditToolbar() );
}
 
+   if ( $this-blankArticle ) {
+   $wgOut-addHTML( Html::hidden( 'wpIgnoreBlankArticle', 
true ) );
+   }
+
if ( $this-isConflict ) {
// In an edit conflict bypass the overridable content 
form method
// and fallback to the raw wpTextbox1 since 
editconflicts can't be
@@ -2649,6 +2660,10 @@
$wgOut-wrapWikiMsg( div 
id='mw-missingcommentheader'\n$1\n/div, 'missingcommentheader' );
}
 
+   if ( $this-blankArticle ) {
+   $wgOut-wrapWikiMsg( div 
id='mw-blankarticle'\n$1\n/div, 

[MediaWiki-commits] [Gerrit] Enable the creation of empty pages - change (mediawiki/core)

2014-07-13 Thread Ebe123 (Code Review)
Ebe123 has uploaded a new change for review.

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

Change subject: Enable the creation of empty pages
..

Enable the creation of empty pages

This change enables the direct creation of empty pages without needing
to use a work-around (such as {{subst:ns:0}}). A warning is added as
the message blankarticle to request confirmation that the empty page
was meant to be blank.

May possibly fix bug 57238
Bug: 65206

Change-Id: I3457c36a909d1dbfaeed04a1f0568c69e0ef3386
---
M RELEASE-NOTES-1.24
M includes/EditPage.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 14 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/99/145899/1

diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24
index 3686548..38314d6 100644
--- a/RELEASE-NOTES-1.24
+++ b/RELEASE-NOTES-1.24
@@ -141,6 +141,8 @@
 * (bug 65757) MSSQL: Update script drops unnamed constraints to be prepared
   for future updates. Because it's doing so heuristically, it may fail or drop
   wrong constraints.
+* (bugs 57238, 65206) Empty pages are now able to be made without a 
work-around.
+  A warning has been added when attempting to do such.
 
 === Web API changes in 1.24 ===
 * action=parse API now supports prop=modules, which provides the list of
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 3d57e95..f341561 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -254,6 +254,9 @@
/** @var bool */
protected $allowBlankSummary = false;
 
+   /** @var bool */
+   protected $blankArticle = false;
+
/** @var string */
protected $autoSumm = '';
 
@@ -1400,6 +1403,7 @@
case self::AS_TEXTBOX_EMPTY:
case self::AS_MAX_ARTICLE_SIZE_EXCEEDED:
case self::AS_END:
+   case self::AS_BLANK_ARTICLE:
return true;
 
case self::AS_HOOK_ERROR:
@@ -1433,10 +1437,6 @@
}
}
$wgOut-redirect( $this-mTitle-getFullURL( 
$extraQuery ) . $sectionanchor );
-   return false;
-
-   case self::AS_BLANK_ARTICLE:
-   $wgOut-redirect( 
$this-getContextTitle()-getFullURL() );
return false;
 
case self::AS_SPAM_ERROR:
@@ -1747,6 +1747,8 @@
}
 
if ( $this-textbox1 === $defaultText ) {
+   $this-blankArticle = true;
+   $status-fatal( 'blankarticle' );
$status-setResult( false, 
self::AS_BLANK_ARTICLE );
wfProfileOut( __METHOD__ );
return $status;
@@ -2664,6 +2666,10 @@
$wgOut-wrapWikiMsg( div 
id='mw-missingcommentheader'\n$1\n/div, 'missingcommentheader' );
}
 
+   if ( $this-blankArticle ) {
+   $wgOut-wrapWikiMsg( div 
id='mw-blankarticle'\n$1\n/div, 'blankarticle' );
+   }
+
if ( $this-hookError !== '' ) {
$wgOut-addWikiText( $this-hookError );
}
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index c06c29e..daeb450 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -582,6 +582,7 @@
preview: Preview,
showpreview: Show preview,
showdiff: Show changes,
+   blankarticle: strongWarning:/strong The page you are creating is 
blank.\nIf you click \{{int:savearticle}}\ again, the page will be created 
without any content.,
anoneditwarning: strongWarning:/strong You are not logged 
in.\nYour IP address will be recorded in this page's edit history.,
anonpreviewwarning: emYou are not logged in. Saving will record 
your IP address in this page's edit history./em,
missingsummary: strongReminder:/strong You have not provided an 
edit summary.\nIf you click \{{int:savearticle}}\ again, your edit will be 
saved without one.,
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 0b3e7af..b481344 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -744,6 +744,7 @@
preview: The title of the Preview page shown after clicking the 
\Show preview\ button in the edit page. Since this is a heading, it should 
probably be translated as a noun and not as a verb.\n\n{{Identical|Preview}},
showpreview: The text of the button to preview the page you are 
editing. See also {{msg-mw|showdiff}} and {{msg-mw|savearticle}} for the other 
buttons.\n\nSee also:\n* {{msg-mw|Showpreview}}\n*