Greetings,
I just installed a fresh copy of 4.7beta3 along with the category.module. I followed instructions as to enabling category module and then overwriting taxonomy.module with the wrapper version from category. I am using PHP5-MySQL5 on IIS6 and Windows 2003.
Problem exists when I logout as admin and try to load the index page. I get the following error:
Fatal error: Call to undefined function drupal_get_path() in D:\Inetpub\wwwsol\modules\category\category.module on line 35
The line in category.module is ...
/**
* Implementation of hook_init().
*/
function category_init() {
include drupal_get_path('module', 'category') . '/category.inc';
}
When I uninstalled category.module my site loaded again. But when I reinstalled, including database etc. the error message came up again. But now I can't get to my login page but I can view certain pages like -- http://www.omain.com/index.php?q=admin/logs and http://www.omain.com/index.php?q=admin/settings -- but this is inconsistent if I reload the page it brings up the error message again.
Thanks for the read and support.
Lsabug
Comments
Comment #1
Jaza commentedProblem confirmed, but the problem only occurs when a site has page caching enabled. When Drupal serves cached pages, it only loads a small subset of its code base (called the 'bootstrap' code), and this code does not include the drupal_get_path() function (which is in common.inc, not bootstrap.inc). hook_init() is the only module hook that gets called during bootstrap, so it's the only hook where developers need to avoid using non-bootstrap functions.
I've moved the drupal_get_path() call to hook_menu(), and committed this change to HEAD. From a bit of testing, this seems to have fixed the problem. But I'm still not sure that I've done it 100% right. For example, I didn't put the call inside the "if (!$may_cache)" condition, because the function is needed on all pages. If anyone has any better suggestions, please post them here.
Thanks.
Comment #2
Jaza commentedFixed. Call now put inside the !$may_cache area of hook_menu.
Comment #3
scott_dft commentedSorry Jaza, I've had to re-open this one.
I'm getting a call to category_load (and on other occassions category_nodeapi) before category_menu so it requires category.inc for the functions in it. Re-instating category_init fixes everything (don't have page caching).
Not got really the time or expertise to give all the specifics, or figure a fix on how to get it working for cached pages..., but I can confirm that it is not guarenteed that category_menu is always called first ...
Scott
Comment #4
Jaza commentedYou're going to have to give me more details, Scott. How can I reproduce this problem? I have been unable to see any problems in loading category.inc, whether I have caching turned on or off.
Also, AFAIK, hook_menu() is guaranteed to always be called before any other hook, except hook_init() and hook_exit(). I can't see how hook_load() or hook_nodeapi() could possibly get invoked if hook_menu() has not been invoked first.
Comment #5
mgiffordI think this is a related problem:
http://drupal.org/node/46061
Comment #6
scott_dft commentedFound it!
As I mentioned, I've got a pretty clean version of Drupal with only a couple of contribs, but that included the one that threw the wobbly: acidfree.
On its menu call, which happens before category's, it calls acidfree_get_node_by_id() which modifies the menu depending on some info on the node called. To retrieve the info it calls hook_load...
Not knowing the rules of 'Drupal Contributions' I don't know if this behaviour is illegal or not, but clearly this is a weak area. Obviously it is safer to expect any function to be called at any point and cover by using the init call, but then there is the caching issue...
Comment #7
Jaza commentedShould be fixed now. I've moved the including of category.inc back to hook_init(), but it now depends only on bootstrap functions.
Comment #8
(not verified) commented