When Drupal's performance page caching setting is enabled, the following error appears.

Fatal error: Call to undefined function drupal_get_path_alias() in /home/kylehase/public_html/modules/contrib/clickpath/clickpath.module on line 152

Error appears even when drupal's error reporting is set to "write errors to the log". This message does not appear when logged in as user 1.

Drupal v6 RC3

Comments

zilla’s picture

strange - is anybody seeing this on d6.1?

zilla’s picture

still seeing this myself

thomas23@drupal.org’s picture

confirm. Observed when in maintenance mode but not when logged in as user of admin group (all permissions enabled but differend to user/1!) -- nothing else tested.

thomas23@drupal.org’s picture

work-around for the time beeing: don't display when visitor not logged in:

.not-logged-in  #block-clickpath-0
{
  display: none;
}

Maybe this has to do with caching the block or similar? Because I also noticed that
a) this error doesn't occure always
b) block in FF and Opera only refreshes if Strg+R pressed not by normal link navigation

Caching used here is normal (not agressive) but disabled for blocks.

Edit: Silly me, just not displaying the item, of course, wouldn't omit the error message... *dogh* So, this is not a work-around.

coltrane’s picture

Observed when page cache is normal, anonymous user, not in maintenance mode. Also got Fatal error: Call to undefined function t() in /var/www/test/sites/all/modules/contrib/clickpath/clickpath.module on line 167 a couple times.

clickpath.module saves the path on hook_exit()

From http://api.drupal.org/api/function/hook_exit/6:

If you implement this hook and see an error like 'Call to undefined function', it is likely that you are depending on the presence of a module which has not been loaded yet. It is not loaded because Drupal is still in bootstrap mode.

Before this the documentation says:

Only use this hook if your code must run even for cached page views. If you have code which must run once on all non cached pages, use hook_init instead. Thats the usual case.

So, how about not saving the path on cached pages? Only save the path for authenticated users?

coltrane’s picture

#234790: seeing an error in was marked a duplicate of this

coltrane’s picture

Status: Active » Needs review
StatusFileSize
new703 bytes

Using hook_init() instead of hook_exit() is a fix but then the path is saved early and available in the SESSION for when the block is built. This means when you visit a page it is listed at the top of the recently visited pages which might not be acceptable.

Applies against DRUPAL-6--1 clickpath.module rev 1.1.2.1.2.2

coltrane’s picture

Priority: Normal » Critical
Status: Needs review » Needs work

A huge downside of switching to hook_init() is the page title is saved before things like drupal_set_title() run. An example is taxonomy pages are listed in the module's block as "Taxonomy term" rather than the term name.

coltrane’s picture

Status: Needs work » Needs review
StatusFileSize
new669 bytes

Here's another approach, it only calls clickpath_save_path() when the user is authenticated.

vacilando’s picture

Subscribing (possibly see also related/duplicate #329002: undefined function t() -- fatal error).

coltrane’s picture

Status: Needs review » Fixed

patch from #9 has been committed, expect a release soon.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.