Closed (fixed)
Project:
Clock
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2011 at 09:09 UTC
Updated:
28 May 2011 at 14:02 UTC
Jump to comment: Most recent file
Installed version 2 dev today.
Looks good, but there's a small issue, seeing this Notice when working with the clock block configuration:
Undefined index: clock in clock_tokens() (line 50 of /pathToD7/sites/all/modules/clock/clock.tokens.inc).
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1121730-clock-token-fix.patch | 1.24 KB | dave reid |
| #3 | clock back-trace.txt | 562.49 KB | tebb |
Comments
Comment #1
tebb commentedHmmm. This is a bit odd.
Now that I have added and deleted some clocks, swapped to the edge module from the table module etc I only seem to see this when I log in to the site.
I can't be clear about what exact changes have happened and when the behaviour changed.
When I navigate to another page and for the rest of the session, there's no message.
If I log out and log back in again, I see the message again.
Is anybody else seeing this?
Comment #2
tstoecklerSorry, but I can't really reproduce your error. If you can find any way to reproduce this, that would be great!
Comment #3
tebb commentedHi Tobias and thanks for trying.
I get this consistently.
I do not see the notice as anonymous user while browsing the site.
I do see it when submitting the registration form.
I see the notice consistently:
- Twice when I log in.
- Once when I save the logged in user details, for instance after only changing the signature.
- Once when I save the user details without making any changes
- Once when saving changes to pages or articles
etc
I see the notice even if the clock block is excluded from displaying on the page. This seems odd.
I had a look at a back-trace printed to screen using these instructions: http://www.lullabot.com/articles/quick-and-dirty-debugging.
As far as I can see, it just confirms that there is no 'clock' section of the array, but I'll attach it in case it helps.
The back-trace has a label '*Recursion*' near the end of each section of the array. I guess this is normal?
Anything else I can do to trace the issue? I tried disabling entity_cache, but this didn't make any difference.
Unsurprisingly, when I disable the clock module, the issue disappears.
Comment #4
Starminder commentedGetting this one also.
Comment #5
cord1 commentedNotice: Undefined index: clock in clock_tokens() (line 50 of /srv/www/htdocs/DEVTEST/sites/all/modules/clock/clock.tokens.inc).
running
Core 7.x-dev 2011-05-01
clock 7.x-2.x-dev 2011-02-25
( token 7.x-1.x-dev 2011-02-25 )
Everything worked fine until I tested triggers, message when user log in.
Then the above notice came up.
Following var_dumps at line 48 in clock_tokens.inc:
type= string(5) "clock"
tokens= array(1) { ["date"]=> string(12) "[clock:date]" }
data= array(1) { ["clock"]=> object(stdClass)#157 (6) { ["cid"]=> string(1) "1" ["time_zone_type"]=> string(4) "user" ["custom_time_zone"]=> string(3) "UTC" ["date_type"]=> string(4) "long" ["display"]=> string(12) "[clock:date]" ["weight"]=> string(1) "0" } }
SOLUTION:
In line 50 change :
if ($type = 'clock') {
to
if ($type == 'clock') {
Comment #6
dave reidWas also missing a break statement int clock_tokens().
Also please consider respecting $options['sanitize'] - see core implementations of hook_tokens() for examples on how to do it.
Comment #7
Starminder commentedI can confirm the patch is good - thanks!
Comment #8
tstoecklerThanks very much for tha patch and your patience, and sorry it took me so long.
Committed to 7.x-2.x.
http://drupal.org/commitlog/commit/12842/74205536b51c27ef584ed6ca65acd02...
@Dave Reid: I will look into
$options['sanitize']. I do not yet know how that is relevant here, but I'll find that out :)