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

registerPlugin modifier unable to call with reference #980

Closed
meesha81 opened this issue Mar 31, 2024 · 7 comments
Closed

registerPlugin modifier unable to call with reference #980

meesha81 opened this issue Mar 31, 2024 · 7 comments

Comments

@meesha81
Copy link

In v4.5.1 I am not able to use php function called by reference.

php function like (use case: Every function call increase and return the number of tabindex)

function tbx(&$tabindex) {
   $tabindex++;
   return $tabindex;
}

In tpl file called like:

{$tbx = 0}
.
.
.

tbx($tbx)


Pluign registered by
$this->smarty->registerPlugin("modifier","tbx", "tbx");

But this cannot work because not passed by reference:
PHP Warning: tbx(): Argument #1 ($tabindex) must be passed by reference, value given in ...

I am not able to find how to call custom modifier with reference.

If I leave tbx unregistered, there is smarty deprecated warning, but working fine, because of calling pure php function "tbx()".

Please, is it meant that the modifier could be called a reference? Or is there another way to solve this?

@meesha81
Copy link
Author

I have found it is propably similar to
#964

@meesha81
Copy link
Author

I think this havent easy fix, but is possible to allow "force use some php function directly" ? Provide some php function whitelist for these type of issues?

@meesha81
Copy link
Author

meesha81 commented Apr 2, 2024 via email

@meesha81
Copy link
Author

meesha81 commented Apr 2, 2024

Note: Problem is not with modifier {$tbx|tbx} (I don't need modifier) but I want to call PHP function like {tbx($tbx)}
This type of function call has new deprecation warning. Calling PHP function with referenced variable can be very useful.

@Ninjinka
Copy link

Ninjinka commented Apr 2, 2024

Yes the new version broke around 30% of current project if i try to upgrade, is there a way to have direct call of php function?
With an extension maybe?

@Nightprince
Copy link

Yes the new version broke around 30% of current project if i try to upgrade, is there a way to have direct call of php function? With an extension maybe?

You cannot use these functions at this time:
#961 (comment)

@wisskid
Copy link
Contributor

wisskid commented Apr 5, 2024

@meesha81 for now, please consdier leaving your function unregistered. That will trigger a deprecation notice, but that shouldn't hurt anyone.

Closing this as this is a duplicate of #964

@wisskid wisskid closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2024
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

4 participants