有一个 Mediawiki 配置,众所周知,每个或几乎每个请求都会引发该配置。因此,该配置的性能问题至关重要。
在此配置中,我自定义用户组的访问权限集。
有一组权限user
具有一些默认权限,并且在加载配置时它已经存在,然后我修改其权限集。
$wgGroupPermissions['user']['viewmyprivateinfo'] = true;
$wgGroupPermissions['user']['editmyprivateinfo'] = true;
$wgGroupPermissions['user']['editmyoptions'] = true;
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['user']['createpage'] = false;
$wgGroupPermissions['user']['createtalk'] = false;
$wgGroupPermissions['user']['editmyusercss'] = false;
$wgGroupPermissions['user']['editmyuserjs'] = false;
$wgGroupPermissions['user']['sendemail'] = false;
$wgGroupPermissions['user']['upload'] = false;
$wgGroupPermissions['user']['reupload-shared'] = false;
$wgGroupPermissions['user']['writeapi'] = false;
$wgGroupPermissions['user']['minoredit'] = false;
$wgGroupPermissions['user']['reupload'] = false;
$wgGroupPermissions['user']['move-rootuserpages'] = false;
$wgGroupPermissions['user']['move'] = false;
$wgGroupPermissions['user']['move-categorypages'] = false;
$wgGroupPermissions['user']['move-subpages'] = false;
$wgGroupPermissions['user']['movefile'] = false;
$wgGroupPermissions['user']['applychangetags'] = false;
$wgGroupPermissions['user']['editcontentmodel'] = false;
$wgGroupPermissions['user']['editmyuserjson'] = false;
$wgGroupPermissions['user']['editmyuserjsredirect'] = false;
$wgGroupPermissions['user']['changetags'] = false;
这正是 Mediawiki 文档建议的做法。
但后来,当我第一百次经过这列代码时,我决定可以这样重写:
$wgGroupPermissions['user'] = [
...$wgGroupPermissions['user'],
'viewmyprivateinfo' => true,
'editmyprivateinfo' => true,
'editmyoptions' => true,
'edit' => false,
'createpage' => false,
'createtalk' => false,
'editmyusercss' => false,
'editmyuserjs' => false,
'sendemail' => false,
'upload' => false,
'reupload-shared' => false,
'writeapi' => false,
'minoredit' => false,
'reupload' => false,
'move-rootuserpages' => false,
'move' => false,
'move-categorypages' => false,
'move-subpages' => false,
'movefile' => false,
'applychangetags' => false,
'editcontentmodel' => false,
'editmyuserjson' => false,
'editmyuserjsredirect' => false,
'changetags' => false,
];
从可读性的角度来看,这个选项看起来更酷。从性能的角度来看,这两个选项都可以正常工作。
问题:我是否使性能或内存方面的情况变得更糟?
PHP-FPM 8.3 + Nginx + Debian @ Docker