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

BC break with protected $Template property #4086

Closed
bytehead opened this issue Feb 8, 2022 · 19 comments · Fixed by #4231
Closed

BC break with protected $Template property #4086

bytehead opened this issue Feb 8, 2022 · 19 comments · Fixed by #4231
Labels
Milestone

Comments

@bytehead
Copy link
Member

bytehead commented Feb 8, 2022

Affected version(s)

4.9.26

Description

The fix from #4075 has still a BC break in PageRegular:

Bildschirmfoto 2022-02-08 um 14 14 25

@bytehead bytehead added the bug label Feb 8, 2022
@bytehead bytehead added this to the 4.9 milestone Feb 8, 2022
@fritzmg
Copy link
Contributor

fritzmg commented Feb 8, 2022

Yes, we still need to decide whether accessing ->Template of PageRegular publicly should be allowed or not. In the past it was allowed, but probably an oversight. However, even if it was not intentional, the current state is inconsistent. Module and ContentElement allow you to publicly access the Template property. PageRegular and BackendMain do not.

@m-vo
Copy link
Member

m-vo commented Feb 8, 2022

Can we allow it in 4.13 and ultimately drop it everywhere in 5.0?

@bytehead
Copy link
Member Author

bytehead commented Feb 8, 2022

Before 4.9.24 you could actually access Template in PageRegular therefore we cannot change this in 4.x IMO.

@bytehead
Copy link
Member Author

bytehead commented Feb 8, 2022

Or how would you add some properties to the page template?

@fritzmg
Copy link
Contributor

fritzmg commented Feb 8, 2022

Or how would you add some properties to the page template?

I would do it via the parseTemplate hook.

@ausi
Copy link
Member

ausi commented Feb 8, 2022

Can we make it a public member in Contao 4.9/4.13 and private in Contao 5.0?

@leofeyer
Copy link
Member

leofeyer commented Feb 8, 2022

Huh? I don‘t understand. I have merged the original fix, so why is this breaking now?

@bytehead
Copy link
Member Author

bytehead commented Feb 8, 2022

Then this was also a BC break then.

@bytehead
Copy link
Member Author

bytehead commented Feb 8, 2022

Can we make it a public member in Contao 4.9/4.13 and private in Contao 5.0?

Like discussed already: #3894 (comment) 😅

@leofeyer leofeyer added the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label Feb 8, 2022
@aschempp
Copy link
Member

aschempp commented Feb 9, 2022

jup, it must be public. Or probably just not be set at all. I noticed that too while reading the PR 😂

@bytehead
Copy link
Member Author

bytehead commented Feb 9, 2022

I'm in for making it public, I doubt that people made the property protected or private by themself. But otherwise, why not leave it as it was and don't set it at all until 5.0? 🤷‍♂️

@leofeyer
Copy link
Member

leofeyer commented Feb 9, 2022

Creating dynamic properties is deprecated as of PHP 8.2, which is why this issue came up in the first place.

https://github.com/contao/contao/runs/4498623325?check_suite_focus=true

@bytehead
Copy link
Member Author

bytehead commented Feb 9, 2022

True, I've already missed that again. So making it public would be the only (futureproof) way.

@aschempp
Copy link
Member

aschempp commented Feb 9, 2022

How about adding a __get() method that return the template object? This would work in any case. If a developer did make it public in a child class that property would be accessed, and in any other case our __get() method would be called?

@fritzmg
Copy link
Contributor

fritzmg commented Feb 9, 2022

You mean: leave everything as it was before (i.e. reverting #4075 again 🙈) and only implement __get for Template for PageRegular? (May be also BackendMain)

@fritzmg
Copy link
Contributor

fritzmg commented Feb 9, 2022

There is another issue. We cannot revert #4075 because there are actually extensions who directly access $this->arrData['Template']: https://github.com/DERHAEUPTLING/contao-lazy-images/blob/9edd71b3e8d632ad2ad66329c519a8b3a9e0686a/elements/LazyContentImage.php#L26

@m-vo
Copy link
Member

m-vo commented Feb 9, 2022

Creating dynamic properties is deprecated as of PHP 8.2, which is why this issue came up in the first place.

If we cannot guarantee BC otherwise, we could add #[AllowDynamicProperties] in this special case I think.

@leofeyer
Copy link
Member

As discussed in the Contao call, we do want to add #[AllowDynamicProperties].

@leofeyer leofeyer removed the up for discussion Issues and PRs which will be discussed in our monthly Mumble calls. label Feb 10, 2022
@ausi
Copy link
Member

ausi commented Feb 10, 2022

And use a protected property in Contao 5.0 and remove #[AllowDynamicProperties] then.

@leofeyer leofeyer closed this as completed Mar 3, 2022
leofeyer added a commit that referenced this issue Mar 3, 2022
…4231)

Description
-----------

Fixes #4086

Commits
-------

c5790cd Remove the $Template property from the PageRegular class again
eefb46f Add a back slash to the PHP attribute
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants