Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Just installed the latest version available. Error below occur while using it with commerce product.
Notice: Undefined variable: node_id in lightbox2_field_formatter_view() (line 977 of /home/victori2/public_html/sites/all/modules/lightbox2/lightbox2.module).
but everything still work well... Any idea??
Comment | File | Size | Author |
---|---|---|---|
#32 | entity_identifier.patch | 1.14 KB | mindless_mind |
#18 | Immagine.jpg | 131.71 KB | Miao1994 |
error.jpg | 92.48 KB | maxchock |
Comments
Comment #1
maxchock CreditAttribution: maxchock commentederror goes if i comment out line 977...
Comment #2
yukare CreditAttribution: yukare commentedI will fix it. The error is that we get the node id (nid) when the lightbox is used on a node, but since commerce module may use other entity type, we do not get the nid. We need this id when using views to group the imagens on the page.
The fix will be set a default value for id and try to get it for each entity type.
Comment #3
maxchock CreditAttribution: maxchock commentedI see. One thing I notice is why Lightbox2 not working on the default content "Basic Page" ?? I wanted to generate the error on "Basic Page" but the image can only show original size on full content node and there is no lightbox feature. But it work on "Blog".
Comment #4
yukare CreditAttribution: yukare commentedThis is not the same issue, so please, open a new issue for it. For lightbox do not matter the content type, only the entity type, so provide more details about it. How you are using it? There is any public url i can access?
Thanks.
Comment #5
tomogden CreditAttribution: tomogden commentedAlso getting this error using Lightbox on my profile2 pages. Please let us know when there is a patch or release we can download.
Comment #6
togsbayar CreditAttribution: togsbayar commentedI also getting this error. And it looks bad because it shows many error messages, so I put some codes. Maybe it's not good. But at least errors gone for me.
Suggest me if you have any other good idea. What I changed is :
$element[$delta] = array(
'#theme' => 'lightbox2_image',
'#item' => $item,
'#lightbox_type' => $lightbox_type,
'#image_style' => $image_style,
'#lightbox_style' => $lightbox_style,
'#path' => $uri,
'#node_id' => $node_id,
'#field_name' => $field['field_name'],
);
This lines to :
if( isset($node_id) ){
$element[$delta] = array(
'#theme' => 'lightbox2_image',
'#item' => $item,
'#lightbox_type' => $lightbox_type,
'#image_style' => $image_style,
'#lightbox_style' => $lightbox_style,
'#path' => $uri,
'#node_id' => $node_id,
'#field_name' => $field['field_name'],
);
}
else{
$element[$delta] = array(
'#theme' => 'lightbox2_image',
'#item' => $item,
'#lightbox_type' => $lightbox_type,
'#image_style' => $image_style,
'#lightbox_style' => $lightbox_style,
'#path' => $uri,
'#field_name' => $field['field_name'],
);
Comment #7
SteffenRThe error occurs while having none 'node' Entity Types in the formatter_view - in combination with field_collection i also get the error message.
Setting $node_id to FALSE solved the issue for me - maybe we need some more validation here:
SteffenR
Comment #8
bensti CreditAttribution: bensti commentedsame error #7 don't work for me
Comment #9
SteffenR@bensti: have you already checked the values that are in the entity object ? You can use dsm($entity) (devel module) or print_r($entity) to have a look at all the values.
Comment #10
thirdboxcar CreditAttribution: thirdboxcar commentedSame error as the above. I'm using it on a field_collection created with this module, if that makes a difference: http://drupal.org/project/field_collection
Comment #11
yukare CreditAttribution: yukare commentedI just commited a small fix for it, please test(wait for the next dev release) and report if you still have this issue.
Comment #13
jalbrizio CreditAttribution: jalbrizio commentedI also Just installed 7.x-1.0-beta1 with the latest commerce product and im still seeing this issue.
I just commented out line 977 like in the first comment. and it works on my products.
I havent tested it anywhere else yet.
Comment #14
fehin CreditAttribution: fehin commentedI recently installed this module and I'm getting this same error on a user view.
Comment #15
laraz CreditAttribution: laraz commentedsame for me. version 7.x-1.0-beta1 with commerce product. I commented out line 977.
Comment #16
VladimirAusYep, error is still there with commerce.
Comment #17
Miao1994 CreditAttribution: Miao1994 commentedI report the same PHP notice setting an image display field in article content (lightbox medium to original). No commerce product installed.
Comment #18
Miao1994 CreditAttribution: Miao1994 commentedComment #19
Elavarasan R CreditAttribution: Elavarasan R commentedThe error was fixed by doing as below
Add $node_id = 0; in lightbox2.module at line 960 or before the line
if ($entity_type == 'node') {
$node_id = $entity->nid;
}
Comment #20
tomogden CreditAttribution: tomogden commentedUsing the Dev version from #11 fixes it for me.
I guess we are just waiting for this fix to come out in the next release?
Comment #21
ckukahiko CreditAttribution: ckukahiko commentedword. commenting out line 977 is working for me so far too.
thanks, maxchock!
Comment #22
bporter2387 CreditAttribution: bporter2387 commentedSame happened to me. It turns out the entity type (for the commerce module) is 'commerce_product' instead of 'node'.. So I just added a 2nd conditional statement into there. Commenting out the line works too :P
Comment #23
a.milkovskyI just define variable node_id. E.g. $node_id = '';
Comment #24
Narek CreditAttribution: Narek commented#23 works for.
I don't have this error on fields on node level, but I do when the field has been used for user, I think that is why its causing error.
Thanks a.milkovsky
Please let us know if this is the right way of fixing it.
Comment #25
lazly CreditAttribution: lazly commentedSorry guys, I dont want to be a jerk, but...
Its an 1 year old bug, with lots of solution from the developers and with easy reproduction.
Why doesnt commited it to base code? :(
Comment #26
mlopresti CreditAttribution: mlopresti commentedThis definitely needs to be fixed, but I think it should be in a way that works with all entities not just implicitly stated ones. That way we don't have to re-visit this every time we add a new entity.
Comment #27
tds2012 CreditAttribution: tds2012 commentedHi, had the same issue and commented out line 977, it works now.
Comment #28
mindless_mind CreditAttribution: mindless_mind commentedMy personal solution of problem.
Remove:
In line 977, replace
with:
Should work for every entity type.
Comment #29
AlfTheCat CreditAttribution: AlfTheCat commented#27 worked for me but #28 produced an error (WSOD)
Error: syntax error, unexpected ';', expecting ')' in [..] line 977
Comment #30
mindless_mind CreditAttribution: mindless_mind commentedSorry, my bad. There should be a comma instead of semicolon. I made a typo when writing post.
'#node_id' => $entity->identifier(),
Comment #31
djs070 CreditAttribution: djs070 commentedMy situation: same error when applying lightbox field formatter to image on a field collection.
Tried #30:
Fatal error: Call to undefined method stdClass::identifier() in ...sites/all/modules/lightbox2/lightbox2.module on line 977
Commenting out line 977 seems to work, though I'm anxious about other issues that this may cause.
EDIT: Just re-read the thread and found that $node_id is used in views. Have un-commented line 977 and changed 961:
Comment #32
mindless_mind CreditAttribution: mindless_mind commentedOk, I now see that I've made too many custom modifications in my own project, so my above changes won't work for you. In order to check why, I've created clean drupal installation and installed lightbox2 module from git. I attach patch with my changes. Notice that I added entity module dependency, because identifier() by itself is an entity class method. In patch I'm using entity_metadata_wrapper which is an entity module function. There is tendency to make nearly everything an entity, so I don't think that this additional dependency is a problem.
I created example node and user, with image field and it worked in both cases.
Applying patch:
Copy it to lightbox2 module directory.
In this directory invoke: git apply -v entity_identifier.patch
Can somebody confirm that this is working?
Comment #33
jason.fisher CreditAttribution: jason.fisher commenteddid not apply for me.
Comment #34
mindless_mind CreditAttribution: mindless_mind commentedDid you have errors when applying patch? Are you sure that it made any changes in files? Just a moment ago I installed D7 fresh install, applied it and everything worked without scratch.
Hmmm... I have git version of lightbox2 module installed. Maybe this is required when applying patches?
Nevermind. I see that in the dev version it is fixed (commit 4757f78369fbda2cfb0da50eb3f614b79bf3b61b).
Comment #35
aaronmfisher86 CreditAttribution: aaronmfisher86 commented#19 solved the issue for me!
Comment #36
Tokoh CreditAttribution: Tokoh commented#19 solved the issue for me too.
Comment #37
JeniferTucker CreditAttribution: JeniferTucker commentedSubscribing.
D7 (7.20) clean install with Lightbox2 (7.x-1.0-beta1) installed and enabled.
Getting the same message orginally posted on 24 October 2011.
I have gone for #22 solution and applied to line 960 as using Lightbox2 with Commerce module as I have a multisite set up, one site for eCommerce.
Fixed and working.
Agree with #25 but understand the module developer may have other commitments.
http://drupal.org/project/lightbox2
Maintenance status: Seeking new maintainer
Development status: No further development
If the development status showed active, then I would have made a donation to encourage the developer for providing Lightbox2 for us all to use freely.
Comment #38
cjtriplett CreditAttribution: cjtriplett commented#30 worked for me.
I'm not using the commerce module. The error was occurring on a panel page that replaces the default Node view. I tried adding the NID to the panel manually but this did not solve the error.
Comment #39
drasgardian CreditAttribution: drasgardian commentedThe patch in #32 worked a treat for me, applied against 7.x-1.x-dev
Comment #40
ascii122 CreditAttribution: ascii122 commentedgot this same problem using taxonomy term page with lightbox. Patch at #32 fixed it
Comment #41
5t4rdu5t CreditAttribution: 5t4rdu5t commented#32 also solved the problem for me. Thank you!!
Comment #42
yukare CreditAttribution: yukare commentedThe patch on #32 is commited: http://drupalcode.org/project/lightbox2.git/commit/0f07ed2
Thanks for mindless_mind for this.
Just one important thing, this adds a dependency from entity module, but it is necessary as it is impossible to get the id from all entity types in core/contrib without this.
Comment #44
ragavendra_bn CreditAttribution: ragavendra_bn commentedJust put isset condition as below before $element...should work.......
970
971 if (!isset($node_id))
972 $node_id = '';
973
974 $element..............
Give me commit instructions, I can commit this to the next release....
Comment #45
Anonymous (not verified) CreditAttribution: Anonymous commentedGetting this same error today(Jan 2014) with latest dev release. Commerce module installed.
Comment #46
mindless_mind CreditAttribution: mindless_mind commentedAre you sure that you have downloaded dev version..? :)
Comment #47
Anonymous (not verified) CreditAttribution: Anonymous commentedHi @mindless_mind You were right, I was running 7.x-1.0-beta1. I just updated to the latest dev using drush and will report back on the error message status later today after I have a chance to watch the dlog for a while.
Comment #48
Anonymous (not verified) CreditAttribution: Anonymous commentedUpdated to latest dev release and still getting error message in dblog:
page not found
Date Wednesday, February 19, 2014 - 13:49
User Anonymous (not verified)
Location ...modules/lightbox2/js/lightbox.js,q1388124812.pagespeed.jm.4ihZxm_Qi8.js
Referrer
Message ...modules/lightbox2/js/lightbox.js,q1388124812.pagespeed.jm.4ihZxm_Qi8.js
Severity warning
Hostname #########
Comment #49
mikeaja CreditAttribution: mikeaja commentedGetting issue in 1.0-beta1 (bearing in mind this was reported 3 years ago).
I will try dev release, but it's a production site, and I'm not confident in using a dev release on an unmaintained module (only that I presume it's unmaintained given this is a 3 year old bug).
Alternatives to lightbox2 perhaps?
Comment #50
VM CreditAttribution: VM commented#42 indicates that the patch in #32 was applied to -dev on 06JUL13. Project page indicates that new beta hasn't been released that includes the patch. As such resetting the version to #39.
Comment #51
quotesBro CreditAttribution: quotesBro commentedmarking as fixed again (#42)
Comment #53
lughy CreditAttribution: lughy commentedHello,
at this time, #30 works for me (drupal 7.31 - lightbox2 7.x-1.0-beta1)
Comment #54
Wtower CreditAttribution: Wtower commentedJust for reference, if anyone upgrading from 7.x-1.0-beta1 to 7.x-1.x-dev gets an error:
make sure that you have the Entity API module up and enabled.