Some errors are thrown relating to token after creating a node with a link field:

Notice: Undefined index: enable_tokens in _link_sanitize() (line 472 of /sites/all/modules/link/link.module).
Notice: Undefined index: title in _link_sanitize() (line 510 of /sites/all/modules/link/link.module).
Notice: Undefined index: enable_tokens in _link_sanitize() (line 510 of /sites/all/modules/link/link.module).

(Originally documented here: http://drupal.org/node/696678#comment-3584764)

Note: this is based on the Oct 18 2010 7.1 dev version.

Attached is a proposed patch.

Comments

das-peter’s picture

Status: Active » Needs review

Works perfectly for me - thanks.

dave reid’s picture

Status: Needs review » Needs work

We actually need to remove the module_exists('token') since the token_replace() function is provided by core.

becw’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB

I'm experiencing the same array key errors. They just look like a typo/oversight. This patch works for me--here's a patch that removes this specific usage of module_exists('token').

becw’s picture

Title: Token-related errors » Notice: Undefined index: title in _link_sanitize()

http://drupal.org/node/955864 was a duplicate of this issue but had a more descriptive title.

scotwith1t’s picture

Applied #3 and still getting

Notice: Undefined index: enable_tokens in _link_sanitize() (line 472 of ...link.module).

Eolmornedhel’s picture

Also applied #3 and still getting:
Notice: Undefined variable: title in _link_sanitize() (line 513 of /sites/all/modules/link/link.module)

jcarlson34’s picture

I am getting the same notice as phrancescot in #5 but only when a url has a question mark query in it.

Like this: http://www.facebook.com/profile.php?ref=profile&id=500042465

jcarlson34’s picture

Did some hunting... Looks like a patch in http://drupal.org/node/947050 (see post #1) fixes the "Notice: Undefined index: enable_tokens in _link_sanitize() (line 472 of ...link.module)." issue.

jcfiala’s picture

Status: Needs review » Fixed

Okay, great!

Amusingly, the token module isn't a module anymore, so I also pulled out the module_enabled('token').

dave reid’s picture

Technically it is still a module for the token UI and missing core tokens, but yes, to perform token replacement, you don't need the module at all.

jcfiala’s picture

Really? Huh, hadn't known that.

Well, we'll see how things shake out if we need to go back in and add module_exists or not.

Status: Fixed » Closed (fixed)

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

franzkewd’s picture

Got the following error message on latest 7.x-1.0-beta1:

Notice: Undefined index: title in _link_sanitize() (line 495 of /var/www/vhosts/example.com/httpdocs/sites/all/modules/link/link.module).

Subscribe.

paulbeaney’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta1
Status: Closed (fixed) » Active

Same here. Just updated to 7.x-1.0-beta1 here too and the error started occurring as per #13.

imiksu’s picture

Status: Active » Needs review
StatusFileSize
new615 bytes

Here's a quick fix. See the patch.

Hope it's helping.

franzkewd’s picture

Thanks iMiksu. It works for me.

clauded’s picture

Patch #15 also worked here.

eewing’s picture

Thanks! Patch #15 worked for me as well.

luke.oakes’s picture

#15 is good :) Thanks.

dqd’s picture

thx! iMiksu can you please reroll for latest dev again, since I had to make 2 important commits last hour?
Sorry, didn't saw it earlier ...

dqd’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
icetristar’s picture

I had the exact same issue. I was also unable to edit nodes which has a link field. It was throwing some error like "Either title or link has to be set." when I wanted to save node even though the node have both fields were filled.

I went to edit content type / edit link field. I selected set static title and set the static title to token [node:title]. Now both errors disappeared and everything works fine in my case.

bcurry’s picture

I also had this issue (Notice: Undefined index: title in _link_sanitize()) after updating to 7.x-1.0-beta1 . I attempted to implement patch #15 on a local copy of the link.module file but was unsuccessful. In the end, after reading icetristar's comment #22, I went into "manage fields" for the two link fields my site uses in:

Home » Administration » Configuration » People » Account settings

I didn't actually change anything, I just selected "edit" and re-saved the field and all seems to be fine.

I had cleared the cache and run cron several times before this to no avail.

I'm pleased to see with this update that it seems that including http:// in front of a URL is now optional. Prior to now, I'd have users adding URL's to their accounts and I'd have to manually add the http:// for them if they didn't include it.

dqd’s picture

thx 4 the reports!

btmash’s picture

Tested out the patch on my site and its working well. The code is also looking sound.

btmash’s picture

Status: Needs review » Reviewed & tested by the community

Ack...should have marked it as such.

Screenack’s picture

Patch is working well here, too; though only informally tested

logickal’s picture

Had this issue pop up today after the latest version of Link was applied. Patch appears to be working fine here.

dqd’s picture

Status: Reviewed & tested by the community » Needs work

nope,
patch doesn't match latest dev

btmash’s picture

StatusFileSize
new623 bytes

Ok...patch applied to latest dev.

btmash’s picture

Status: Needs work » Needs review

Setting to 'needs review'

catmoleman’s picture

Just as in #22 and #23, I was getting that error after upgrading to 7.x-1.0-beta1. I followed the step-by-step instructions in #23 and it worked perfectly. Thanks, bcurry!

jackalope’s picture

Status: Needs review » Needs work

Had this problem today after updating to 7.x-1.0-beta1; problem persisted in 7.x-1.x-dev. The errors went away and the links worked properly in both nodes and views after I edited and saved the link fields; didn't make any changes to the fields, just edited, saved, cleared cache, and all worked well again.

dqd’s picture

Status: Needs work » Fixed

@ BTMash: holy cow! that was fast. ok, wait, I will try to beat it: ... 1 ... 2 ... 3 ... tested. 4 ... 5 ... 6 ... committed to latest dev. bam!
thx! credentials added.

johnlaine’s picture

Same as #23, I tried clearing the cache several times then just clicked edit and re-saved without making any changes and all was well in the Drupal world.

Foxhaven’s picture

Just cleared all caches. Problem went away...
Using 7.8, not dev, btw :-/

Spoke too soon. Edited each content type & resaved. Cleared cache.

Still getting notices.

spacereactor’s picture

Use #30 patch, error is gone after clearing cache. thnk

dqd’s picture

spacereactor, patch already committed to latest dev

Frederic wbase’s picture

patch from #30 worked for me thanks for the effort!

selfuntitled’s picture

patch in 30 worked for me as well! Thanks! I'll keep my eyes out for any side-effects.

enricpera’s picture

patch in 30 also worked for me! Thanks!

Yaazkal’s picture

Patch in 30 really works.

thanks a lot !

marcorai’s picture

Patch in #30 worked for me, too! Thanks!

dqd’s picture

#39, #40, #41, #42, #43 ... patch already committed to latest dev.

Please keep the issues clean!

No need for new reports. Thanks to BTMash and all other contributers.

t0xicCode’s picture

Status: Fixed » Closed (fixed)

For undefined index title in _link_sanitize() errors, please see http://drupal.org/node/1309608