jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/398270 )

Change subject: Reject non-editable pages in conflict test page
......................................................................


Reject non-editable pages in conflict test page

If the content model of a page does not support direct editing (e. g. a
Structured Discussions topic page, a Wikibase item, etc.), attempting to
use it in Special:SimulateTwoColEditConflict will first expose the
internal serialized content, which the user should never need to see,
and then result in an MWException. To fix this, reject such pages.

Bug: T182668
Change-Id: I01abae3e9080a9dc51872d7975c1fc6a555edff8
---
M i18n/en.json
M i18n/qqq.json
M includes/SpecialConflictTestPage/SpecialConflictTestPage.php
M 
tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
4 files changed, 40 insertions(+), 0 deletions(-)

Approvals:
  WMDE-Fisch: Looks good to me, approved
  jenkins-bot: Verified
  Thiemo Kreuz (WMDE): Looks good to me, but someone else must approve



diff --git a/i18n/en.json b/i18n/en.json
index e32f5d4..193b83c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -48,6 +48,7 @@
        "twoColConflict-test-title-label": "Enter the title of a non-protected 
wiki page for which the edit conflict should be simulated:",
        "twoColConflict-test-title-submit": "Show edit page",
        "twoColConflict-test-title-not-existing": "There is no page with this 
title.",
+       "twoColConflict-test-no-direct-editing": "This page cannot be edited 
directly.",
        "twoColConflict-test-text-submit": "Create conflict",
        "twoColConflict-test-initial-hint": "On this page you can try out the 
new Two Column Edit Conflict interface without messing anything up.",
        "twoColConflict-test-edit-hint": "Make some changes below. They won't 
be saved. They will only be used to simulate an example edit conflict.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index abdd0c6..d85d0d1 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -53,6 +53,7 @@
        "twoColConflict-test-title-label": "Label for the conflict test page 
input box to load an article.",
        "twoColConflict-test-title-submit": "Submit button on the conflict test 
page to load an article.",
        "twoColConflict-test-title-not-existing": "Error message shown on the 
conflict test page when the submitted title does not exist.",
+       "twoColConflict-test-no-direct-editing": "Error message shown on the 
conflict test page when the submitted page's content model does not support 
direct editing (e. g. a Structured Discussions topic or a Wikibase item).",
        "twoColConflict-test-text-submit": "Submit button on the conflict test 
page to submit changes creating a test conflict.",
        "twoColConflict-test-initial-hint": "First hint shown on the conflict 
test page above the input field to load an article to experiment with.",
        "twoColConflict-test-edit-hint": "Second hint shown on the conflict 
test page above the editor to make changes.",
diff --git a/includes/SpecialConflictTestPage/SpecialConflictTestPage.php 
b/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
index fa536d7..a758e8a 100644
--- a/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
+++ b/includes/SpecialConflictTestPage/SpecialConflictTestPage.php
@@ -56,6 +56,15 @@
                }
 
                $testArticle = Article::newFromTitle( $testTitle, 
$this->getContext() );
+
+               if ( 
!$testArticle->getContentHandler()->supportsDirectEditing() ) {
+                       $this->showHintBox( ( new Message( 
'twoColConflict-test-initial-hint' ) )->parse() );
+
+                       $this->showWarningBox( new Message( 
'twoColConflict-test-no-direct-editing' ) );
+                       $this->showLoadTitle();
+                       return;
+               }
+
                if ( $request->getVal( 'mw-twocolconflict-test-text' ) === null 
) {
                        $this->showHintBox( ( new Message( 
'twoColConflict-test-edit-hint' ) )->parse() );
 
diff --git 
a/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
 
b/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
index 29f848f..e5df1c3 100644
--- 
a/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
+++ 
b/tests/phpunit/SpecialConflictTestPage/SpecialConflictTestPageIntegrationTest.php
@@ -2,6 +2,25 @@
 
 class SpecialConflictTestPageIntegrationTest extends SpecialPageTestBase {
 
+       protected function setUp() {
+               parent::setUp();
+
+               // register a namespace with non-editable content model to test 
T182668
+               $this->mergeMwGlobalArrayValue( 'wgExtraNamespaces', [
+                       12312 => 'Dummy',
+                       12313 => 'Dummy_talk',
+               ] );
+               $this->mergeMwGlobalArrayValue( 'wgNamespaceContentModels', [
+                       12312 => 'testing',
+               ] );
+               $this->mergeMwGlobalArrayValue( 'wgContentHandlers', [
+                       'testing' => 'DummyContentHandlerForTesting',
+               ] );
+               MWNamespace::clearCaches();
+               // and a page inside it
+               $this->insertPage( 'Dummy', '', 12312 );
+       }
+
        /**
         * Returns a new instance of the special page under test.
         *
@@ -32,6 +51,16 @@
                                        $this->assertWarningBox( $html, 'There 
is no page with this title.' );
                                },
                        ],
+                       'Expect warning on non-editable title' => [
+                               new FauxRequest( [
+                                       'mw-twocolconflict-test-title' => 
'Dummy:Dummy',
+                               ] ),
+                               function ( $html ) {
+                                       $this->assertFormIsPresent( $html );
+                                       $this->assertTitleInputFieldPresent( 
$html );
+                                       $this->assertWarningBox( $html, 'This 
page cannot be edited directly.' );
+                               },
+                       ],
                        'Expect editor on valid title' => [
                                new FauxRequest( [
                                        'mw-twocolconflict-test-title' => 
'TestPage',

-- 
To view, visit https://gerrit.wikimedia.org/r/398270
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I01abae3e9080a9dc51872d7975c1fc6a555edff8
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/TwoColConflict
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Andrew-WMDE <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Thiemo Kreuz (WMDE) <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: WMDE-Fisch <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to