power-media / prado3

Automatically exported from code.google.com/p/prado3
Other
0 stars 0 forks source link

Deferred script rendering does not work well with output caching #410

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The changes introduced in r3159 do not work properly under all circumstances, 
and in some cases, when output caching, might lead to the same script files 
being loaded multiple times (which is a problem, because all variables defined 
in those script files will be reset and all functions called or objects created 
upon loading of the script will be executed/created multiple times).

What steps will reproduce the problem?
1. Run the testcase
2. When prompted about the need to have the page reloaded agree
3. Observe the bugcheck message

What is the expected output? What do you see instead?
The page generated in the 2nd run of the testcase (ie. when the content inside 
the TOutputCache has already been cached) should be the same as the one 
generated in the 1st run cycle (when the content has not been cached yet), so 
the control script "controlscript.js" should be loaded only once in the page. 
That, however, is not what happens, and "controlscript.js" will be loaded twice 
in the page if the content inside the TOutputCache control can be and gets 
retrieved from the application cache.

What version of the product are you using? On what operating system?
Prado/trunk

Please provide any additional information below.
This happens because the current clientscript manager implementation does not 
keep track of what scripts might have been registered inside the cached block, 
and thus might duplicate any script registrations that have happened (been 
emitted) inside cached content blocks.

I've attached a fix for the issue which corrects this behaviour by ensuring 
that all scripts loaded inside a cached content block will be marked as already 
loaded in the clientscript manager if said block is retrieved an emitted from 
the cache.

Original issue reported on code.google.com by google...@pcforum.hu on 22 Jun 2012 at 10:50

Attachments:

GoogleCodeExporter commented 8 years ago
I've attached an updated version of TClientScriptManager.php. The modifications 
incorporated in this newer version are not directly related to the issue 
explained in this ticket, and I'm including the file here only for the sake of 
simplicity and so it won't get overlooked.

The new version has seem some now unneeded and redundant code removed from 
TClientScriptManager::getScriptUrls(). The package expansion code there is now 
superflous, because since r3159 Prado package member scripts are already 
registered together with regular scripts in the $_scriptFiles array.

Original comment by google...@pcforum.hu on 24 Jun 2012 at 3:28

Attachments:

GoogleCodeExporter commented 8 years ago
committed as r3167, thank you

Original comment by ctrlal...@gmail.com on 25 Jun 2012 at 9:25

GoogleCodeExporter commented 8 years ago

Original comment by ctrlal...@gmail.com on 25 Jun 2012 at 1:38