Add supportsDirectEditing methods to ContentHandler
authoraude <aude.wiki@gmail.com>
Wed, 15 Apr 2015 08:26:22 +0000 (10:26 +0200)
committerAude <aude.wiki@gmail.com>
Fri, 17 Apr 2015 15:55:20 +0000 (15:55 +0000)
commit2513086ec16150431cc9a62aaf6f09711f838c46
tree97b754464326f9c2e826ba08e75a8984d49ad393
parent055068d8f00943c7801283399b40ae9c32ccd292
Add supportsDirectEditing methods to ContentHandler

This adds supportsDirectApiEditing and
supportsDirectEditing methods to ContentHandler. Both
return false by default for the ContentHandler base
class, and true for TextContentHandler and it's
derivatives. (everything in core)

Extension content types that directly extend
AbstractContent / ContentHandler, often / generally don't
support direct editing. EntityContent in Wikibase
and Flow boards are the two such content types currently
in gerrit-hosted extensions.

The use and direct settings of the allowNonTextContent
member variable is replaced by enableApiEditOverride and
a setter for that. The only place allowNonTextContent is
used in all of Wikimedia-hosted git repos is core itself
(EditPage and ApiEditPage), so should be safe to make
this change.

With this change, Wikibase can remove its ApiCheckCanExecute
hook handler that disallows editing there, and MobileFrontend
could check if direct editing is allowed before enabling it's
editing features, instead of Wikibase having to add
MobileFrontend hook handlers to disable the features.

Bug: T96382
Change-Id: I276cd6ecedf38108f1f2be16b38e699e8c5d2d0c
15 files changed:
RELEASE-NOTES-1.26
includes/EditPage.php
includes/api/ApiEditPage.php
includes/content/ContentHandler.php
includes/content/TextContentHandler.php
tests/TestsAutoLoader.php
tests/phpunit/includes/EditPageTest.php
tests/phpunit/includes/api/ApiEditPageTest.php
tests/phpunit/includes/content/ContentHandlerTest.php
tests/phpunit/includes/content/TextContentHandlerTest.php [new file with mode: 0644]
tests/phpunit/includes/content/WikitextContentHandlerTest.php
tests/phpunit/mocks/content/DummyContentForTesting.php [new file with mode: 0644]
tests/phpunit/mocks/content/DummyContentHandlerForTesting.php [new file with mode: 0644]
tests/phpunit/mocks/content/DummyNonTextContent.php [new file with mode: 0644]
tests/phpunit/mocks/content/DummyNonTextContentHandler.php [new file with mode: 0644]