Hoo man has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/348905 )

Change subject: Rely on ContentHandler::supportsDirectEditing being false
......................................................................

Rely on ContentHandler::supportsDirectEditing being false

Instead of hacking this ourselves using a permission hook.

I only tested this briefly, but it seems to be equivalent
to doing this per hand. This also fixes T163144.

Bug: T163144
Change-Id: Ie60bf1ac217bd3757e7b2a0aa269f856f346e096
---
M repo/Wikibase.hooks.php
M repo/Wikibase.php
2 files changed, 2 insertions(+), 38 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/05/348905/1

diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php
index 280325a..26860c2 100644
--- a/repo/Wikibase.hooks.php
+++ b/repo/Wikibase.hooks.php
@@ -546,6 +546,8 @@
                                $handler = ContentHandler::getForModelID( 
$contentModel );
 
                                if ( $handler->getEntityNamespace() === 
$namespace ) {
+                                       // XXX: This is most probably redundant 
with setting
+                                       // 
ContentHandler::supportsDirectApiEditing to false.
                                        // trying to use ApiEditPage on an 
entity namespace
                                        $params = 
$module->extractRequestParams();
 
@@ -666,43 +668,6 @@
                if ( $namespaceLookup->isEntityNamespace( 
$title->getNamespace() ) ) {
                        // Remove create and move protection for Wikibase 
namespaces
                        $types = array_diff( $types, array( 'create', 'move' ) 
);
-               }
-
-               return true;
-       }
-
-       /**
-        * Handler for the TitleQuickPermissions hook, implemented to point out 
that entity pages cannot
-        * be "created" normally.
-        *
-        * @see 
https://www.mediawiki.org/wiki/Manual:Hooks/TitleQuickPermissions
-        *
-        * @param Title $title The Title being checked
-        * @param User $user The User performing the action
-        * @param string $action The action being performed
-        * @param array[] &$errors
-        * @param bool $doExpensiveQueries Whether to do expensive DB queries
-        * @param bool $short Whether to return immediately on first error
-        *
-        * @return bool
-        */
-       public static function onTitleQuickPermissions(
-               Title $title,
-               User $user,
-               $action,
-               array &$errors,
-               $doExpensiveQueries,
-               $short
-       ) {
-               if ( $action === 'create' ) {
-                       $namespaceLookup = 
WikibaseRepo::getDefaultInstance()->getEntityNamespaceLookup();
-
-                       if ( $namespaceLookup->isEntityNamespace( 
$title->getNamespace() ) ) {
-                               // Do not allow normal creation of pages in 
Wikibase namespaces
-                               $errors[] = array( 
'wikibase-no-direct-editing', $title->getNsText() );
-
-                               return false;
-                       }
                }
 
                return true;
diff --git a/repo/Wikibase.php b/repo/Wikibase.php
index cfb8947..d239470 100644
--- a/repo/Wikibase.php
+++ b/repo/Wikibase.php
@@ -870,7 +870,6 @@
        $wgHooks['ShowSearchHit'][] = 'Wikibase\RepoHooks::onShowSearchHit';
        $wgHooks['ShowSearchHitTitle'][] = 
'Wikibase\RepoHooks::onShowSearchHitTitle';
        $wgHooks['TitleGetRestrictionTypes'][] = 
'Wikibase\RepoHooks::onTitleGetRestrictionTypes';
-       $wgHooks['TitleQuickPermissions'][] = 
'Wikibase\RepoHooks::onTitleQuickPermissions';
        $wgHooks['AbuseFilter-contentToString'][] = 
'Wikibase\RepoHooks::onAbuseFilterContentToString';
        $wgHooks['SpecialPage_reorderPages'][] = 
'Wikibase\RepoHooks::onSpecialPageReorderPages';
        $wgHooks['OutputPageParserOutput'][] = 
'Wikibase\RepoHooks::onOutputPageParserOutput';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie60bf1ac217bd3757e7b2a0aa269f856f346e096
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>

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

Reply via email to