mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-02 18:54:28 -05:00
Looking for other instances of the CronTab.php fatal in the previous commit found eleven, in ten files, dating from 2019 to 2023. Each is a call to a logger function from the global namespace without the \ZM\ prefix, so each is a fatal the moment its branch runs: web/ajax/console.php, events.php, reports.php, add_monitors.php, status.php web/includes/actions/snapshot.php (two), donate.php web/includes/functions.php, session.php web/views/image.php They have survived this long because of where they sit. Every one is on an error or diagnostic path -- an invalid sort order, a zero byte download, a failed read lock -- so the call is only reached when something has already gone wrong, and then it turns a handled problem into a blank 500. That is the shape of the bug on the monitor save: the write had worked, and the thing that broke was the attempt to log. Verified before changing any of them that each file is in the global namespace, does not define the function itself and does not import it, so the call really does not resolve. Tests: tests/php/test_logger_calls_qualified.php, 16 checks. It tokenizes every php file under web/ and reports unqualified calls, with the function names read out of logger.php rather than listed, so a new one is covered the day it is added. web/api is skipped as cakephp with its own logging, and assets as third party. Php's own tokenizer rather than a regex, because the distinctions matter: a method call on an object that happens to have an Error() method is fine, as is a definition, a mention, a qualified call, the same call from inside namespace ZM, and the name appearing in a comment or a string. There is a check for each of those, since a scan that quietly matched nothing would pass the tree-wide check on its own. Verified the scan fails when the Debug() in CronTab.php is put back. Ran: tests/php/test_logger_calls_qualified.php (16 passed), the rest of tests/php and tests/js, npx eslint . (clean), utils/check-homoglyphs.py (clean). test_bandwidth_clamp.php fails on this box for an unrelated reason: it cannot read /etc/zm/conf.d/03custom.conf and the permission warning lands in its captured output. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JpiSWBmtQkR5bcgpHWY4ME
62 lines
2.2 KiB
PHP
62 lines
2.2 KiB
PHP
<?php
|
|
//
|
|
// ZoneMinder web action file
|
|
// Copyright (C) 2019 ZoneMinder LLC
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License
|
|
// as published by the Free Software Foundation; either version 2
|
|
// of the License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
//
|
|
|
|
if (!canEdit('System')) {
|
|
ZM\Warning('Need System permissions to update donation');
|
|
return;
|
|
}
|
|
|
|
if ( $action == 'donate' && isset($_REQUEST['option']) ) {
|
|
$option = $_REQUEST['option'];
|
|
$nextReminder = time();
|
|
|
|
switch ( $option ) {
|
|
case 'go' :
|
|
// Ignore this, the caller will open the page itself, use a return to shortut the view=none
|
|
$redirect = 'https://zoneminder.com/donate';
|
|
return;
|
|
case 'hour' :
|
|
$nextReminder += 60*60;
|
|
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_DONATE_REMINDER_TIME'");
|
|
break;
|
|
case 'day' :
|
|
$nextReminder += 24*60*60;
|
|
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_DONATE_REMINDER_TIME'");
|
|
break;
|
|
case 'week' :
|
|
$nextReminder += 7*24*60*60;
|
|
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_DONATE_REMINDER_TIME'");
|
|
break;
|
|
case 'month' :
|
|
$nextReminder += 30*24*60*60;
|
|
dbQuery("UPDATE Config SET Value = '".$nextReminder."' WHERE Name = 'ZM_DYN_DONATE_REMINDER_TIME'");
|
|
break;
|
|
case 'never' :
|
|
case 'already' :
|
|
dbQuery("UPDATE Config SET Value = '0' WHERE Name = 'ZM_DYN_SHOW_DONATE_REMINDER'");
|
|
break;
|
|
default :
|
|
\ZM\Warning("Unknown value for option in donate: $option");
|
|
break;
|
|
} // end switch option
|
|
$redirect = '?view='.getHomeView();
|
|
}
|
|
?>
|