You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Calling the include --><% include Features Services=0 %><!-- Inside Features.ss --><% if $Services.Count %><ul><% loop $Services %><li>{$Title}</li><% end_loop %></ul><% end_if %>
Now it results in:
Uncaught TypeError: method_exists(): Argument #1 ($object_or_class) must be of type object|string, int given
Passing false when calling the include results in the same error (just with bool instead of int in the error message), passing null works fine because of the above check.
Calling .Count is unnecessary, but I’m inclined to fix this because it is a minor regression and the error message is really confusing.
More info
In SS4 $on was a DBText instance with a value of string '0', in SS5 $on is an integer 0, so this is most likely a regression from the type changes in #10497.
I think the simplest fix here is to add an additional check to the line above for && is_object($on)
The text was updated successfully, but these errors were encountered:
kinglozzer
added a commit
to kinglozzer/sapphire
that referenced
this issue
Aug 9, 2023
Agreed that's a regression. I've merged the PR - it'll be automatically tagged once CI finishes running on the branch. Thank you for reporting and fixing this.
PR: #10912
Affected Version
5.0.15
Description
This used to work in SS4:
Now it results in:
silverstripe-framework/src/View/SSViewer_DataPresenter.php
Line 380 in 0e74e35
Passing
false
when calling the include results in the same error (just withbool
instead ofint
in the error message), passingnull
works fine because of the above check.Calling
.Count
is unnecessary, but I’m inclined to fix this because it is a minor regression and the error message is really confusing.More info
In SS4
$on
was aDBText
instance with a value of string'0'
, in SS5$on
is an integer0
, so this is most likely a regression from the type changes in #10497.I think the simplest fix here is to add an additional check to the line above for
&& is_object($on)
The text was updated successfully, but these errors were encountered: