[development] strange inconsistency: 'custom_url_rewrite'

Gabor Hojtsy gabor at hojtsy.hu
Tue Dec 27 16:10:52 UTC 2005


> I agree completely, Ber.  This topic came up on the dev list a few weeks ago 
> as well when discussing the limitations of path and pathauto.  The basic 
> problem is that they don't scale well, particularly for dynamic content.  
> Making /user/myname/* work for all /user/ functions, just in core, using 
> url_alias, would require at minimum 4 records per user.  (view, edit, track, 
> contact, plus some number of profile pages.)  Putting that in url_alias is 
> simply not going to scale past a few hundred users.  Try it on drupal.org 
> (45000 users and counting), and it dies horribly.
> 
> I did spend some time trying to implement it manually for the user module, 
> actually (usernames are unique, so they can be used in place of uids in URLs 
> without increasing the number of db hits), but ended up creating all sorts of 
> strange and mysterious errors I couldn't identify so I eventually abandoned 
> it.  (It also had to be all-or-nothing, or other user-extending modules 
> wouldn't work either.)  
> 
> The performance concern is real, though, given the number of links a typical 
> page has.  Some fast, well-cached module-based rewrite mechanism is needed, I 
> agree.  Perhaps just prefix-based?  I've been trying to avoid proposing 
> anything at this point, though, as any changes now would just slow down the 
> release of 4.7. :-)

Speaking of users, these are quite easy to do these in regexps. This is
an edited excerpt from the weblabor.hu aliasing code (generates
Hungarian URLs):

$userautoalias = array(
  ''                       => '',
  '/edit'                  => '/szerkesztes',
  '/track'                 => '/kovetes',
  '/track/navigation'      => '/kovetes/navigacio',
  '/contact'               => '/kapcsolat',
);

if (preg_match("!^user/(\\d+)(.*)$!", $path, $match)) {
  if (isset($userautoalias[$match[2]])) {
    return 'tagok/' . $match[1] . $userautoalias[$match[2]];
  }
}

This is all it takes to convert user/1234/track to tagok/1234/kovetes.
User names can be similarly done, given that you either query the
database for the name, or have it cached somewhere.

Goba


More information about the development mailing list