From: florianschmidtwelzow Date: Sun, 27 Jul 2014 12:18:26 +0000 (+0200) Subject: Fix getAutosummary for create blank page X-Git-Tag: 1.31.0-rc.0~14731 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=8012165a229180a16490ee6e4992b8f8817e8137;p=lhc%2Fweb%2Fwiklou.git Fix getAutosummary for create blank page Fixes for change to enable the creation of blank pages. Added test for this case. Follow up: I3457c36a909d1dbfaeed04a1f0568c69e0ef3386 Bug: 57238 Change-Id: Id52be6cbe22c6098d1c0824d7a7848579aa05a84 --- diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 1d7a7a7a9e..c8a9f1e352 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -822,8 +822,8 @@ abstract class ContentHandler { } // New blank article auto-summary - if ( $flags && EDIT_NEW && $newContent->getSize() == 0 ) { - return wfMessage( 'autosumm-newblank' ) ->inContentLanguage()->text(); + if ( $flags & EDIT_NEW && $newContent->isEmpty() ) { + return wfMessage( 'autosumm-newblank' )->inContentLanguage()->text(); } // If we reach this point, there's no applicable auto-summary for our diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php index 2add9f23b6..b564a29b7a 100644 --- a/tests/phpunit/includes/content/ContentHandlerTest.php +++ b/tests/phpunit/includes/content/ContentHandlerTest.php @@ -312,6 +312,23 @@ class ContentHandlerTest extends MediaWikiTestCase { } } + /* + * Test if we become a "Created blank page" summary from getAutoSummary if no Content added to + * page. + */ + public function testGetAutosummary() { + $content = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT ); + $title = Title::newFromText( 'Help:Test' ); + // Create a new content object with no content + $newContent = ContentHandler::makeContent( '', $title, null, null, CONTENT_MODEL_WIKITEXT ); + // first check, if we become a blank page created summary with the right bitmask + $autoSummary = $content->getAutosummary( null, $newContent, 97 ); + $this->assertEquals( $autoSummary, 'Created blank page' ); + // now check, what we become with another bitmask + $autoSummary = $content->getAutosummary( null, $newContent, 92 ); + $this->assertEquals( $autoSummary, '' ); + } + /* public function testSupportsSections() { $this->markTestIncomplete( "not yet implemented" );