Issues

ZF-2663: Set name in headMeta View Helper deletes previous entries

Issue Type: Bug Created: 2008-02-15T09:32:56.000+0000 Last Updated: 2008-07-25T23:56:06.000+0000 Status: Resolved Fix version(s): - 1.5.3 (28/Jul/08)

Reporter: Carlton Gibson (carlton) Assignee: Ralph Schindler (ralph) Tags: - Zend_View

Related issues: Attachments:

Description

<

pre class="highlight"> [Test Script] <?php set_include_path('../zf-trunk/library'); require_once 'Zend/Loader.php'; Zend_Loader::registerAutoload();

$view = new Zend_View;

$view->headMeta()->setName('keywords', 'php application');                     
$view->headMeta()->appendHttpEquiv('pragma', 'no-cache');
$view->headMeta()->appendHttpEquiv('Cache-control', 'no-cache');

$view->headMeta()->setName('keywords', 'xavi'); 
?>


<?php 
echo htmlentities($view->headMeta()->setPostfix("\n")); 

[Expected Output]


[Actual Output]


(Run against: r7761 & r8026)

CG wrote: I was expecting the second call to setName() to only override the 'keywords' index/property. Is this simply a misunderstanding on Xavier's and my side or this this indeed a bug?

MO'P wrote: Bug. Please file an issue in JIRA with the above reproduce/expect/actual information so either Ralph or I can look into it.

Comments

Posted by Ralph Schindler (ralph) on 2008-02-21T11:46:36.000+0000

Fixed in r8253.

Please check, if not completely fixed, then reopen.

-ralph

Posted by Wojciech Naruniec (wojciech) on 2008-06-09T14:06:06.000+0000

Use case provided by CG works after r8253 fix, but this doesn't:

<

pre class="highlight"> [Test Script] <?php set_include_path('/Users/cyphelf/Sites/ZendFramework/library'); require_once 'Zend/Loader.php'; Zend_Loader::registerAutoload();

$view = new Zend_View;

$view->headMeta()->setName('keywords', 'php application');                     
$view->headMeta()->setName('description', 'php application');
$view->headMeta()->appendHttpEquiv('pragma', 'no-cache');
$view->headMeta()->appendHttpEquiv('Cache-control', 'no-cache');

$view->headMeta()->setName('keywords', 'xavi'); 
?>


<?php 
echo $view->headMeta()->setPostfix("\n"); 
?>

[Expected Output]


[Actual Output]


(Run against: r9647)

Posted by Wojciech Naruniec (wojciech) on 2008-06-09T14:24:12.000+0000

It's a fix:

<pre class="highlight">--- Zend/View/Helper/HeadMeta.php  (revision 9498)
+++ Zend/View/Helper/HeadMeta.php   (working copy)
@@ -268,7 +268,7 @@
 
         $container = $this->getContainer();
         foreach ($container->getArrayCopy() as $index => $item) {
-            if ($item->type == $value->type) {
+            if ($item->type == $value->type && $item->name == $value->name) {
                 $this->offsetUnset($index);
             }
         }

Posted by Andrew Ballard (aballard) on 2008-06-27T07:38:03.000+0000

The fix posted by Wojciech Naruniec is close, but it only works for meta name entries.

This condition

<pre class="highlight">
if ($item->type == $value->type && $item->name == $value->name) {

should replaced with

<pre class="highlight">
if ($item->type == $value->type && $item->{$item->type) == $value->{$value->type}) {

Posted by Ralph Schindler (ralph) on 2008-07-25T23:56:05.000+0000

Fixed in trunk in r10457 Fixed in 1.5 branch in r10458 Fixed in 1.6 branch in r10459

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts