Closed (fixed)
Project:
Lightbox2
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Oct 2011 at 07:59 UTC
Updated:
30 Dec 2014 at 09:01 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
maxchock commentederror goes if i comment out line 977...
Comment #2
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 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 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 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 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 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 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 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 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 commentedI recently installed this module and I'm getting this same error on a user view.
Comment #15
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 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 commentedComment #19
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 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 commentedword. commenting out line 977 is working for me so far too.
thanks, maxchock!
Comment #22
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 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 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 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 commentedHi, had the same issue and commented out line 977, it works now.
Comment #28
mindless_mind commentedMy personal solution of problem.
Remove:
In line 977, replace
with:
Should work for every entity type.
Comment #29
alfthecat commented#27 worked for me but #28 produced an error (WSOD)
Error: syntax error, unexpected ';', expecting ')' in [..] line 977Comment #30
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 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 977Commenting 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 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 commenteddid not apply for me.
Comment #34
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 commented#19 solved the issue for me!
Comment #36
Tokoh commented#19 solved the issue for me too.
Comment #37
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 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 commentedThe patch in #32 worked a treat for me, applied against 7.x-1.x-dev
Comment #40
ascii122 commentedgot this same problem using taxonomy term page with lightbox. Patch at #32 fixed it
Comment #41
5t4rdu5t commented#32 also solved the problem for me. Thank you!!
Comment #42
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 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) commentedGetting this same error today(Jan 2014) with latest dev release. Commerce module installed.
Comment #46
mindless_mind commentedAre you sure that you have downloaded dev version..? :)
Comment #47
Anonymous (not verified) 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) 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 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 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 commentedmarking as fixed again (#42)
Comment #53
lughy commentedHello,
at this time, #30 works for me (drupal 7.31 - lightbox2 7.x-1.0-beta1)
Comment #54
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.