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

compileAllTemplates() has problems with block plugins #231

Closed
SlimDeluxe opened this issue May 26, 2016 · 9 comments
Closed

compileAllTemplates() has problems with block plugins #231

SlimDeluxe opened this issue May 26, 2016 · 9 comments

Comments

@SlimDeluxe
Copy link

I am using compileAllTemplates() for gettext extraction, but I just found out that it does not work with custom block functions.
While the template works perfectly as expected, the following error is returned when using compileAllTemplates()

/var/www/project/com_saop/_frontend/views/---saop/orders/dispatch_by_product.tpl
------>Error: Syntax error in template "file:/var/www/project/com_saop/_frontend/views/saop/orders/dispatch_by_product.tpl" on line 79 "{/block}" unclosed {block} tag

Line 79 is {/block}, while the whole layout is like this:

{extends tpl('1column.tpl', '_frontend')}

{block page_body}
        {datatable class='table-striped' list=$list}
            <thead>
                bla...
            </thead>
            <tbody>
                bla...
            </tbody>
            <tfoot>
                bla...
            </tfoot>
        {/datatable}
{/block}

If I remove the {block page_body} wrapper and not use an extends statement (ie. remove inheritance), it still does not work, but the error is different:

------>Error: Syntax error in template "file:/var/www/project/com_saop/_frontend/views/saop/orders/dispatched.tpl" on line 77 "{/datatable}" unexpected closing tag

Running on dev-master.

Regards

uwetews added a commit that referenced this issue May 27, 2016
…late folder (PHP >= 5.3.1) #224

      clear internal cache and expension handler for each template to avoid possible conflicts #231
@uwetews
Copy link
Contributor

uwetews commented May 27, 2016

I could reproduce your problem.
Was the block plugin 'datatable' in the plugins folder by file block.datatable.php?
What happens if you replace 'datatable' with another block plugin like 'textformat'?

I have modified compileAllTemplates() to clear all internal caches for each template to eliminate every chance of side effects from compilation of other templates.
The update is in the dev-master branch.
Any feedback is welcome.

uwetews added a commit that referenced this issue May 28, 2016
…late folder (PHP >= 5.3.1) #224

      clear internal cache and expension handler for each template to avoid possible conflicts #231
@SlimDeluxe
Copy link
Author

SlimDeluxe commented May 28, 2016

Sorry I have found out the problem was in an old plugin function.datatable I have in one of the plugin dirs (it is not a block plugin)... Before using compileAllTemplates() I use setPluginsDir() which I though removes all plugins from other packages (each package has it own plugins dir). While it does remove the directories, it does not "unload" any already loaded plugins, so this was the problem. I have renamed the function now and everything works again.

However there's a code problem with your latest commit:

A PHP Error was encountered

Severity: 4096

Message: Argument 2 passed to Smarty_Internal_Method_CompileAllTemplates::compileAllTemplates() must be an instance of Smarty, string given

Filename: sysplugins/smarty_internal_method_compilealltemplates.php

Line Number: 35

A PHP Error was encountered

Severity: 4096

Message: Argument 1 passed to Smarty_Internal_Method_CompileAllTemplates::compileAll() must be an instance of Smarty, string given, called in /var/www/dev/vendor/smarty/smarty/libs/sysplugins/smarty_internal_method_compilealltemplates.php on line 38 and defined

Filename: sysplugins/smarty_internal_method_compilealltemplates.php

Line Number: 53

( ! ) Fatal error: Call to a member function getTemplateDir() on string in /var/www/dev/vendor/smarty/smarty/libs/sysplugins/smarty_internal_method_compilealltemplates.php on line 62
Call Stack
Time Memory Function Location
1 0.0000 240304 {main}( ) .../backend.php:0
2 0.0014 289432 require_once( '/var/www/dev/_backend/core/SDLX_CodeIgniter.php' ) .../backend.php:208
3 0.1926 1435752 call_user_func_array:{/var/www/dev/_backend/core/SDLX_CodeIgniter.php:370} ( ) .../SDLX_CodeIgniter.php:370
4 0.1926 1436040 Maintainance->gettext_compile( ) .../SDLX_CodeIgniter.php:370
5 0.1929 1439736 Utilities->gettext_compile( ) .../maintainance.php:180
6 0.2143 1645808 compileAllTemplates ( ) .../Utilities.php:243
7 0.2143 1646296 Smarty_Internal_Data->__call( ) .../Utilities.php:243
8 0.2143 1646592 Smarty_Internal_Extension_Handler->_callExternalMethod( ) .../smarty_internal_data.php:241
9 0.2145 1650320 call_user_func_array:{/var/www/dev/vendor/smarty/smarty/libs/sysplugins/smarty_internal_extension_handler.php:96} ( ) .../smarty_internal_extension_handler.php:96
10 0.2145 1650872 Smarty_Internal_Method_CompileAllTemplates->compileAllTemplates( ) .../smarty_internal_extension_handler.php:96
11 0.2158 1659832 Smarty_Internal_Method_CompileAllTemplates->compileAll( ) .../smarty_internal_method_compilealltemplates.php:38

@uwetews
Copy link
Contributor

uwetews commented Jun 1, 2016

you must update to the complete dev-master version because of some other internal changes.

@uwetews uwetews closed this as completed Jun 1, 2016
@SlimDeluxe
Copy link
Author

Not sure what you mean by that, my composer.json is
"smarty/smarty": "dev-master"
so I have the latest commit. Switching to one commit before that
"smarty/smarty": "dev-master#dccfc6c2f5f519ff2db1b24de2ccb0283554b8c7"
makes it work again

@uwetews
Copy link
Contributor

uwetews commented Jun 2, 2016

If I install "smarty/smarty": "dev-master" at my place everything is okay.
Have you tried not to update but reinstall Smarty by composer?

@uwetews uwetews reopened this Jun 2, 2016
@SlimDeluxe
Copy link
Author

I don't know what's the difference, but I tried it anyway. Deleted "smarty/smarty" from composer.json. Ran "composer update" which removed the smarty folder. Then put it back as "dev-master". Ran update again and the same errors are shown.

I've taken a look at line 35 of sysplugins/smarty_internal_method_compilealltemplates.php

public function compileAllTemplates(Smarty $dummy, Smarty $smarty, $extension = '.tpl', $force_compile = false, $time_limit = 0,
                                        $max_errors = null)

If I change this to

public function compileAllTemplates(Smarty $smarty, $extension = '.tpl', $force_compile = false, $time_limit = 0,
                                        $max_errors = null)

(removed $dummy param)
it seems to be working again.

@uwetews
Copy link
Contributor

uwetews commented Jul 12, 2016

the fix is now in the master branch

@uwetews uwetews closed this as completed Jul 12, 2016
@ophian
Copy link

ophian commented Jul 13, 2016

@uwetews
What about the same in compileAllConfig(Smarty $dummy, Smarty $smarty, ...)? And they both are also noted in the PHPDoc header.

@uwetews
Copy link
Contributor

uwetews commented Jul 14, 2016

@ophian
Ian you are right
both methods are new fixed in the master branch

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

3 participants