Skip to content

Instantly share code, notes, and snippets.

@pa4080
Last active May 16, 2020 08:59
Show Gist options
  • Save pa4080/0e7770dfb497f6ed543c8be8110c0b66 to your computer and use it in GitHub Desktop.
Save pa4080/0e7770dfb497f6ed543c8be8110c0b66 to your computer and use it in GitHub Desktop.
Patch for MediaWiki Extension:CollapsibleVector - https://github.com/wikimedia/mediawiki-extensions-CollapsibleVector/
*** CollapsibleVectorHooks.php 2020-04-16 19:53:58.903979173 +0300
--- CollapsibleVectorHooks.patch.php 2020-04-16 19:53:17.347693246 +0300
***************
*** 46,51 ****
--- 46,56 ----
public static function isEnabled( $name ) {
global $wgCollapsibleVectorFeatures, $wgUser;
+ // Handle global false and anonymous users
+ $is_anonymosus_user = filter_var($wgUser, FILTER_VALIDATE_IP);
+ if ( $is_anonymosus_user && $wgCollapsibleVectorFeatures['customSettings']['anonymous'] === false ) {
+ return false;
+ }
// Features with global set to true are always enabled
if (
!isset( $wgCollapsibleVectorFeatures[$name] ) || $wgCollapsibleVectorFeatures[$name]['global']
@pa4080
Copy link
Author

pa4080 commented Apr 16, 2020

This patch allows to disable the CollapsibleVector feature for anonymous users by adding the following line in your LocalSettings.php:

$wgCollapsibleVectorFeatures['customSettings']['anonymous'] = false;

Unfortunately the embedded option $wgCollapsibleVectorFeatures['collapsiblenav']['global'] = false; doesn't help in this case. The logged in users are still able to enable the feature via their preferences.

Here is how to apply the patch:

cd $IP/extensions/CollapsibleVector      # $IP is the MediaWiki Document Root directory
sudo patch < <(sudo curl -s https://gist.githubusercontent.com/pa4080/0e7770dfb497f6ed543c8be8110c0b66/raw/c95cd17d6be0f0f6c9b5019742b6fb0b16742b41/CollapsibleVectorHooks.patch)

In order to revert the change before update use:

sudo patch -R < <(sudo curl -s https://gist.githubusercontent.com/pa4080/0e7770dfb497f6ed543c8be8110c0b66/raw/c95cd17d6be0f0f6c9b5019742b6fb0b16742b41/CollapsibleVectorHooks.patch)

References:

@pa4080
Copy link
Author

pa4080 commented Apr 16, 2020

Tested with MediaWiki/CollapsibleVector REL1_34.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment