Development

#3078 (UrlHelper::link_to_unless() generates undefined property "tag" in links)

You must first sign up to be able to contribute.

Ticket #3078 (closed defect: fixed)

Opened 10 months ago

Last modified 10 months ago

UrlHelper::link_to_unless() generates undefined property "tag" in links

Reported by: garak Assigned to: FabianLange
Priority: minor Milestone: 1.0.12
Component: helpers Version: 1.0.10
Keywords: Cc:
Qualification: Unreviewed

Description

As described in UrlHelper::link_to_unless() comment, you can use an option "tag", used to enclose the name when condition is true. But when condition is false, the option is not discarded, resulting in a non-existing property "tag" for link, something like <a href="/module/action" tag="strong">name</a>

Change History

03/10/08 16:34:42 changed by FabianLange

  • owner changed from fabien to FabianLange.
  • status changed from new to assigned.

03/10/08 16:37:50 changed by FabianLange

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

(In [7794]) fixes #3078

03/10/08 16:38:09 changed by FabianLange

  • qualification changed from Unreviewed to Accepted.
  • milestone set to 1.0.12.

03/11/08 09:29:50 changed by epaulin

  • qualification changed from Accepted to Unreviewed.

This change breaks my app.

[11-Mar-2008 16:10:37] PHP Fatal error: Cannot unset string offsets in /home/josh/www/jeebo/vendor/symfony/lib/helper/UrlHelper.php on line 167

PHP Version 5.2.5 OS: Ubuntu 7.10

03/11/08 09:50:05 changed by FabianLange

thats for testing this so fast. I did not see this on my machine, but seems some php versions need an isset check here. done in r7802

03/11/08 10:19:17 changed by dwhittle

Can you apply this to 1.1 as well?

03/11/08 10:42:38 changed by FabianLange

in r7803 its done on 1.1 trunk as well

03/11/08 10:47:07 changed by epaulin

you kidding!

This doesn't help at all! cause you need to parse options first!!!

Here is the patch:

Index: vendor/symfony/lib/helper/UrlHelper.php
===================================================================
--- vendor/symfony/lib/helper/UrlHelper.php     (版本 7803)
+++ vendor/symfony/lib/helper/UrlHelper.php     (工作副本)
@@ -162,17 +162,14 @@
  */
 function link_to_if($condition, $name = '', $internal_uri = '', $options = array())
 {
+  $html_options = _parse_attributes($options);
   if ($condition)
   {
-    if (isset($options['tag']))
-    {
-      unset($options['tag']);
-    }
-    return link_to($name, $internal_uri, $options);
+    unset($html_options['tag']);
+    return link_to($name, $internal_uri, $html_options);
   }
   else
   {
-    $html_options = _parse_attributes($options);
 
     unset($html_options['query_string']);
     unset($html_options['absolute_url']);

03/11/08 11:10:58 changed by FabianLange

spare your exclamation marks, you might need them later. I added a unit test that now also catches the tag=div short notation. in r7804 and r7805

03/11/08 12:44:14 changed by epaulin

I was over-reaction to this, sorry. Please accept my apology.