fix: fatal error when using an undefined combo parameter name#34
Open
peterschade wants to merge 2 commits into
Open
fix: fatal error when using an undefined combo parameter name#34peterschade wants to merge 2 commits into
peterschade wants to merge 2 commits into
Conversation
meth_Misc_ApplyPrmCombo is a static method but called $this->meth_Misc_Alert() in its error branch, causing a fatal "Using $this when not in object context" in PHP 8 whenever a template referenced an unknown combo name. Fix: add an optional $TBS parameter and pass $this from the instance call site (line 1436). The registration-time call site (line 4260, $Loc=false) stays without $TBS, so missing combos at registration time are silently skipped — correct behaviour since combos can be registered in any order. Adds PrmComboTestCase with two unit tests that reproduce the bug and verify the fix.
Owner
|
Thanks, very well documented and the idea of the optional argument is good. |
TBS resolves field names via VarRef/$GLOBALS, not the local scope of a class method. Replace the local $msg assignment with VarRef so the tag [onshow.msg;...] is actually resolved during Show(). Also remove an unused $this->newInstance assignment from the second test.
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.
Problem
meth_Misc_ApplyPrmCombois declaredstaticbut its error branch calls$this->meth_Misc_Alert(). In PHP 8 this causes a fatal error whenever a template references an undefined combo name:Minimal reproduction:
Fix
Add an optional
$TBS = nullparameter tometh_Misc_ApplyPrmComboand pass$thisfrom the merge-time call site (meth_Locator_FindTbs). The registration-time call site (f_Misc_UpdateArray, always called with$Loc=false) stays without$TBS, so missing combos at combo-definition time are silently skipped — correct behaviour since combos can be registered in any order.Changes
tbs_class.php: 3-line fix inmeth_Misc_ApplyPrmCombotestunit/testcase/PrmComboTestCase.php: new unit test case with two teststestKnownCombo— verifies a registered combo's parameters are appliedtestUnknownComboRaisesTbsError— reproduces the bug; passes only after the fixtestunit/index.php: registers the new test case