Skip to content

Commit

Permalink
ensure all json_decodes output arrays not stdClass
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnFLewis committed Sep 17, 2018
1 parent 8a3e871 commit 682b667
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions includes/ManageWiki.php
Expand Up @@ -80,7 +80,7 @@ public static function groupPermissions( $group ) {
[ 'perm_permissions', 'perm_addgroups', 'perm_removegroups' ],
[ 'perm_dbname' => $wgDBname, 'perm_group' => $group ]
);

$perms = [];

if ( !$res ) {
Expand All @@ -90,9 +90,9 @@ public static function groupPermissions( $group ) {
'removegroups' => []
];
} else {
$perms['permissions'] = json_decode( $res->perm_permissions );
$perms['addgroups'] = json_decode( $res->perm_addgroups );
$perms['removegroups'] = json_decode( $res->perm_removegroups );
$perms['permissions'] = json_decode( $res->perm_permissions, true );
$perms['addgroups'] = json_decode( $res->perm_addgroups, true );
$perms['removegroups'] = json_decode( $res->perm_removegroups, true );
}

return (array)$perms;
Expand Down Expand Up @@ -131,9 +131,9 @@ public static function defaultGroupPermissions( $group ) {

$perms = [];

$perms['permissions'] = json_decode( $res->perm_permissions );
$perms['addgroups'] = json_decode( $res->perm_addgroups );
$perms['removegroups'] = json_decode( $res->perm_removegroups );
$perms['permissions'] = json_decode( $res->perm_permissions, true );
$perms['addgroups'] = json_decode( $res->perm_addgroups, true );
$perms['removegroups'] = json_decode( $res->perm_removegroups, true );

return (array)$perms;
}
Expand Down
10 changes: 5 additions & 5 deletions includes/ManageWikiHooks.php
Expand Up @@ -62,19 +62,19 @@ public static function onSetupAfterCache() {
);

foreach ( $res as $row ) {
$permsJson = json_decode( $row->perm_permissions );
$permsJson = json_decode( $row->perm_permissions, true );
foreach ( (array)$permsJson as $perm ) {
$wgGroupPermissions[$row->perm_group][$perm] = true;
}

$wgAddGroups[$row->perm_group] = json_decode( $row->perm_addgroups );
$wgAddGroups[$row->perm_group] = json_decode( $row->perm_addgroups, true );

$wgRemoveGroups[$row->perm_group] = json_decode( $row->perm_removegroups );
$wgRemoveGroups[$row->perm_group] = json_decode( $row->perm_removegroups, true );

$cacheArray[$row->perm_group] = [
'permissions' => $permsJson,
'addgroups' => json_decode( $row->perm_addgroups ),
'removegroups' => json_decode( $row->perm_removegroups )
'addgroups' => json_decode( $row->perm_addgroups, true ),
'removegroups' => json_decode( $row->perm_removegroups, true )
];
}

Expand Down

0 comments on commit 682b667

Please sign in to comment.