Download & Extend

call to undefined drupal_get_path_alias

Project:Clickpath
Version:6.x-1.0
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

strange - is anybody seeing this on d6.1?

#2

still seeing this myself

#3

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.

#4

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.

#5

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?

#6

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

#7

Status:active» needs review

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

AttachmentSize
clickpath-user-hook_init-216308.patch 703 bytes

#8

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.

#9

Status:needs work» needs review

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

AttachmentSize
clickpath_hook_exit_auth-216308-9.patch 669 bytes

#10

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

#11

Status:needs review» fixed

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

#12

Status:fixed» closed (fixed)

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