Ticket #1622 (closed defect: fixed)

Opened 2 months ago

Last modified 1 month ago

makeJsOptimizerLink() adds files more than onces if under global and current

Reported by: biggs Assigned to: lakiboy
Priority: normal Milestone: 0.6.5
Component: SGL - Output Severity: need feedback
Keywords: addJavascriptFile multiple javascript calls Cc:

Description

I have JavaScript? files, which can be included on global level in config, or on manager level. To be sure the manager has the files included, they get added in manager method by $oOutput->addJavascriptFile() even so they may be in global array already.

Unfortunately the current makeJsOptimizerLink() function does not take this into account and just merges the files. This is wrong! The current javascript files should be added by addJavascriptFile() function as well cause there is an in_array() check.

        //$this->aJavascriptFiles = array_merge($this->aJavascriptFiles, $aCurrentFiles);
        $this->addJavascriptFile($aCurrentFiles);

Thanks! Phil

Attachments

Output_addJavascriptFile_r3835.diff (1.1 kB) - added by tecodan on 06/12/08 19:45:55.

Change History

06/12/08 19:45:55 changed by tecodan

  • attachment Output_addJavascriptFile_r3835.diff added.

06/12/08 19:47:13 changed by tecodan

  • keywords set to addJavascriptFile multiple javascript calls.
  • owner changed from somebody to demian.
  • severity changed from open to need feedback.

I have experienced a similar problem where the same javascript file is loaded multiple times if the Output->addJavascriptFile() is called with the same JS file more than once, regardless of the in_array() checks.

I've concluded that the issue is with the inconsistency of the in_array() check. The check is called prior to the appending of the WEB_ROOT prefix. ie. in the array we may have something like http://example.com/js/foo.js while its trying to compare it against js/foo.js.

I've attached a patch I've used to solve this issue. It could probably be optimised.

06/15/08 14:18:25 changed by demian

  • status changed from new to assigned.
  • milestone set to 0.6.5.

06/17/08 14:33:36 changed by demian

  • owner changed from demian to lakiboy.
  • status changed from assigned to new.

06/24/08 10:38:11 changed by lakiboy

  • status changed from new to closed.
  • resolution set to fixed.

I totally agree both of you. Fixed in [3880]