Skip to content

Commit 4ef0e61

Browse files
caseysoftwareclaude
andcommitted
isWorkingDay(): ignore the Holiday add-on when its files are missing
isWorkingDay() did an unguarded require_once of modules/holiday/holiday_functions.class.php whenever the holiday module row was active. If the add-on's folder was removed or never deployed (a server move, deleting the folder instead of uninstalling), that was a fatal error, and task scheduling and every calendar view stopped loading. Treat the add-on as present only when it is active, the file exists, and it defines HolidayFunctions::isHoliday(). The check is still made once per request. The add-on (web2project/modules-holiday, master) still ships holiday/holiday_functions.class.php with a static HolidayFunctions::isHoliday($date, $userid = 0). Checked from the CLI with an active holiday row: without the folder the old code is fatal and the new one falls back to the working-day setting; with a stub add-on, its holiday is non-working. Fixes #452. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01K315UgUazvx8qspudiHKjg
1 parent 5591b79 commit 4ef0e61

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎classes/w2p/Utilities/Date.class.php‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,23 @@ public function isWorkingDay() {
165165
/** @var w2p_Core_CAppUI $AppUI */
166166
global $AppUI;
167167

168-
// isActiveModule() runs a query; calendars call this once per cell, so look it up once per request
168+
// Calendars call this once per cell, so decide once per request
169+
// whether the Holiday add-on can be used. It counts only when it is
170+
// active *and* its files are there: a module row left active after
171+
// the folder was removed must not make every calendar fatal.
169172
static $holidayModuleActive = null;
170173
if (is_null($holidayModuleActive)) {
171-
$holidayModuleActive = (bool) $AppUI->isActiveModule('holiday');
174+
$holidayModuleActive = false;
175+
$holidayFile = W2P_BASE_DIR . '/modules/holiday/holiday_functions.class.php';
176+
if ($AppUI->isActiveModule('holiday') && is_file($holidayFile)) {
177+
require_once $holidayFile;
178+
$holidayModuleActive = class_exists('HolidayFunctions', false)
179+
&& method_exists('HolidayFunctions', 'isHoliday');
180+
}
172181
}
173182

174-
if ($holidayModuleActive) {
175-
// Holiday module, check the holiday database
176-
require_once W2P_BASE_DIR."/modules/holiday/holiday_functions.class.php";
177-
if(HolidayFunctions::isHoliday($this)) {
178-
return false;
179-
}
183+
if ($holidayModuleActive && HolidayFunctions::isHoliday($this)) {
184+
return false;
180185
}
181186

182187
$working_days = w2PgetConfig('cal_working_days');

0 commit comments

Comments
 (0)