Skip to content

Commit

Permalink
Fix passing null as $json warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Nov 15, 2023
1 parent 245dba8 commit 41a428f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions includes/Helpers/ManageWikiPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct( string $wiki ) {
'removegroups' => json_decode( $perm->perm_removegroups, true ),
'addself' => json_decode( $perm->perm_addgroupstoself, true ),
'removeself' => json_decode( $perm->perm_removegroupsfromself, true ),
'autopromote' => json_decode( $perm->perm_autopromote, true )
'autopromote' => json_decode( $perm->perm_autopromote ?? '', true )
];
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ public function commit() {
'perm_removegroups' => json_encode( $this->livePermissions[$group]['removegroups'] ),
'perm_addgroupstoself' => json_encode( $this->livePermissions[$group]['addself'] ),
'perm_removegroupsfromself' => json_encode( $this->livePermissions[$group]['removeself'] ),
'perm_autopromote' => $this->livePermissions[$group]['autopromote'] === null ? null : json_encode( $this->livePermissions[$group]['autopromote'] )
'perm_autopromote' => $this->livePermissions[$group]['autopromote'] === null ? null : json_encode( $this->livePermissions[$group]['autopromote'] ?? '' )
];

$this->dbw->upsert(
Expand Down
12 changes: 6 additions & 6 deletions includes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,16 @@ public static function onCreateWikiJsonBuilder( string $wiki, DBConnRef $dbr, ar
}
}

$permissions = array_merge( json_decode( $perm->perm_permissions, true ) ?? [], $addPerms );
$permissions = array_merge( json_decode( $perm->perm_permissions ?? '', true ) ?? [], $addPerms );
$filteredPermissions = array_diff( $permissions, $removePerms );

$jsonArray['permissions'][$perm->perm_group] = [
'permissions' => $filteredPermissions,
'addgroups' => array_merge( json_decode( $perm->perm_addgroups, true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalAddGroups' )[$perm->perm_group] ?? [] ),
'removegroups' => array_merge( json_decode( $perm->perm_removegroups, true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalRemoveGroups' )[$perm->perm_group] ?? [] ),
'addself' => array_merge( json_decode( $perm->perm_addgroupstoself, true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalAddGroupsSelf' )[$perm->perm_group] ?? [] ),
'removeself' => array_merge( json_decode( $perm->perm_removegroupsfromself, true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalRemoveGroupsSelf' )[$perm->perm_group] ?? [] ),
'autopromote' => json_decode( $perm->perm_autopromote, true )
'addgroups' => array_merge( json_decode( $perm->perm_addgroups ?? '', true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalAddGroups' )[$perm->perm_group] ?? [] ),
'removegroups' => array_merge( json_decode( $perm->perm_removegroups ?? '', true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalRemoveGroups' )[$perm->perm_group] ?? [] ),
'addself' => array_merge( json_decode( $perm->perm_addgroupstoself ?? '', true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalAddGroupsSelf' )[$perm->perm_group] ?? [] ),
'removeself' => array_merge( json_decode( $perm->perm_removegroupsfromself ?? '', true ) ?? [], self::getConfig( 'ManageWikiPermissionsAdditionalRemoveGroupsSelf' )[$perm->perm_group] ?? [] ),
'autopromote' => json_decode( $perm->perm_autopromote ?? '', true )
];
}

Expand Down

0 comments on commit 41a428f

Please sign in to comment.