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

Error: Call to undefined method Smarty\Smarty::setErrorUnassigned() #979

Open
Chrissyx opened this issue Mar 30, 2024 · 3 comments
Open

Comments

@Chrissyx
Copy link

While upgrading to Smarty 5 I encountered this fatal error by calling this:
$this->smarty->setErrorUnassigned(true);

Not a big deal, the property is still there and I can set it directly like this:
$this->smarty->error_unassigned = true;

However the upgrade docs do not mention this. So I'm wondering are the getter/setter removed intentionally and the docs are missing some API method changes? Or should setErrorUnassigned() still work?

@wisskid
Copy link
Contributor

wisskid commented Apr 3, 2024

Wow, after inspecting the code, I was going to say that setErrorUnassigned does not exist in Smarty 4 either. But even though it is not defined, calling $this->smarty->setErrorUnassigned(true); indeed actually works. It seems to be routed through \Smarty_Internal_Extension_Handler::_callExternalMethod() which magically allows you to get/set Smarty properties.

I cannot find any reference of setErrorUnassigned in the documentation or anywhere else on the internet, so it seems you guessed this one by accident? I'm wondering what to do about this. Adding a getter/setter seems the easiest fix. And documenting it. But there might be more magic getters/setters to consider.

@wisskid
Copy link
Contributor

wisskid commented Apr 3, 2024

Also, there is overlap with $smarty->muteUndefinedOrNullWarnings()

@Chrissyx
Copy link
Author

Chrissyx commented Apr 3, 2024

I'm using this setter since Smarty 3.0 RC4. It always worked.
If this is no longer intended, I can migrate to set the property directly. It would be just nice to have a hint in the docs about the removed magic setters/getters in general.

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

No branches or pull requests

2 participants