[drupal-devel] Cache sid
I have a test drupal 4.51 at http://localhost/bikeweb So in conf.php I have $base_url = "http://localhost/bikeweb"; In bootstrap.inc function page_set_cache() cached pages are saved at $base_url . request_uri() and Apache is reporting via function request_uri() $_SERVER['REQUEST_URI'] = '/bikeweb/' So the cached page gets set in the cache table with a cid of http://localhost/bikeweb/bikeweb/ if the cache has to be rebuilt, I then start getting assorted errors because the path is now wrong. This doesn't look right to me although it will only fail on installations that are not in the root of the url. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
On Tue, 1 Mar 2005, Julian Bond wrote:
I have a test drupal 4.51 at http://localhost/bikeweb
So in conf.php I have $base_url = "http://localhost/bikeweb";
In bootstrap.inc function page_set_cache() cached pages are saved at $base_url . request_uri()
and Apache is reporting via function request_uri() $_SERVER['REQUEST_URI'] = '/bikeweb/'
So the cached page gets set in the cache table with a cid of http://localhost/bikeweb/bikeweb/ if the cache has to be rebuilt, I then start getting assorted errors because the path is now wrong.
Is this related to this patch? http://drupal.org/node/10917 Cheers, Gerhard
Gerhard Killesreiter <killesreiter@physik.uni-freiburg.de> Tue, 1 Mar 2005 17:26:47
On Tue, 1 Mar 2005, Julian Bond wrote:
I have a test drupal 4.51 at http://localhost/bikeweb
So in conf.php I have $base_url = "http://localhost/bikeweb";
In bootstrap.inc function page_set_cache() cached pages are saved at $base_url . request_uri()
and Apache is reporting via function request_uri() $_SERVER['REQUEST_URI'] = '/bikeweb/'
So the cached page gets set in the cache table with a cid of http://localhost/bikeweb/bikeweb/ if the cache has to be rebuilt, I then start getting assorted errors because the path is now wrong.
Is this related to this patch? http://drupal.org/node/10917
Indeed it is. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
Julian Bond wrote:
I have a test drupal 4.51 at http://localhost/bikeweb
So in conf.php I have $base_url = "http://localhost/bikeweb";
In bootstrap.inc function page_set_cache() cached pages are saved at $base_url . request_uri()
and Apache is reporting via function request_uri() $_SERVER['REQUEST_URI'] = '/bikeweb/'
So the cached page gets set in the cache table with a cid of http://localhost/bikeweb/bikeweb/ if the cache has to be rebuilt, I then start getting assorted errors because the path is now wrong.
This doesn't look right to me although it will only fail on installations that are not in the root of the url.
I can reproduce this on Drupal HEAD. Both page_cache_get() and page_cache_set() use the "$base_url . request_uri()" construct. So while this isn't right, it shouldn't impact performance. What errors do you get? Maybe we should use url($_GET['q']) instead? We'd have to move url() to bootstrap.inc though. Test and patch? -- Dries Buytaert :: http://www.buytaert.net/
I can reproduce this on Drupal HEAD. Both page_cache_get() and page_cache_set() use the "$base_url . request_uri()" construct. So while this isn't right, it shouldn't impact performance.
What errors do you get?
Maybe we should use url($_GET['q']) instead? We'd have to move url() to bootstrap.inc though. Test and patch?
$GET['q'] is not the only part of the URL having some say in what is displayed, just think of paged results. Goba
Maybe we should use url($_GET['q']) instead? We'd have to move url() to bootstrap.inc though. Test and patch?
We do have a patch which moves url to bootstrap (along with drupal_goto). http://drupal.org/node/16069 Regards NK
Dries Buytaert <dries@buytaert.net> Tue, 1 Mar 2005 18:35:22
Julian Bond wrote:
I have a test drupal 4.51 at http://localhost/bikeweb So in conf.php I have $base_url = "http://localhost/bikeweb"; In bootstrap.inc function page_set_cache() cached pages are saved at $base_url . request_uri() and Apache is reporting via function request_uri() $_SERVER['REQUEST_URI'] = '/bikeweb/' So the cached page gets set in the cache table with a cid of http://localhost/bikeweb/bikeweb/ if the cache has to be rebuilt, I then start getting assorted errors because the path is now wrong. This doesn't look right to me although it will only fail on installations that are not in the root of the url.
I can reproduce this on Drupal HEAD. Both page_cache_get() and page_cache_set() use the "$base_url . request_uri()" construct. So while this isn't right, it shouldn't impact performance.
What errors do you get?
Maybe we should use url($_GET['q']) instead? We'd have to move url() to bootstrap.inc though. Test and patch?
I'm getting an error in a module I was writing/testing Call to undefined function: drupal_set_html_head() Hmmm. Maybe I shouldn't be calling functions in common.inc during the module_init hook. I was trying to add a style sheet and a javascript file to the <head> of every page using quicktags_init() as an example. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
Julian Bond <julian_bond@voidstar.com> Tue, 1 Mar 2005 18:41:15
Hmmm. Maybe I shouldn't be calling functions in common.inc during the module_init hook.
I was trying to add a style sheet and a javascript file to the <head> of every page using quicktags_init() as an example.
I think there may be a sequence problem here Index.php include_once 'includes/bootstrap.inc'; drupal_page_header(); include_once 'includes/common.inc'; If the cache is turned on drupal_page_header() calls bootstrap_invoke_all('init'); which calls module_load($module); module_invoke($module, $op); So module functions can be called before common.inc is loaded, but only if cache is turned on and it's a guest user coming in. And it seems quite possible that module writers would use functions that are only available *after* common.inc is loaded. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
Julian Bond wrote:
Julian Bond <julian_bond@voidstar.com> Tue, 1 Mar 2005 18:41:15
Hmmm. Maybe I shouldn't be calling functions in common.inc during the module_init hook.
I was trying to add a style sheet and a javascript file to the <head> of every page using quicktags_init() as an example.
I think there may be a sequence problem here
Index.php include_once 'includes/bootstrap.inc'; drupal_page_header(); include_once 'includes/common.inc';
If the cache is turned on drupal_page_header() calls bootstrap_invoke_all('init');
which calls module_load($module); module_invoke($module, $op);
So module functions can be called before common.inc is loaded, but only if cache is turned on and it's a guest user coming in.
In this case, modules are not even loaded so surely they can't be called. The fact that one could call module_invoke() does not imply that all modules are available. The current best practice for injecting content into <HEAD> tag is to use hook_menu(!$may_cache). using init is a bad idea. The developer docs state this but unfortuantely the vrsion which shows at drupaldocs.org is so old that it omits this info. I have mailed Kjartan about this.
Moshe Weitzman <weitzman@tejasa.com> Tue, 1 Mar 2005 14:23:09
Julian Bond wrote:
If the cache is turned on drupal_page_header() calls bootstrap_invoke_all('init'); which calls module_load($module); module_invoke($module, $op); So module functions can be called before common.inc is loaded, but only if cache is turned on and it's a guest user coming in.
In this case, modules are not even loaded so surely they can't be called. The fact that one could call module_invoke() does not imply that all modules are available.
Look at function bootstrap_invoke_all($op) { foreach (module_list(FALSE, TRUE) as $module) { module_load($module); module_invoke($module, $op); } } Sure looks to me like all modules get loaded in this scenario. And bootstrap_invoke_all('init') in drupal_page_header() is going to call every modules init function if it exists.
The current best practice for injecting content into <HEAD> tag is to use hook_menu(!$may_cache). using init is a bad idea.
Ah. http://drupaldocs.org/api/4.5/function/hook_init Perhaps something should be added to this to say don't use common.inc functions either. -- Julian Bond Email&MSM: julian.bond at voidstar.com Webmaster: http://www.ecademy.com/ Personal WebLog: http://www.voidstar.com/ M: +44 (0)77 5907 2173 T: +44 (0)192 0412 433 S: callto://julian.bond/
This has been bugging in my sleep of late because I keep having to go into the core modules to change things. But why doesn't module_invoke_ all or Drupal use data caching? This would allow modules to override functions by writing to the cache. When checking for the hook there could be an extra maintenance string added. this is just notes code not real or perfect. <?php function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) { $function = $module .'_'. $hook; if (function_exists(${$function.'_extended'})) { return addToCache($function_extended($a1, $a2, $a3, $a4)); } else { return addToCache($function($a1, $a2, $a3, $a4)); } } ?> Carl McDade
this is just notes code not real or perfect.
No problem, I guess with that.
<?php function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
Where do you see this code in HEAD? It's "long" gone <smirks>. In English words, you are proposing that the return value of functions that are invoked by module_invoke shall be recorded into the cache? (Still don't understand that extended part) I fail to see what good will you achive by this. Pages' cache are OK, and of the few functions that needs cache, have their own ways of cache. Regards NK
That code is from an old drupaldocs.org download. I was thinking that the call for all functions could be cached. The cache would be the usable function calls. If and when a function name contains 'extend' then it would overwrite the original. Example $function_hook is loaded to cache, if and when $function_extend_hook is found then its name would be changed to $function_hook and it would overwrite any previous version. This way if you wanted to use and extend a core or contrib function in a module it could be done without actually going in and coding the extended functionallity. http://www.onlamp.com/pub/a/php/2001/10/11/pearcache.html?page=2 The example uses a database function call but I believe any type can be used. Carl McDade Negyesi Karoly wrote:
this is just notes code not real or perfect.
No problem, I guess with that.
<?php function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
Where do you see this code in HEAD? It's "long" gone <smirks>.
In English words, you are proposing that the return value of functions that are invoked by module_invoke shall be recorded into the cache? (Still don't understand that extended part) I fail to see what good will you achive by this. Pages' cache are OK, and of the few functions that needs cache, have their own ways of cache.
Regards
NK
That example uses Pear but what I was thinking is that rather than interate through the module files and functions inaccordance with the db controls. Instead create cached copies of the overriden modules if a cached overriden copy is found then the original gets skipped over. check for cached modules to invoke invoke regular modules ( doubles can't happen because of checks already in place) if a regular module uses a overrideTocache(module/override.module) then set it to cache. When creating a module where this is needed then an override function in common.inc would be called to set the cached override in place. Of course this is extra work for module developers in having to maintain a second module but it is a lot better than nothing or having to hard code changes that don't carry with version changes. There is also the problem of the cached module not being set on first iteration. But I think that is nominal. Carl McDade Negyesi Karoly wrote:
this is just notes code not real or perfect.
No problem, I guess with that.
<?php function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
Where do you see this code in HEAD? It's "long" gone <smirks>.
In English words, you are proposing that the return value of functions that are invoked by module_invoke shall be recorded into the cache? (Still don't understand that extended part) I fail to see what good will you achive by this. Pages' cache are OK, and of the few functions that needs cache, have their own ways of cache.
Regards
NK
There is also a problem with collisions on the same module. Something I have not figured out yet. Carl Negyesi Karoly wrote:
this is just notes code not real or perfect.
No problem, I guess with that.
<?php function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
Where do you see this code in HEAD? It's "long" gone <smirks>.
In English words, you are proposing that the return value of functions that are invoked by module_invoke shall be recorded into the cache? (Still don't understand that extended part) I fail to see what good will you achive by this. Pages' cache are OK, and of the few functions that needs cache, have their own ways of cache.
Regards
NK
folks - please do not double post to the forums *and* the mailing list. it unnecessarily complicates life for researchers who search the archives for answers. further, it an inconsiderate grab for attention, IMO. replies to this 'data caching' post are welcome at http://drupal.org/node/15943#comment-30468 On Mar 2, 2005, at 6:14 AM, Carl McDade wrote:
This has been bugging in my sleep of late because I keep having to go into the core modules
to change things. But why doesn't module_invoke_ all or Drupal use data caching?
This would allow modules to override functions by writing to the cache.
When checking for the hook there could be an extra maintenance string added.
this is just notes code not real or perfect.
<?php function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) { $function = $module .'_'. $hook; if (function_exists(${$function.'_extended'})) { return addToCache($function_extended($a1, $a2, $a3, $a4)); } else { return addToCache($function($a1, $a2, $a3, $a4)); } } ?>
Carl McDade
Sorry, I posted before I realized that it was not the same topic and one that belongs in the mailing list instead. Carl Moshe Weitzman wrote:
folks - please do not double post to the forums *and* the mailing list. it unnecessarily complicates life for researchers who search the archives for answers. further, it an inconsiderate grab for attention, IMO.
replies to this 'data caching' post are welcome at http://drupal.org/node/15943#comment-30468
On Mar 2, 2005, at 6:14 AM, Carl McDade wrote:
This has been bugging in my sleep of late because I keep having to go into the core modules
to change things. But why doesn't module_invoke_ all or Drupal use
data
caching?
This would allow modules to override functions by writing to the cache.
When checking for the hook there could be an extra maintenance string added.
this is just notes code not real or perfect.
<?php function module_invoke($module, $hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL) { $function = $module .'_'. $hook; if (function_exists(${$function.'_extended'})) { return addToCache($function_extended($a1, $a2, $a3, $a4)); } else { return addToCache($function($a1, $a2, $a3, $a4)); } } ?>
Carl McDade
participants (7)
-
Carl McDade -
Dries Buytaert -
Gabor Hojtsy -
Gerhard Killesreiter -
Julian Bond -
Moshe Weitzman -
Negyesi Karoly