Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible template regression #10911

Closed
kinglozzer opened this issue Aug 9, 2023 · 1 comment
Closed

Possible template regression #10911

kinglozzer opened this issue Aug 9, 2023 · 1 comment

Comments

@kinglozzer
Copy link
Member

kinglozzer commented Aug 9, 2023

PR: #10912

Affected Version

5.0.15

Description

This used to work in SS4:

<!-- 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

if ($on !== null && (isset($on->$property) || method_exists($on, $property ?? ''))) {

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)

kinglozzer added a commit to kinglozzer/sapphire that referenced this issue Aug 9, 2023
GuySartorelli added a commit that referenced this issue Aug 9, 2023
FIX: Regression with include argument (fixes #10911)
@GuySartorelli
Copy link
Member

GuySartorelli commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants