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

Problem with custom function "URL" #131

Closed
GAngZta85 opened this issue Dec 15, 2015 · 10 comments
Closed

Problem with custom function "URL" #131

GAngZta85 opened this issue Dec 15, 2015 · 10 comments

Comments

@GAngZta85
Copy link

Since 3.1.28 the smarty autoloader tries to load the class Smarty_Internal_Compile_URL.
This will not work because URL is a custom function.

In 3.1.27 it is all ok.

My custom function (plugins/function.URL.php):

function smarty_function_URL($params, $template) {
        $sPath = ifsetter($params['path'], '');
        return MSE()->Language()->getUrl(['sPath' => $sPath]);
}

Template example: {URL path=$i1}

@uwetews
Copy link
Contributor

uwetews commented Dec 16, 2015

On all tags Smarty does check if a class Smarty_Internal_Compile_{tag} does exist. If not it looks for a plugin in the plugin folder. This is how all Smarty 3.1 versions work. Nothing has changed there.

Your example does work at my place.
So what kind of error do you see?

Do you have other autoloader in your application?
A problem we have seen sometimes in the past is that false was returned if the class is not found.
This is wrong implementation. An autoloader must always return without a value.

@GAngZta85
Copy link
Author

Thanks for your reply.
Actual we use our system autoloader and the smarty autoloader. The system autoloader returns nothing "return;"
In both autoloader I insert an echo to see what class name was passed as parameter. In the output I can see both autoloader are called. At first the smarty autoloader then from the system.
The last class is called "Smarty_Internal_Compile_URL". Then I get a empty page. All neccessary plugins are available

@uwetews
Copy link
Contributor

uwetews commented Dec 16, 2015

Calling the autoloader for "Smarty_Internal_Compile_URL" is correct because the compiler does call the class_exists() method for it. That can't be the problem. It must be something else. Do you get compiled templates? Check the PHP error_log if something is reported there.

@uwetews
Copy link
Contributor

uwetews commented Jan 29, 2016

As there is no further reply this issue gets closed.

@uwetews uwetews closed this as completed Jan 29, 2016
@ovidiugabriel
Copy link

I think the compiler shall not check if class Smarty_Internal_Compile_URL exists if url is registered as plugin. Suddenly my URL plugin is not working anymore. Please reopen this issue.

@uwetews uwetews reopened this Feb 23, 2016
@uwetews
Copy link
Contributor

uwetews commented Feb 23, 2016

The compiler always checks if an internal compile class does exists. if this is not the cases it checks registered plugins.

Note that plugin tag names are case sensitive. If you use {URL} it must registered as 'URL'.

It does work at my place.

@ovidiugabriel
Copy link

I am using {url}, not {URL}. The plugin is registered as follows:

$_smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'url',  'smarty_function_url');

I will be back with a backtrace if the problem is still persistent.

@ovidiugabriel
Copy link

You say: "The compiler always checks if an internal compile class does exists. if this is not the cases it checks registered plugins." / It should not be the other way around: "The compiler always checks checks registered plugins, if this is not the cases, checks if an internal compile class does exists?".

Because if I do not have the class, Smarty will throw exception and become unusable.

@uwetews
Copy link
Contributor

uwetews commented Mar 2, 2016

Not sure if it could be related to #199

@wisskid
Copy link
Contributor

wisskid commented Jan 27, 2020

This seems fixed.

@wisskid wisskid closed this as completed Jan 27, 2020
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