Fix loan auto-approval and soft-delete catalog counts - #307
Merged
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
version.json was still 0.7.45 while this branch ships migrate_0.7.46.sql —
version_compare('0.7.46','0.7.45','<=') is FALSE, so the updater would silently
skip the auto-approve setting migration on upgrade (and the release preflight
would reject it). Bumped to 0.7.46 so the migration runs.
Adds tests/loan-auto-approval-301.unit.php: 12 behavioural checks that seed real
libri/copie/utenti/prestiti and drive the real UserActionsController::autoApprove-
LoanRequest() (which delegates to the canonical approveLoan pipeline), asserting
state transitions rather than string-matching the source:
- setting accessor: absent/'0'/non-'1' → off, '1' → on;
- OFF leaves the request in the pendente queue;
- ON + available copy → 'da_ritirare', pickup_deadline set, a copy assigned, loan activated;
- ON + no available copy → left pending, never wrongly auto-approved.
The run restores the global auto_approve_requests setting and cleans its fixtures.
The Code Quality meta-guard (issue-237-regression.unit.php) requires the release-version migration to have a matching tests/migration-<version>.unit.php. migrate_0.7.46.sql shipped without one, failing CI. Adds tests/migration-0.7.46.unit.php: runs the real migration against a sandbox system_settings table and asserts the loans/auto_approve_requests setting is created with the safe default '0', a re-run preserves an admin's '1' (does not reset it — ON DUPLICATE KEY UPDATE keeps the stored value), and no duplicate row is created.
fabiodalez-dev
added a commit
that referenced
this pull request
Jul 29, 2026
Mirrors .github/workflows/ci-quality.yml so a red Code Quality job is caught before pushing: PHPStan, composer/npm audit, translation key+placeholder parity, route-key integrity, Tailwind-JIT guard, plugin ensureSchema() rule, soft-delete guard, autoloader phpstan-free, the migration-version guard, ALL standalone tests/*.unit.php (via exit code — including the meta-guard that requires a tests/migration-<version>.unit.php for the release migration), and the setup-permissions shell test. reinstall-test.sh + verify-schema.sh only cover the E2E + schema/plugin gates, so they missed the placeholder-parity regression (v0.7.45-rc.x) and the version-skipped migration (#307). Run this before every PR push and release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request resolves the loan auto-approval request and the stale author book counts reported in #301 and #306.
Loan requests previously always entered the manual
pendentequeue. Libraries that do not need a separate availability review therefore had to approve every request before it could move to pickup. A new setting in Settings → Loans now lets administrators automatically promote immediate requests toda_ritirare. The implementation reuses the canonical approval pipeline, including eligibility, capacity, copy locking, availability recalculation, and pickup deadlines. Administrator request notifications and the patron approval email remain enabled.The Mobile API exposes
loan_approval_requiredthrough discovery and returns the resultingloan_id,auto_approvedflag, and status when creating an immediate loan. Its OpenAPI contract documents the new fields.Author list counts were derived directly from
libri_autori, so associations belonging to soft-deleted books were still included even though author detail pages correctly hid those books. Both the list and bulk export now joinlibriand requiredeleted_at IS NULL. The same audit confirmed publisher counts were already correct and found one equivalent inconsistency in genre facet counts, which is fixed here as well.The setting defaults to disabled for backward compatibility. Fresh-install seed data, an idempotent 0.7.46 migration, and all bundled translations are included.
Validation
git diff --check: passedCloses #301
Closes #306