Restore consoleLog helper and remove test stub masking production fatal
The v2 rewrite of processLogEntries() calls consoleLog(...) at two
skip branches (no id, and no deposited/withdrawn). Commit 3ebc5e2 had
removed the project helper from includes/utilities.php, leaving a
production runtime fatal ("Call to undefined function consoleLog()")
the first time a non-vault entry flowed through fetchAndStoreLogPage
-> processLogEntries in real use.
The previous test appeared to pass only because it defined a local
no-op consoleLog stub via function_exists() guard — masking the defect
behind a test fixture that never reached either skip branch.
Fix:
- Restore the original consoleLog() helper to
includes/utilities.php (unchanged from the pre-3ebc5e2 codebase;
spec lists it as unchanged).
- Remove the local consoleLog stub from
tests/process_log_entries_test.php so the test now exercises
the real production code path.
This commit is contained in:
@@ -287,3 +287,16 @@ function fetchAndStoreLogPage($pdo, $user, $url) {
|
||||
|
||||
return $responseData['_metadata']['links']['next'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a variable to the console for debugging purposes.
|
||||
*
|
||||
* @param mixed $data The data to print to the console.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function consoleLog( $data ) {
|
||||
echo '<script>';
|
||||
echo 'console.log(' . json_encode($data) . ')';
|
||||
echo '</script>';
|
||||
}
|
||||
|
||||
@@ -22,15 +22,6 @@ if (!defined('USER_KEYS')) {
|
||||
]);
|
||||
}
|
||||
|
||||
// consoleLog was removed from includes/utilities.php (commit 3ebc5e2), but the
|
||||
// rewritten processLogEntries() still calls it for skipped entries. Define a
|
||||
// local no-op here so the test does not trigger a fatal error.
|
||||
if (!function_exists('consoleLog')) {
|
||||
function consoleLog(string $message): void {
|
||||
// Intentionally silent — these are "skip" notices during the test.
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../includes/exceptions.php';
|
||||
require_once __DIR__ . '/../includes/utilities.php';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user