Posted by dan_liip on June 17, 2010 at 3:07pm
34 followers
| Project: | Link |
| Version: | 6.x-2.10 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Digidog |
| Status: | needs work |
Issue Summary
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
| Attachment | Size |
|---|---|
| no_notice.patch | 695 bytes |
Comments
#1
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).
#2
Patch fixed the issue in dan_liip's description.
#3
Apply patch from module directory
#4
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.
#5
Shawn DeArmond, i think the easiest way to fix your notices is to edit and resave the link fields on your nodes.
#6
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).#7
For the undefined index: title, how about this?
#8
Subscribe
#9
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?
#10
subscribe
#11
@jonthomas83
#6 is the patch I'm using.
#6 is RTBC
#12
thanks mikeytown2, much appreciated.
#13
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.
#14
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.
#15
Agree with @srjosh (14): patch didn't solve at least one notice in 2.x-dev
#16
I found many of the warnings could be solved by editing and saving the widget and field settings.
#17
@drewish: re-saving the settings won't fix small logic bugs in the code.
#18
This is still active - waiting for a new release.
#19
Any chance of getting a new release out soon to fix these notices?
#20
Rerolled patch from #6 against current dev and bit extended.
#21
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.
#22
#1225690: PHP notice in _link_sanitize function marked as duplicate of this issue.
#23
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.
#24
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.
#25
++
#26
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).#27
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.
#28
Saving the fields as in #16 worked for me as well.
#29
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 :-)
#30
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? :)
#31
I have the same issue as @csmiller.
#32
The cure in #16 works perfectly for the 7.x-1.0-beta1 release as well.
- paul
#33
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).
#34
@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.
#35
#16 actually worked for me! cheers
#36
Editing & re-saving fields as described in #16 indeed worked for 7.x version
#37
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.
#38
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?
#39
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.
#40
@alltooeasy, you can upgrade Link module to latest -dev version, that helped me without editing any fields or widgets.
#41
#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.
#42
folks, please ... 6.x only here!
( btw, link_sanitize() d7 issue has already to closed /dup and fixed issues )
#43
#44
#23 link-830432-23.patch worked for me only when I switched to the dev version of link module.
#45
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.
#46
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 functionname theme.inc:669
but after a clear-cache, using
6.x-2.xI confirm that I can't reproduce the notice.#47
Subscribing to the original issue, 6.x-2.9 here. Please don't forget the D6 branch yet. Thx!
#48
Note, had constant following errors from every page upon update to 6.x-2.10
#49
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.