ezsystems/ezpublish-legacy — pull request #900 by thiagocamposviana (2014-03-07 18:34:56+00:00)
Title: Do not cache ezscript_load and ezcss_load call

Caching ezscript_load and ezcss_load in pagelayout will cause problems in modules that uses ezscript_require and ezcss_require. I have tested a case where we were using ezscript_require in the left menu. The first we load the page the tag is generated at the correct place, but after some cache files expires and we call again ezscript_require it won't generate the tag because it will pass the files to be generated in the ezscript_load call.

Please check the ezscript_load definition:

Works like ezscript(), except that the optional $script parameter is prepended to the list of script files already saved with ezscript_require() before they are packed and the script tag is generated.

Now the ezscript_require definition:

Like ezscript(), but stores script files to be loaded using the persistent_variable.js_files template variable* instead of generating the script tag unless ezscript_load() is already called.

So, when developing ez publish admin interface extension we can't use ezscript_require because it will fail later because ez publish will cache the ezscript_load call, making ezscript_require think ezpublish_load hasn't been called.

Also it isn't necessary to cache page_head_style.tpl page_head_script.tpl because it doesn't contain any code that should be cache anyways. I do understand caching page_header because sometimes it will call tons of mysql queries, but that isn't the case for page_head_style.tpl and page_head_script.tpl.