- 4 tasks: failing test, helper implementation, vaultLoop switch, smoke check
- New helper fetchLiveVaultBalance(string $user): ?int in includes/utilities.php
- vaultLoop prefers the live value, falls back to MAX(running_balance)
- Per-request cache to avoid N HTTP calls
- Test hook via $GLOBALS['liveBalanceTestHook'] for unit testing
- Falls back gracefully on API failure
Per the spec's error-handling section, all exceptions must be caught at
the top of index.php's bootstrap path so a single bad page (CurlError,
JsonData, ApiValidation, ApiKeyMissing, LogEntryIncomplete) does not take
down the whole UI. The page now renders whatever data is in the DB plus
a warning banner with the exception message (htmlspecialchars-escaped to
avoid XSS). On the first-run backfill path, the redirect is still
emitted inside the try block so the success path is unchanged.
Per the spec's error-handling table, entries missing timestamp or
details.title should be skipped (logged via consoleLog) and the loop
should continue processing the rest. Previously the function threw
LogEntryIncompleteException and aborted the entire batch, which would
take down the whole UI when a single malformed entry was returned.
These helpers were no longer called after the v2 migration rewrote
processLogEntries and fetchAndStoreLogPage (the latter now prepares its
own idempotent INSERT inline). Rendered unused by the v2 migration.
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.
- Compares old (api-sample.json) and new (api-sample-new.json) shapes
- Specifies Authorization: ApiKey header instead of ?key= query param
- Specifies following _metadata.links.next for pagination
- Specifies entry.id (string) as PRIMARY KEY with INSERT ... ON CONFLICT DO NOTHING
- Adds backfillUserLogs (replaces firstRun) and syncUserLogs (renamed from getLog)
- Adds shared fetchAndStoreLogPage helper
- Adds golden-file unit test (no live API)
- Updated .gitignore to exclude new directories and files.
- Enhanced config.php with detailed PHPDoc comments for better clarity.
- Refactored functions.php to include PHPDoc comments and improve code readability.
- Added custom exceptions in exceptions.php with detailed documentation.
- Improved utilities.php with better documentation and error handling.
- Updated index.php with structured comments and improved readability.
- Refined style.css for better visual consistency.
- Introduced phpcs.xml for coding style checks and standards enforcement.
- Updated README.md with detailed project description, features, and installation instructions.
- Refactored functions.php to include configuration settings and improved database handling.
- Modified index.php for better user experience and added pagination controls.
- Introduced new utility functions for API handling and database interactions.
- Added CSS styles for improved layout and visibility of elements.
- Removed vault.csv as data is now managed through the database.
- Implemented FTP deployment workflow for automated deployment.
- Added exception handling classes for better error management.
- Created JavaScript functions for pagination of transaction records.