LSaddon::accesslog: Fix PHP < 7.3 compatibility

This commit is contained in:
Benjamin Renard 2022-07-20 14:53:28 +02:00
parent c0d8f9f81a
commit 75258d9744

View file

@ -54,7 +54,7 @@ function LSaddon_accesslog_support() {
'getEntryAccessLog',
'cli_getEntryAccessLog',
'Get entry access log',
'[entry DN] [page]',
'[entry DN] [page]'
);
}
return true;
@ -118,7 +118,7 @@ function getEntryAccessLog($dn) {
'reqMod',
'reqOld',
),
),
)
);
if (!is_array($data)) {
return;
@ -151,7 +151,7 @@ function getEntryAccessLogPage($dn, $page = false, $nbByPage = 30) {
'logs' => array_slice(
$_SESSION['entryAccessLogPages'][$dn],
$page > 1 ? (($page - 1) * $nbByPage) - 1 : 0,
$nbByPage,
$nbByPage
)
);
}
@ -193,6 +193,6 @@ function cli_getEntryAccessLog($command_args) {
$page = isset($command_args[1]) ? intval($command_args[1]) : 1;
echo json_encode(
getEntryAccessLogPage($dn, $page),
JSON_PRETTY_PRINT,
JSON_PRETTY_PRINT
);
}