MarkAHershberger has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/404776 )
Change subject: Merge branch 'master' of https://gerrit.wikimedia.org/r/mediawiki/extensions/Lockdown ...................................................................... Merge branch 'master' of https://gerrit.wikimedia.org/r/mediawiki/extensions/Lockdown Change-Id: I70ae71f1d4d48f7ba5ce9771049a82fd31783a1a --- M .phpcs.xml D Lockdown.php M composer.json 3 files changed, 0 insertions(+), 250 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lockdown refs/changes/76/404776/1 diff --git a/.phpcs.xml b/.phpcs.xml index 92fad25..b915cf8 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -1,30 +1,7 @@ <?xml version="1.0"?> <ruleset> -<<<<<<< HEAD (d2e5d5 Use phpcs from composer) - <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> - <exclude name="Generic.Arrays.DisallowLongArraySyntax.Found"/> - <exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed"/> - <exclude name="Generic.Files.LineLength.TooLong"/> - <exclude name="Generic.PHP.NoSilencedErrors.Discouraged"/> - <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic"/> - <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamComment"/> - <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag"/> - <exclude name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch"/> - <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle"/> - <exclude name="MediaWiki.ControlStructures.IfElseStructure.SpaceBeforeElse"/> - <exclude name="MediaWiki.NamingConventions.PrefixedGlobalFunctions.wfPrefix"/> - <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.SingleSpaceBeforeSingleLineComment"/> - <exclude name="MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceAfterOpenParenthesis"/> - <exclude name="MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis"/> - <exclude name="MediaWiki.WhiteSpace.SpaceyParenthesis.SpaceBeforeOpeningParenthesis"/> - </rule> - <file>.</file> - <arg name="extensions" value="php"/> - <arg name="encoding" value="UTF-8"/> -======= <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki" /> <file>.</file> <arg name="extensions" value="php"/> <arg name="encoding" value="UTF-8"/> ->>>>>>> BRANCH (4d3629 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0) </ruleset> diff --git a/Lockdown.php b/Lockdown.php deleted file mode 100644 index d57dd60..0000000 --- a/Lockdown.php +++ /dev/null @@ -1,223 +0,0 @@ -<<<<<<< HEAD (d2e5d5 Use phpcs from composer) -<?php - -/** - * Lockdown extension - implements restrictions on individual namespaces and special pages. - * - * @file - * @ingroup Extensions - * @author Daniel Kinzler, brightbyte.de - * @copyright © 2007 Daniel Kinzler - * @license GNU General Public Licence 2.0 or later - */ - -/* -* WARNING: you can use this extension to deny read access to some namespaces. Keep in mind that this -* may be circumvented in several ways. This extension doesn't try to -* plug such holes. Also note that pages that are not readable will still be shown in listings, -* such as the search page, categories, etc. -* -* Known ways to access "hidden" pages: -* - transcluding as template. can be avoided using $wgNonincludableNamespaces. -* Some search messages may reveal the page existance by producing links to it (MediaWiki:searchsubtitle, -* MediaWiki:noexactmatch, MediaWiki:searchmenu-exists, MediaWiki:searchmenu-new...). -* - supplying oldid=<revisionfromhiddenpage> may work in some versions of mediawiki. Same with diff, etc. -* -* NOTE: you cannot GRANT access to things forbidden by $wgGroupPermissions. You can only DENY access -* granted there. -*/ - -if ( !defined( 'MEDIAWIKI' ) ) { - echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); - die( 1 ); -} - -$wgExtensionCredits['other'][] = array( - 'path' => __FILE__, - 'name' => 'Lockdown', - 'author' => array( - 'Daniel Kinzler', - 'Platonides', - '...' - ), - 'url' => 'https://mediawiki.org/wiki/Extension:Lockdown', - 'descriptionmsg' => 'lockdown-desc', - 'license-name' => 'GPL-2.0+' -); - -$wgMessagesDirs['Lockdown'] = __DIR__ . '/i18n'; - -$wgNamespacePermissionLockdown = array(); -$wgSpecialPageLockdown = array(); -$wgActionLockdown = array(); - -$wgHooks['getUserPermissionsErrors'][] = 'lockdownUserPermissionsErrors'; -$wgHooks['MediaWikiPerformAction'][] = 'lockdownMediawikiPerformAction'; -$wgHooks['SearchableNamespaces'][] = 'lockdownSearchableNamespaces'; -$wgHooks['SearchGetNearMatchComplete'][] = 'lockdownSearchGetNearMatchComplete'; - -/** - * @param Title $title - * @param User $user - * @param string $action - * @param MessageSpecifier|array|string|bool|null $result - * @return bool - */ -function lockdownUserPermissionsErrors( - Title $title, - User $user, - $action, - &$result = null -) { - global $wgNamespacePermissionLockdown, $wgSpecialPageLockdown, $wgWhitelistRead, $wgLang; - - $result = null; - - // don't impose extra restrictions on UI pages - if ( $title->isCssJsSubpage() ) { - return true; - } - - if ( $action == 'read' && is_array( $wgWhitelistRead ) ) { - // don't impose read restrictions on whitelisted pages - if ( in_array( $title->getPrefixedText(), $wgWhitelistRead ) ) { - return true; - } - } - - $groups = null; - $ns = $title->getNamespace(); - if ( NS_SPECIAL == $ns ) { - foreach ( $wgSpecialPageLockdown as $page => $g ) { - if ( !$title->isSpecial( $page ) ) continue; - $groups = $g; - break; - } - } - else { - $groups = @$wgNamespacePermissionLockdown[$ns][$action]; - if ( $groups === null ) { - $groups = @$wgNamespacePermissionLockdown['*'][$action]; - } - if ( $groups === null ) { - $groups = @$wgNamespacePermissionLockdown[$ns]['*']; - } - } - - if ( $groups === null ) { - #no restrictions - return true; - } - - if ( !$groups ) { - #no groups allowed - - $result = array( - 'badaccess-group0' - ); - - return false; - } - - $ugroups = $user->getEffectiveGroups(); - - $match = array_intersect( $ugroups, $groups ); - - if ( $match ) { - # group is allowed - keep processing - $result = null; - return true; - } else { - # group is denied - abort - $groupLinks = array_map( array( 'User', 'makeGroupLinkWiki' ), $groups ); - - $result = array( - 'badaccess-groups', - $wgLang->commaList( $groupLinks ), - count( $groups ) - ); - - return false; - } -} - -function lockdownMediawikiPerformAction ( - OutputPage $output, - Article $article, - Title $title, - User $user, - WebRequest $request, - MediaWiki $wiki -) { - global $wgActionLockdown, $wgLang; - - $action = $wiki->getAction(); - - if ( !isset( $wgActionLockdown[$action] ) ) { - return true; - } - - $groups = $wgActionLockdown[$action]; - if ( $groups === null ) { - return true; - } - if ( !$groups ) { - return false; - } - - $ugroups = $user->getEffectiveGroups(); - $match = array_intersect( $ugroups, $groups ); - - if ( $match ) { - return true; - } else { - $groupLinks = array_map( array( 'User', 'makeGroupLinkWiki' ), $groups ); - - $err = array( 'badaccess-groups', $wgLang->commaList( $groupLinks ), count( $groups ) ); - throw new PermissionsError( $request->getVal('action'), array( $err ) ); - } -} - -function lockdownSearchableNamespaces( array &$searchableNs ) { - $user = RequestContext::getMain()->getUser(); - $ugroups = $user->getEffectiveGroups(); - - foreach ( $searchableNs as $ns => $name ) { - if ( !lockdownNamespace( $ns, $ugroups ) ) { - unset( $searchableNs[$ns] ); - } - } - return true; -} - -function lockdownNamespace( $ns, array $ugroups ) { - global $wgNamespacePermissionLockdown; - - $groups = @$wgNamespacePermissionLockdown[$ns]['read']; - if ( $groups === null ) { - $groups = @$wgNamespacePermissionLockdown['*']['read']; - } - if ( $groups === null ) { - $groups = @$wgNamespacePermissionLockdown[$ns]['*']; - } - - if ( $groups && !array_intersect($ugroups, $groups) ) { - return false; - } - - return true; -} - -#Stop a Go search for a hidden title to send you to the login required page. Will show a no such page message instead. -function lockdownSearchGetNearMatchComplete( $searchterm, Title &$title = null ) { - global $wgUser; - - if ( $title ) { - $ugroups = $wgUser->getEffectiveGroups(); - if ( !lockdownNamespace( $title->getNamespace(), $ugroups ) ) { - $title = null; - } - } -} -======= ->>>>>>> BRANCH (4d3629 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0) diff --git a/composer.json b/composer.json index 9ce9df6..c54f128 100644 --- a/composer.json +++ b/composer.json @@ -3,11 +3,7 @@ "jakub-onderka/php-parallel-lint": "0.9.2", "jakub-onderka/php-console-highlighter": "0.3.2", "mediawiki/minus-x": "0.2.1", -<<<<<<< HEAD (d2e5d5 Use phpcs from composer) - "mediawiki/mediawiki-codesniffer": "14.1.0" -======= "mediawiki/mediawiki-codesniffer": "15.0.0" ->>>>>>> BRANCH (4d3629 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0) }, "scripts": { "test": [ -- To view, visit https://gerrit.wikimedia.org/r/404776 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I70ae71f1d4d48f7ba5ce9771049a82fd31783a1a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Lockdown Gerrit-Branch: master Gerrit-Owner: MarkAHershberger <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
