Make path.inc swappable

Eaton - October 12, 2008 - 03:35
Project:Drupal
Version:7.x-dev
Component:base system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs work)
Description

Drupal's path aliasing system is a serious performance hotspot, and there's currently no way to change the path retrieval algorithm that it uses. Making it swappable in the same way that cache.inc is swappable would make it vastly easier to switch high-traffic sites to memcached.

Haven't had time to roll the patch yet, but I think it could resolve the long-standing dispute between "load all paths at once" and "load paths as needed" sites.

#1

kbahey - October 12, 2008 - 04:32
Status:active» patch (code needs review)

I support this direction.

For this to happen though, there should be some juggling around.

cache.inc provides only 3 functions, path.inc on the other hand has more function, which an alternate path.inc should provide.

So, these are the ones that a new path.inc would need to provide.

drupal_init_path()
drupal_lookup_path($action, $path = '', $path_language = '')
drupal_get_path_alias($path, $path_language = '')
drupal_get_normal_path($path, $path_language = '')
drupal_match_path($path, $patterns)
drupal_is_front_page()

The following functions though need to a new home, so I moved them to common.inc.

drupal_get_title()
drupal_set_title($title = NULL, $output = CHECK_PLAIN)
arg($index = NULL, $path = NULL) {

Patch attached.

AttachmentSize
320132-swappable-pathinc.patch7.02 KB

#2

kbahey - October 12, 2008 - 04:51

Actually, drupal_match_path() can be moved as is to common.inc too.

Attaching new patch.

Also, attached is a path-null.inc for testing that does not do anything other than provide the function stubs.

AttachmentSize
path-null.inc_.txt605 bytes
320132-2-swappable-path-inc.patch8.56 KB

#3

moshe weitzman - October 12, 2008 - 04:53

Moving arg() that late is gonna cause some problems, at least for custom code. I'd prefer to move that to bootstrap.inc. arg() is quite brief.

This patch is a good idea.

#4

kbahey - October 12, 2008 - 04:58

Moved arg() to bootstrap.inc.

AttachmentSize
320132-4-swappable-path-inc.patch8.67 KB

#5

kbahey - October 12, 2008 - 04:59

Who will be the first to write a path-memcache.inc when this gets in?

#6

meba - October 12, 2008 - 12:53

subscribing

#7

earnie - October 12, 2008 - 16:35
Status:patch (code needs review)» patch (code needs work)

I can see some idiots setting 'path_inc' to empty. Better check to see if the value of path_inc exists and if not use the default with a status message in admin/logs/status.

#8

kbahey - October 12, 2008 - 16:38
Status:patch (code needs work)» patch (code needs review)

It is not a bad idea, but we don't do this for cache_inc. We will have similarly missing functions and things will stop working badly if they do that..

Let us leave this for a future patch, and focus on this one for now.

#9

earnie - October 13, 2008 - 13:38

I don't think we should base the merit of your current patch based on the usability issues of a previous patch. I'll leave it up to Webchick to decide.

#10

kbahey - October 13, 2008 - 15:54

@earnie

How long does it take someone to realize that the error of their ways if they do that? A message will say function blah is missing.

This is overengineering, and extra code that will execute on every page load, yet will help with only 0.01% of the cases.

Let us have some real reviews now ...

Anyway, here is an update patch after the most recent commits.

AttachmentSize
320132-10-swappable-path-inc.patch8.3 KB

#11

chx - October 13, 2008 - 16:39
Status:patch (code needs review)» patch (code needs work)

arg() must be in path.inc because it can not be used without drupal_init_path -- if you put in bootstrap then some will surely use it from hook_boot and get back bad results. While we do not babysit broken code for sure, this is a great way to introduce bugs into everyone's code -- if you do not explicitly test your page with a path alias then it is going to break. Even core tests do not test that kind of bugs... I would much rather see most of path.inc staying put, and only drupal_lookup_path moved into something pluggable.

 
 

Drupal is a registered trademark of Dries Buytaert.