We just upgraded the link module on our server and since then we have the following PHP notice shown when content containing links is displayed:

notice: Undefined variable: element in /var/www/drupal/sites/all/modules/link/link.module on line 445.

I enclosed a patch adding a simple isset test to avoid this notice.

Hope it helps

Comments

shawn dearmond’s picture

I'm getting this error too. In fact, when I first create a node with a link value, I get these three errors:

    * Notice: Undefined index: title in _link_validate() (line 323 of /path/to/drupal/sites/all/modules/link/link.module).
    * Notice: Undefined index: title in content_storage() (line 1031 of /path/to/drupal/sites/all/modules/cck/content.module).
    * Notice: Undefined variable: element in _link_sanitize() (line 445 of /path/to/drupal/sites/all/modules/link/link.module).
shawn dearmond’s picture

Status: Active » Reviewed & tested by the community

Patch fixed the issue in dan_liip's description.

nasa51’s picture

StatusFileSize
new703 bytes

Apply patch from module directory

drewish’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new964 bytes

I don't think that patch is right. The $element variable is not used elsewhere in the function and not passed in as a parameter so it'll never be set and the code will never be executed. My guess is that the function used to get $element passed in and referred to the item as $element['#item']. At some point all the other references were changed but this one.

drewish’s picture

Shawn DeArmond, i think the easiest way to fix your notices is to edit and resave the link fields on your nodes.

damienmckenna’s picture

StatusFileSize
new5.6 KB
new4.55 KB

Here are two updated patches that cover other logic flaws through the module, one patch for v6.x-2.9 and one for the lasted DRUPAL-6--2 branch.

There's one remaining error that shows when the title field is disabled, upon saving the node the following error is displayed:
Notice: Undefined index: title in content_storage() (line 1071 of /sites/all/modules/contrib/cck/content.module).

rbayliss’s picture

StatusFileSize
new367 bytes

For the undefined index: title, how about this?

naxoc’s picture

Subscribe

jonthomas83’s picture

Hi guys, there's so many patches on here, I was wondering if someone could point me in the right direction to the correct patch that will definitely solve this issue.

Any news on whether this will be ported into a new stable release of the module?

caktux’s picture

subscribe

mikeytown2’s picture

Status: Needs review » Reviewed & tested by the community

@jonthomas83
#6 is the patch I'm using.

#6 is RTBC

jonthomas83’s picture

thanks mikeytown2, much appreciated.

coltrane’s picture

There's also a notice in link.inc

Notice: Undefined variable: element in _link_sanitize() (line 171 of .../htdocs/sites/all/modules/contrib/link/link.inc).

Line 171 is referencing variable $element when it's not defined the that function that I can tell.

Edit: Oh, 2.x-dev patch in #6 handles this notice. +1 to #6 being RTBC.

srjosh’s picture

Status: Reviewed & tested by the community » Needs work

My experience with this is not quite RTBC, sadly. 2.9 patch fixed nearly all notices, but I am still getting:
Notice: Undefined index: validate_url in _link_sanitize() (line 395 of .../sites/all/modules/link/link.module)

I'd rewrite the patch but I'm not sure exactly what that section is attempting to do.

esteewhy’s picture

Agree with @srjosh (14): patch didn't solve at least one notice in 2.x-dev

drewish’s picture

I found many of the warnings could be solved by editing and saving the widget and field settings.

damienmckenna’s picture

@drewish: re-saving the settings won't fix small logic bugs in the code.

balabushka’s picture

This is still active - waiting for a new release.

lambic’s picture

Any chance of getting a new release out soon to fix these notices?

wojtha’s picture

Status: Needs work » Needs review
StatusFileSize
new64.07 KB

Rerolled patch from #6 against current dev and bit extended.

wojtha’s picture

StatusFileSize
new8.5 KB

Patch in #20 is wrong during merge I probably accidentally change the line endings, so once again:

Rerolled patch from #6 against current dev and bit extended.

wojtha’s picture

#1225690: PHP notice in _link_sanitize function marked as duplicate of this issue.

mikeytown2’s picture

Version: 6.x-2.9 » 6.x-2.x-dev
StatusFileSize
new5.24 KB
new4.14 KB

I did a simple merge of the patches from #21 and #6. Applies to the latest dev.

I also attached a fixed version of #21 as this patch didn't work for me.

d.clarke’s picture

The patch in #23 (link-830432-23.patch) resolved the notices I was receiving. Can someone else confirm as well and then mark it as reviewed and tested by the community?

Thank you for everyone's work on this.

dqd’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for everyone's work on this.

++

13rac1’s picture

Notices I was receiving were fixed by saving the fields again as described in #16. It seems some new settings were missing. Probably should be corrected in a install update function.
Notice: Undefined index: title in _link_sanitize() (line 495 of /var/www/sites/all/modules/contrib/link/link.module).

dqd’s picture

thanks for all your contribution and sorry for treating v6 as an orphan over the last weeks.

We had to hurry up with the d7 port, that's why. There was and is still a lot to do and so I jumped in the boat and got assigned to it to help / catch up getting ready for final d7 release. And I try as much as I can. Also with certain severity by stopping time wasting goose chases in the issue queue. (Not here) The custom link field module is an important contribution to Drupal custom fields I couldn't imagine to make any custom content type without it, and Jcfiala did awesome work already to make that happen. And thanks to many patch submissions we are close before final 7.

I will try to commit your contributions asap.

joedag32’s picture

Saving the fields as in #16 worked for me as well.

csmiller’s picture

Priority: Minor » Normal

Just updated this module to 7.x-1.0-beta1 this morning and this error has appeared. (Notice: Undefined index: title in _link_sanitize() (line 495 of /home4/diamons0/public_html/sites/all/modules/link/link.module). I tried re-saving all of my link titles and URLs but the message persists.

Addition: I changed the widget settings in Content Types, and the messages are no longer present. Should have read comment #16 more closely :-)

dqd’s picture

weird .. we need to flush this somehow ... I try to get some time for it next days ... I am sure it is something stupid like resetting a var ...

! EDIT:
Uhm ... but wait .... But U know that you are in a v6.x issue thread? Dont' you? right? :)

bulat’s picture

I have the same issue as @csmiller.

paulbeaney’s picture

The cure in #16 works perfectly for the 7.x-1.0-beta1 release as well.

- paul

prston’s picture

Apparently, it doesn't work if the link field already has some content inside. Just doing the #16 doesn't do anything in my case. I removed all nodes using this field (I can do it freely, it's a dev. version), then applied the #16 procedure and... magic, it worked. No need to mention that if you have plenty of content, it's a *bit* annoying :D

@csmiller,
@paulbeaney:
Searching further brings me another errors, especially in the Views 'auto preview'.
So apparently the #16 doesn't fix everything on 7.x-1.0-beta1 (sorry, I just see we are on a 6.x issue).

okokokok’s picture

@prston 7.x-1.x-dev (Sep-27) got rid of the warning on my site.

@Digidig I suggest releasing 7.x-1.0-beta2.

acbramley’s picture

#16 actually worked for me! cheers

Prasad Shir’s picture

Editing & re-saving fields as described in #16 indeed worked for 7.x version

renat’s picture

Faced the same problem as in #29 (on D7 site, of course). Upgrade to link-7.x-1.x-dev (Sep-27) solved this, just like in #34.

alltooeasy’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev

Notice: Undefined index: title in _link_sanitize() (line 495 of

So for D7 what is the suggested solution. Apologies this is in D6 thread was unable to find a D7 thread for it.

We have an aweful lot of fields to edit if that is the method. Any suggestions?

bschilt’s picture

the solution in comment #16 worked for me.

These errors started happening to me when I upgraded to Link 7.x-1.0-beta1. I went into the Manage Fields for each of my custom content types and edited each filed and saved it without changing anything. The _link_sanitize() message I was getting is now gone.

renat’s picture

@alltooeasy, you can upgrade Link module to latest -dev version, that helped me without editing any fields or widgets.

camorim’s picture

#16 also worked for me. As I had only a few content types it was quick.
Hope it get's fixed on the next release.

dqd’s picture

Title: notice: Undefined variable: element in link.module on line 445 » Link module shows PHP notices
Assigned: dqd » Unassigned

folks, please ... 6.x only here!
( btw, link_sanitize() d7 issue has already to closed /dup and fixed issues )

dqd’s picture

Title: Link module shows PHP notices » notice: Undefined variable: element in link.module on line 445
Version: 7.x-1.x-dev » 6.x-2.x-dev
Assigned: Unassigned » dqd
lauggh’s picture

Title: Link module shows PHP notices » notice: Undefined variable: element in link.module on line 445
Assigned: Unassigned » dqd

#23 link-830432-23.patch worked for me only when I switched to the dev version of link module.

chromix’s picture

This has been opened for a while and I'm kind of surprised no one has committed a fix for it. I tried #23 and it worked, but now I'm getting a different error:

Notice: Undefined index: title in content_storage() (line 1031 of drupal/sites/all/modules/contrib/cck/content.module).

This is on a field with a static title. I went ahead and changed the CCK module and it fixed the problem. I posted a solution on CCK #1034428, so maybe we can assume the error isn't happening because of a problem with Link...? Not sure, based on what I saw.

drzraf’s picture

Status: Reviewed & tested by the community » Needs work

bug still present and patch does not apply anymore
anyway, I can't reproduce the notice using 6.x-2.x, but with 6.x-2.9 only.

Instead I got a

function 'theme_link_formatter_default' not found or invalid function
name theme.inc:669

but after a clear-cache, using 6.x-2.x I confirm that I can't reproduce the notice.

doitDave’s picture

Subscribing to the original issue, 6.x-2.9 here. Please don't forget the D6 branch yet. Thx!

strawberrybrick’s picture

Note, had constant following errors from every page upon update to 6.x-2.10

strawberrybrick’s picture

Version: 6.x-2.x-dev » 6.x-2.10

Note, had constant following errors from every page upon update to 6.x-2.10

call_user_func_array() expects parameter 1 to be a valid callback, function 'theme_link_formatter_default' not found or invalid function name in ..../includes/theme.inc on line 669.

however, clearing the site cache seems to have fixed issue.

mikeytown2’s picture

Version: 6.x-2.10 » 6.x-2.x-dev
Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new4.15 KB

#23 re-rolled against the latest dev. Note that without this patch I do not get any php notices so I'm not sure if any of this is needed.

dqd’s picture

@jcfiala: can you chime in to look for the patch? Sry, I am not deep enough into link v6 code ATM and would love to see this fixed to clean up the issue queue.

damienmckenna’s picture

Status: Needs review » Closed (won't fix)

Thank you all for your efforts, but I'm sorry to say that the D6 version is no longer supported.

damienmckenna’s picture

Assigned: dqd » Unassigned
dqd’s picture

Thanks for cleaning up the issue queue, Damien. Greetings from Berlin. *waves*

dqd’s picture

posting error