Make the two session accessors return what they hold - #720
Merged
Conversation
getAccountColor() was declared to return a string and returned whatever setAccountColor(array) had stored — always an array — so the first read after a legitimate write would have raised a TypeError on the way out. The interface carried the same mismatch. Nothing in the application calls it, which is the only reason it went unnoticed. getTheme() had the same shape of problem from the other side: no default, so a session that had not been given a theme returned null from a method declared to return a string. Both are now what they always held: an array of colours keyed by account id, and a string that is empty before a theme is chosen. Doc: the coverage figure is now 96.6% (21648/22402), and the pcov note gains the thing that made a file look like a gap when it is at 100% — the two suites disagree about which lines are statements in nine files, so a merged report overstates them. Confirm per-file before sending anyone to fix one.
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.
The bug
Two dormant type mismatches in
Session, both found while covering it:getAccountColor(): stringreturned whateversetAccountColor(array $color)had stored — always an array. The first read after a legitimate write would have raised aTypeErroron the way out.SessionContextdeclared the same mismatch.getTheme(): stringhad no default on its read, so a session that had not been given a theme returned null from a method declared to return a string.Neither is called anywhere in
src/today, which is the only reason it went unnoticed — and exactly why it was worth fixing before somebody used one.The fix
Both now return what they always held: an array of colours keyed by account id, and a string that is empty before a theme is chosen.
Testing
A round trip for each, including what a session that has never been given either returns — which is where both used to raise.
Doc, folded in
21648/22402).Application/Account/Services/AccountSearch.phpworst, 48 vs 61). A merge that treats absent from one report as uncovered overstates them, so a per-file gap is worth confirming with a focused run before anyone is sent to fix it.