Closed (fixed)
Project:
Vocabulary Index
Version:
5.x-2.0-rc1
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Oct 2008 at 15:05 UTC
Updated:
24 Jul 2013 at 08:40 UTC
I don't know if one is supposed to create issues for 5.x-2 yet... Please let me know.
I get "Call to undefined function drupal_get_path() in vocabindex.module on line 13"
(and a blank page) when trying to enable a block. Disabling the block the
fatal error goes away and it works nicely, although I still get the warning:
"Attempt to assign property of non-object in vocabindex.view.inc on line 240"
Comments
Comment #1
skizzo commentedI can't reproduce the problem anymore... Will keep an eye on it.
Comment #2
xanoYou may report bugs for any version. I'll look into it ASAP.
Comment #3
skizzo commentedI am seeing blank pages again, erratically (even front page).
In case it does matter, I am using also http://drupal.org/project/domain
I am not into software, but please let me know if I can help somehow.
Take your time!
Comment #4
zeezhao commentedLast time I saw this issue was with a similar module, the way I solved it was to wrap this around the function call:
if (function_exists('drupal_get_path'))
{
//body of code of the function were failure was occurring goes here ....
}
Try this out.
Comment #5
xanoI think the best way to solve this issue is to check out why drupal_get_path() is getting called and why it doesn't exist yet in that phase of execution. Wrapping it in an if(function_exists()) may cause another piece of code to break, because the if's body isn't being executed.
Comment #6
zeezhao commentedI am not saying you should blindly apply it, but thats a way to fix it...
In any case, I got the same error:
Fatal error: Call to undefined function drupal_get_path() in ......vocabindex\vocabindex.module on line 13
It tends to happen when logging out of drupal, so it looks like function not set for anonymous users or something. But in my case, access rights do exist for anonymous user.
Comment #7
xanoDrupal_get_path() is located in common.inc, which should have been included before vocabindex.module. If you are experiencing this problem again, please provide a step-by-step list of instructions on how to reproduce the problem.
Comment #8
skizzo commentedYes, I still can reproduce the problem with Build 3 Nov (datestamp = "1225714546"). I have a single Drupal installation with multiple domains site1.example.com, site2.example.com, ... Each site has its own Home Page, and its own vocab index page (embedded in panel). After clearing all caches and restarting the server, I go site hopping while monitoring the httpd log (I tried with both authenticated and anonymous user) visiting:
a) Home page site 1
b) Vocab index page site 1
a) Home page site 2
b) Vocab index page site 2
a) Home page site 3
b) Vocab index page site 3
a) Home page site 1
b) Vocab index page site 1
a) ...
b) ...
Initially everything seems ok, but after repeating the sequence a) b) few times, I enter step a) and get a blank page.
Meanwhile the call to undefined function gets logged.
Comment #9
xanoLine 13 is the first line of the following code, located directly at the beginning of the file, not containing within any other code:
This should work at all times, unless something really went wrong. Unfortunately I have no multisite setup available anytime soon, so I cannot reproduce the problem using those instructions. Since I cannot analyse the problem if I can't reproduce it I have to ask you to come up with a different approach to reproduce the error.
Comment #10
skizzo commentedI am temporarily moving this issue to the Domain Access queue,
in case any Domain Access user has already seen this error in
conjunction with Vocabulary Index module. Thank you.
Comment #11
agentrickardNothing obvious.
Project module does this drupal_get_path() trick too, and runs fine on d.o.
Could also be a Panels issue.
Comment #12
skizzo commentedit might be indeed... I have taken Panels out of the picture,
and so far I have not been able to reproduce the error
using only Domain Access and Vocabulary Index.
Moving back to original queue. Thx.
Comment #13
agentrickardThen I suspect Panels may be trying to load the module out of sequence.
Comment #14
xanoAs long as modules are being loaded normally all core's include files should have been loaded already. Since Vocabulary Index doesn't load anything outside its own 'scope' I believe a won't fix is appropriate.
It seems strange that if Panels loads an index page into a panel it loads the module out of sequence, but perhaps agentrickard is right and Panels _is_ doing something wrong. Perhaps you could create an issue there.
Comment #15
skizzo commentedI spoke too early... Panels is innocent, but the problem is definitely there.
To restrict the scope as much as possible this is what I did:
- disabled Panels and Panels Pages
- uninstalled Vocabindex
- reinstalled Vocabindex: no blocks, no pages, no configuration at all (just disabled VI caching to be on safe side).
- simply kept site hopping, from home page to home page, via DA's domain navigator
- after few attempts I got the Call to undefined function
- disabled Vocabindex
- kept site hopping for 5 minutes, no problems.
If there is something that I can do to help please give me directions
I am not a programmer but I could install dev module and use it as instructed.
If not Panels, which other module could be the suspect?
Thank you
Comment #16
xanoHmm, this is getting tricky. Could you test again using a fresh multisite setup without using other contrib modules than Vocabulary Index? Just to be sure no other modules aren't involved.
Comment #17
agentrickard@xano
Note that Domain Access (which skizzo is using) is not a normal Drupal multisite. I may have to install VocabIndex and see what is going on.
Comment #18
skizzo commentedI hope you can reproduce it right away. Installing Vocabulary Index on
your D5 Domain test environment will take really a couple of minutes.
It would take longer for Xano to setup Domain Access... but I bet that
then he would really like it, and get hooked :-). Thank you guys!
Comment #19
xanoAh, darn. Somehow I missed that bit. It would be great if you could test for this bug as well!
Comment #20
agentrickardI cannot replicate the error. But if I set the View Type to 'Browsable' I get the following:
The other two types seem to work fine. Domain Access seems to have no effect.
Comment #21
xanoI created a new issue for that bug.
Comment #22
skizzo commentedThank you agentrickard. Xano, it may have something to do with caching. I disabled caching in admin/settings/performance and went through 100 site hops without problem. Then I set caching to "Normal" and got the error at fourth hop (btw, cache lifetime in admin/build/vocabindex/settings is set to "0").
Applying zeezhao's workaround (on line 13 only) I will then see the following error
Comment #23
xanoThe error you get after applying that workaround is a logical result of requiring a file from the wrong location, since the file's directory isn't available anymore.
Comment #24
skizzo commentedI don't know enough to fully understand the following comment, but could that be related to my problem? Excerpt from http://drupal.org/node/45190 (Drupal 4.7) : 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.
Comment #25
agentrickardConfirmed. It is a problem with caching, and Project would have the same issue.
What happens (and why it seems unpredictable) is that the first time a page is requested by an anon user, the entire code generates the cached page. On subsequent views, the page is pulled from cache and drupal_get_path is not loaded.
The proper D5 code, I believe is to move the load statement into hook_menu() !$may_cache.
See http://api.drupal.org/api/function/hook_init/5, which describes this issue.
A better fix would be to load those files only on paths where they are needed, if possible.
Comment #26
xanoSince the Drupal 5 menu system does not allow include files for menu callbacks I decided to require all files at the beginning of vocabindex.module. I could have chosen to require them only where necessary, but I didn't for the simple reason that it would make the code more complicated, especially because I am maintaining three branches at the same time.
Skizzo, agentrickard: Thanks a lot! It seems like you have found the problem and a possible solution. I'll try this fix in a couple of minutes.
Comment #27
skizzo commentedI upgraded to rc1 (datestamp = "1225885825") , re-enabled caching, and it looked ok
earlier today, but now I am seeing again instances where the problem occurs...
Comment #28
agentrickardXano-
I've done that trick before by routing all my D5 menu items through a handler function, which takes an argument that indicates the function to load, then loads the includes in the handler function, but that is probably more effort than its worth.
Comment #29
xano@Skizzo: The new RC releases are from yesterday morning, when agentrickard hadn't suggested a fix yet. I was busy with updating some strings and the Dutch translation, which took more time than expected. That's why the fix still hasn't been committed.
@Agentrickard: It's probably not worth it, but I'd still like to see your solution; it sounds very interesting.
Comment #30
agentrickardI found an example in the D5 version of Domain Access.
See:
http://therickards.com/api/function/domain_menu/Domain
http://therickards.com/api/function/domain_admin/Domain
In general, menu calls to the domain_admin function include a callback argument that indicates which function to fire. The conditional file loading happens inside domain_admin.
Comment #31
xanoI like it :) It might be worth implementing this after all to reduce the amount of parsed code.
Comment #32
agentrickardIt is basically a straight port of the D6 menu file include system, using D5 APIs.
Comment #33
xanoI have been able to reproduce and fix the problem. The code to load the include files has been moved to hook_menu().
Thanks, skizzo and agentrickard!
Fixed and committed to 5.x-2.x-dev.
Comment #35
xano