fix(db): remove an impossible lastInsertId fallback and a duplicate getter - #3236
Merged
rubenvdlinde merged 1 commit intoAug 31, 2026
Conversation
…etter
Two more entries the Psalm baseline was carrying. Both are real. 184 -> 180.
PollLinkService had a fallback that could never run:
$pollId = (int)$this->db->lastInsertId("oc_polls_polls_id_seq");
if ($pollId === 0) {
// Fallback for drivers without sequence support.
$pollId = (int)$this->db->lastInsertId();
}
OCP\IDBConnection::lastInsertId(string $table): int takes a REQUIRED
argument, so the no-arg call raises ArgumentCountError on exactly the
drivers the fallback was written for. The surrounding catch (Throwable)
turned that into "Failed to create poll", which blames the insert rather
than the id retrieval. A zero now falls through to the explicit throw that
was already there and says what actually happened.
Checked the other four lastInsertId call sites. MagicMapper and
DedupCollidedSchemasCommand pass a table. DbalObjectSourceProvider calls it
with no argument, but on a DBAL Connection rather than IDBConnection, where
the parameter is optional. Psalm flagged only the one that was wrong.
CaseToken declared getToken TWICE:
@method string|null getToken()
@method void getToken(?string $token) <- copy-paste of the setter
@method void setToken(?string $token)
Psalm binds to the second, which is why two correct $row->getToken() calls
read as "Too few arguments". Removed; setToken on the next line was already
right. Swept lib/Db for the same slip: this was the only one of them.
Verified with the repo own vendor/bin/psalm 5.26.1 on PHP 8.3: all four
TooFewArguments are gone, errors with the baseline emptied went 184 -> 180,
regenerated baseline is green. PHPUnit was NOT run here, it needs the
Nextcloud server bootstrap that only exists inside a server checkout.
Contributor
Quality Report — ConductionNL/openregister @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-specs | ✅ | ||||
| test-l10n | ✅ | ||||
| test-l10n-parity | ✅ | ||||
| format | ✅ | ||||
| check-schema-l10n | ✅ | ||||
| check-l10n-js | ✅ | ||||
| composer | ✅ | ✅ 174/174 | |||
| npm | ✅ | ✅ 543/543 | |||
| app:check-code | ⏭️ | ||||
| info.xml | ✅ | ||||
| REUSE | ❌ | ||||
| PHPUnit | ✅ | ||||
| Newman | ✅ | ||||
| Playwright | ⏭️ deferred — runs on the promotion into beta/main, not on a pull request into development | ||||
| Hydra gates | ✅ |
Quality workflow — 2026-08-31 17:11 UTC
Download the full PDF report from the workflow artifacts.
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.
Two more baseline entries that turned out to be real defects. 184 -> 180.
A fallback that could never run
OCP\IDBConnection::lastInsertId(string $table): inttakes a required argument. The no-arg call raisesArgumentCountErroron precisely the drivers the fallback existed for, and the surroundingcatch (Throwable)reported it asFailed to create poll— blaming the insert rather than the id retrieval. A zero now falls through to the explicit throw that was already there.I checked the other four
lastInsertIdcall sites:MagicMapperandDedupCollidedSchemasCommandpass a table;DbalObjectSourceProvidercalls it with no argument but on a DBALConnection, where the parameter is optional. Psalm flagged only the one that was wrong.A getter declared twice
Psalm binds to the second declaration, which is why two perfectly correct
$row->getToken()calls read as Too few arguments. Removed;setTokenon the next line was already correct. I swept all oflib/Dbfor the same slip and this was the only instance.Verification
vendor/bin/psalm5.26.1 on PHP 8.3: all fourTooFewArgumentsgone, errors with the baseline emptied went 184 -> 180, regenerated baseline green.PHPUnit not run locally (needs the server bootstrap). No constructor signatures changed here, so there is no positional-argument shift to check this time.