ZF-2426: New Zend_View placeholders allow duplicates...



I have just recently begun to use one of the more recent snapshots so that I could start to use Zend_Layout and the new, related functionality. It's great so far, by the way.

But, I've got a problem with some of it....

I have only observed it when using one of the new "concrete placeholder implementations": HeadScript. Whenever I append a new file, it's possible that two entries are added. That really bugs me.

What I'm trying to do is to take advantage of the new features by only adding script files when and where I need them, without concern for what's already included. On the positive side, it works great in that I'm getting what I need quite simply. But, when I look at the source, I sometimes see duplicate entries. That is, one view script will need somefile.js, and so it calls ``` Now, when the request completes and I view the source, I see two references listed for somefile.js. :-|

Can one prevent this? I've poked around a bit through the few examples "out and about" as well as the snapshot docs, the source, and's ArrayObject documentation (which is a little on the light side). I wasn't able to find anything, but perhaps I've missed it.

Is it bad...? I have to admit, I don't know what it would mean to have the same file referenced more than once. Is there a need for this? Will the browser see that it's already fetched the first one and then ignore the second? Or will it go after both?

So...I would prefer to see HeadScript automatically ignore duplicates. If that's the default and there's good reason to allow duplicates sometimes, then that could be configurable. Or, the opposite: duplicates are allowed by default, but ignoring them could be configurable.

What does everyone else think about the whole thing...?

Take care...


I just looked at what I submitted and I must have inadvertently introduced some strikethrough markup. It wasn't intended, so please ignore the fact that some text has strikethrough format.

Sorry. :-|

I've edit the issue to get rid of the strikethrough markup.

Assigned to Matthew, he will have a better idea what to do with this. I personally would suggest adding an extra parameter or a new method to append unique.

This would only inject the headScript element when the filename is unique and each of the attributes matches.

I would love to have a fix for this as well, as this is sort of a blocking issue for me. I'm using ExtJS and have a method that is loading dependencies, but all these scripts are loaded for each extjs element I'm including...

If wanted, I can have a look at this issue as well.

Updating version to next minor release, as this functionality won't even be released until then.

Fix committed to trunk.

The issue is still there.

In the postDispatch function of a plugin I would write:

In this way, if I have a forward, the plugin is executed twice (or more) and I've a double (or more):

Regards, Sergio

More... the workaround will be horrible code... :)