Development

Changeset 10593

You must first sign up to be able to contribute.

Changeset 10593

Show
Ignore:
Timestamp:
08/01/08 18:02:18 (4 months ago)
Author:
fabien
Message:

[1.2] fixed variable replacing in URL happens in wrong order (refs #4058)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/lib/routing/sfPatternRouting.class.php

    r10200 r10593  
    559559    // replace variables 
    560560    $realUrl = $url; 
    561     foreach ($variables as $variable => $value) 
     561 
     562    $tmp = $variables; 
     563    uasort($tmp, create_function('$a, $b', 'return strlen($a) < strlen($b);')); 
     564    foreach ($tmp as $variable => $value) 
    562565    { 
    563566      $realUrl = str_replace($value, urlencode($tparams[$variable]), $realUrl); 
  • branches/1.2/lib/widget/sfWidget.class.php

    r9046 r10593  
    276276    } 
    277277 
    278     return sprintf('<%s%s%s', $tag, $this->attributesToHtml($attributes), self::$xhtml ? ' />' : sprintf('></%s>', $tag)); 
     278    return sprintf('<%s%s%s', $tag, $this->attributesToHtml($attributes), self::$xhtml ? ' />' : ('input' != $tag ? sprintf('></%s>', $tag) : '>')); 
    279279  } 
    280280 
  • branches/1.2/test/unit/routing/sfPatternRoutingTest.php

    r8806 r10593  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(135, new lime_output_color()); 
     13$t = new lime_test(136, new lime_output_color()); 
    1414 
    1515class sfPatternRoutingTest extends sfPatternRouting 
     
    537537$params = array('module' => 'default', 'action' => 'action', 'param1' => 'param1'); 
    538538$t->is($r->parse($url), $params, 'parse /customer/:param1/:action/* route'); 
     539 
     540$r->clearRoutes(); 
     541$r->connect('test', '/customer/:id/:id_name', array('module' => 'default')); 
     542$t->is($r->generate('', array('id' => 2, 'id_name' => 'fabien')), '/customer/2/fabien', '->generate() first replaces the longest variable names');