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.
I tested this with link field.
[node:field-link:0] gave the following result:
PHP Fatal error: Call to a member function value() on a non-object in /home/dev/www/sandbox.dev/sites/all/modules/contrib/entity/entity_token.tokens.inc on line 297
If I entered [node:field-link], this is what I got on screen:
Property 0, Property 1
[node:field_link] displays the content right.
Comment | File | Size | Author |
---|---|---|---|
#44 | 1440928_fix_fatal_error_for_entity_tokens-44.patch | 1.58 KB | firfin |
#19 | entity_token_error-183.png | 10.19 KB | Zero4ffect |
Comments
Comment #1
fagoPlease make sure are running the latest dev versions of both modules (and clear caches after updating). Is the error still there?
Comment #2
Hendry Lee CreditAttribution: Hendry Lee commentedI've tested with development version from 2012-Feb-15.
I used token filter to display the token in content and also the devel module in the devel tab, if that info helps.
Comment #3
fagoIncluding the link-module dev version?
Comment #4
Hendry Lee CreditAttribution: Hendry Lee commentedI didn't test with link dev, but now I do. Yes, it still includes the same error.
And ah, I tried creating a new node with only one link field and single value.
[node:field_link] shows the content properly.
[node:field-link] shows Property 0.
[node:field-link:0] returns the same fatal error message
PHP Fatal error: Call to a member function value() on a non-object in /home/dev/www/sandbox.dev/sites/all/modules/contrib/entity/entity_token.tokens.inc on line 297
Comment #5
Hendry Lee CreditAttribution: Hendry Lee commented(Forget to set status back to active.)
Comment #6
mitchell CreditAttribution: mitchell commentedContinued from #1058856: Entity tokens not created for multi-value fields. 3 users reported this issue.
Comment #7
recrit CreditAttribution: recrit commentedI have received the same error when testing an issue reported for Commerce File - #1443614: Commerce File Tokens in Rules .
After the fatal error described above, I see the following:
Comment #8
Yuri CreditAttribution: Yuri commentedI report the same issue with the latest dev versions of all modules like D7, link, entity token, entity reference
Comment #9
mwidner CreditAttribution: mwidner commentedI can also confirm this bug.
Comment #10
Yuri CreditAttribution: Yuri commentedSetting to critical because of fatal error
Comment #11
Yuri CreditAttribution: Yuri commentedOk I got my issue solved: I used automatic node titles for a Weblink content type, with the link field. The node title was derived from the title of the link field, which gives this error when there are multiple links. Setting back to normal because this is a 'duh' use case.
Comment #12
BWPanda CreditAttribution: BWPanda commentedI'm also experiencing this issue, but with multi-value Date fields.
Moving this back to Entity API as it seems that's where the issue lies...
Comment #13
Lukas von BlarerIs there on progress on this? I am getting this error by using the metatag to use a token of a multivalue image field.
Comment #14
Cray Flatline CreditAttribution: Cray Flatline commentedCompletely same to @Lukas von Blarer
Comment #15
Tsubo CreditAttribution: Tsubo commentedcan confirm:
Notice: Undefined property: EntityListWrapper::$file in entity_token_tokens() (line 183 of x/sites/all/modules/entity/entity_token.tokens.inc).
Comment #16
Tsubo CreditAttribution: Tsubo commentedSeems this error is only occurring for certain types of field. e.g Term Reference fields work ok - such as:
[node:field-term:0:name]
[node:field-term:1:name]
etc
However, a file field (for images etc) if the field has multiple values should be tokenised as:
[node:field-file:0:file]
or even
[node:field-file:file]
returns this error on the WSOD
Fatal error: Call to a member function value() on a non-object in x/sites/all/modules/entity/entity_token.tokens.inc on line 297
And this error in the log
Notice: Undefined property: EntityListWrapper::$file:0 in entity_token_tokens() (line 183 of x/sites/all/modules/entity/entity_token.tokens.inc).
Comment #17
deadlydexter CreditAttribution: deadlydexter commentedchanging the offending line 297 to the following fixed my issue (with multiple date fields) with no ill effects:
if (!$wrapper || $wrapper->value() === NULL) {
Comment #18
yannickooI can confirm that #17 removes the fatal but still get the error from #16.
Comment #19
Zero4ffect CreditAttribution: Zero4ffect commentedThe fix in #17 stopped the WSOD but I am still getting the error "Undefined property: EntityListWrapper::$value in entity_token_tokens() (line 183",,,
Subscribing
Comment #20
spgd01 CreditAttribution: spgd01 commentedI can confirm this bug when trying to use a Date field token to rename a file. I am using latest Dev versions.
Comment #21
spgd01 CreditAttribution: spgd01 commentedopps wrong module. please delete attachment
Comment #22
mradcliffeAfter running into the same issue I don't think it's expected to not use field-something:storage_column, but field-something:0:storage_column, however that doesn't seem to work either.
Comment #23
gudm.d.haralds CreditAttribution: gudm.d.haralds commentedUsing meta tags to produce og:image, PHP generated errors when Open Graph Image field was configured as follows:
[site:url]sites/default/files/[node:field-media:0:file]
The error was "Notice: Undefined property: EntityListWrapper::$0:file in entity_token_tokens() "
A patch which fixes this is provided. It has to be applied in sites/all/modules/entity
Comment #24
jm.federico CreditAttribution: jm.federico commentedI can confirm behaviour from #16 with file fields:
Token:
[node:field-gallery-image:0:name] - [node:field-gallery-image:0:file] - [node:field-gallery-image:0]
Error:
Fatal error: Call to a member function value() on a non-object in XXX/modules/contrib/entity/entity_token.tokens.inc on line 297
Comment #25
steveaps CreditAttribution: steveaps commented#23 works for me for file fields with multiple values
[node:field-name:0:description]
Edit: seems to have resolved the fatal but leaves the warning from #16
Comment #26
klokie CreditAttribution: klokie commentedre: #25 - same for me
Comment #27
klonos...coming from #1103032: Document how to use date tokens that points to #1058856: Entity tokens not created for multi-value fields of which this issue seems to be a follow-up.
Comment #28
bforchhammer CreditAttribution: bforchhammer commentedI think #1618200: Fix date tokens for multiple values (fatal php error) and #1621084: Support list<struct> type tokens describe the same problem with multi-valued date fields. #1621084-1: Support list<struct> type tokens contains a patch...
Comment #29
vinoth.3v CreditAttribution: vinoth.3v commentedsame here
Call to a member function value() on a non-object in entity_token.tokens.inc
Comment #30
pandominox CreditAttribution: pandominox commentedFor error:
Notice: Undefined property: EntityListWrapper::$0:value w entity_token_tokens() (line183 z drupal\sites\all\modules\entity\entity_token.tokens.inc).
add condition (check if property exist for $wrapper, since it is "undefined"):
for block starting from line 183
Best regards!
Comment #31
GreenSkunk#23 & #30 for the win!
Comment #32
yannickooSo here is a patch for #23.
@GreenSkunk what do you mean with following code? Because that is already in
entity_token.tokens.inc
Comment #33
cbergmann CreditAttribution: cbergmann commentedI think he means that you should replace
with
Comment #34
yannickooAh, got it! Here is the new patch :)
Comment #35
dlx CreditAttribution: dlx commentedThanks! However, entity-7.x-1.1 hasn't been patched yet.
Comment #36
nodecode CreditAttribution: nodecode commented@dxl: the file to be patched, entity_token.tokens.inc, is identical in versions 7.x-1.0 and 7.x-1.1 so the patch is still valid for the most recent version.
Works for me!I tested the patch from #34 and it eliminates the fatal error!Unfortunately for me, I'm dealing with multi-value dates and coming from #1621084: Support list<struct> type tokens so I still get errors
which I think are related to that issue, but this patch at least allows me to debug without a WSOD.Thanks!
Comment #37
nodecode CreditAttribution: nodecode commentedSorry, no, that patch didn't fix the problem. While the fatal error is gone, the errors I'm seeing are consistent with those others have been seeing in this thread.
Notice: Undefined property: EntityListWrapper::$value in entity_token_tokens() (line 183 of x/sites/all/modules/entity/entity_token.tokens.inc)
Comment #38
aj2 CreditAttribution: aj2 commentedThe patch in post #34 worked for me.
I used the format: [node:field-date:0:value:custom:Y-m-d] for a date with potential repeat values.
Comment #39
manoloka CreditAttribution: manoloka commented#34 worked for me too ;) thanks
I mean it fixed the fatal error but the tokens still not giving me a single value from a multi-value image field.
Maybe I'm just not using the right token
I've tried with [node:field-fotos:0] & [node:field-fotos:1] & [node:field-fotos:0:value]
With no success ?¿?¿?¿
Comment #40
wickwood CreditAttribution: wickwood commentedI can confirm that the patch #34 works for me.
For the record and to potentially help others who discover they now have this problem, here is my history with the problem.
I was just notififed of this problem with 2 client sites that each have Event Content Types with a repeating date fields. The error we were getting was:
"
Fatal error: Call to a member function value() on a non-object" ... "entity_token.tokens.inc on line 297"
Things were working before with these sites months ago before they were updated to 7.x-1.0. Unfortunately, I don't recall what version we had installed prior to this, but I know we did not have the problem. Upgrading to 7.x-1.1 obviously did not solve the problem, but applying the patch patch #34 to 7.x-1.1 did fix it.
Thanks for the patch!
Steve
Comment #41
nothinghere CreditAttribution: nothinghere commented#34 work for me too. Applied to 1.1. Please, add it to 1.2 ! :)
Comment #42
hathi_ndg CreditAttribution: hathi_ndg commented#34 works for me too, thanks a lot !
Comment #43
firfin CreditAttribution: firfin commentedProblem still exists in 1.2 applying patch manually still fixes the problem.
Will re-roll a patch for dev version tomorrow.
Comment #44
firfin CreditAttribution: firfin commentedBit late but patch is attached, it is the same as #34 only re-rolled for dev version. Setting version accordingly. Please review, test and set status accordingly.
This modification has helped at least 7 people. Thanks @yannickoo !
Comment #45
Mel55113 CreditAttribution: Mel55113 commentedPatch #44 (manually applied) fixed my problem.
Comment #46
fcedillo CreditAttribution: fcedillo commentedok, no fatal error but... no way to use one of the elements in the multi-value field
in my case i am using an Image field
in my case i simply want to use [node:image-field], as with single-value field or [node:image-field:0], to use the first image
Comment #47
firfin CreditAttribution: firfin commentedSomeone please review/test and mark accordingly, let's get this in next release.
@fcedillo: Did you have a fatal error?
No? Than this issue is not for you. Please search the issue queue for a more appropiate issue. Or if you can't find one start a new issue yourself.
Yes? If you did have a fatal error and it is gone now please mark this as reviewed& tested. We can solve other problems in follow up issues? Let's keep this one moving.
By the way the way, the token is I am using [node:image-field:0:file:url] to get the url from a image field. If this works for you too please set status accordingly. Because then THIS problem is solved.
-- EDIT: fixed grammar
Comment #48
klonosI'm willing to help with this, but as I explain back in #27 I'm not here because I'm having the issue described here. So, if one updates the issue summary with steps to reproduce I would give this a few spins in simplytest.me with and without the patch and report back.
Let me know ;)
Comment #49
klonos...btw, so you save me the trouble from re-reading back through the whole issue, if there are multiple use cases, then separate steps-to-reproduce for each case would be great. I'll test all of them ;)
Comment #50
firfin CreditAttribution: firfin commented@klonos Thanks!
I will start with my specific problem. Create a multi-value image field on an entity ( of type content in my case.) Create content with multiple values for this field. Create a rule (rules module) which has an action with a textfield that accepts tokens (e.g. 'display message' or 'send email'). Use multivalue token like [node:image-field:0:file:url] , get errors. But this will probably also occur when using tokens in other places than rules.
Patch from #44 was working for latest dev at the time. I can re-roll if needed.
These have been solved with a version of the patch too. Not really specified use-case wise, but these are other problems:
OP and Yuri had the problem with a link field
spgd01 Had the problem with a date field
Comment #51
petu CreditAttribution: petu commentedThanks! #44 helps me!
Comment #52
ar-jan CreditAttribution: ar-jan commentedI can confirm that the patch in #44 fixed the fatal error for me. I used filefield_sources in a multi-value filefield, with the pattern
[node:field-date:custom:Ymd]-[node:field-attachment:description].[file:ffp-extension-original]
.While the patch fixed the fatal error, the resulting filename afterwords only included the date, not the file-description.
Comment #53
klonosI think that #44 does not apply cleanly on the latest dev (I get a "An error occurred while patching the project." error over at simplytest.me). Please reroll so I can verify #50/#52.
Comment #54
klonos#44: 1440928_fix_fatal_error_for_entity_tokens-44.patch queued for re-testing.
Comment #55
ar-jan CreditAttribution: ar-jan commentedIn #52 I had applied the patch to entity 7.x-1.2. I now tried it with the latest (packaged) 7.x-1.x-dev and this works. Don't know why simplytest.me fails.
Comment #56
firfin CreditAttribution: firfin commentedI just tried with latest dev, but for me .. patch still applies cleanly. And still solves my problem. Too bad simplytest.me is not cooperating. Thanks for trying though @klonos
Comment #57
firfin CreditAttribution: firfin commented@ar-jan: You can confirm that patch applies cleanly and fixes the errors? I think the token not working might have another cause than what this specific patch is trying to solve. So might be best to try and get this in and start another (or follow-up) issue for you specific token not working?
If you agree (especially the 'does this patch fix this specific problem' part) please change status to reviewed and tested.
Comment #58
NancyDruI applied manually, so I can't say if it applies cleanly. But my error is gone.
Comment #59
cgreenoh CreditAttribution: cgreenoh commentedThe patch in #44 fixed the exact same fatal error issue described here when using multiple files with tokens to generate a URL from each, in a rule. Error before the patch:
Notice: Undefined property: EntityListWrapper::$0:file:url in entity_token_tokens() (line 183 of /sites/all/modules/contrib/entity/entity_token.tokens.inc).
Comment #60
NancyDruComment #61
13rac1 CreditAttribution: 13rac1 commentedApplied to current dev and works as described.
Comment #62
alexweber CreditAttribution: alexweber commented+1 works as expected for me
Comment #63
interestingaftermath CreditAttribution: interestingaftermath commented+ 1 works as expected for me too
Comment #64
adammalone+1 works for me too. This can take a site down through no fault of the user and be hard to diagnose. I think it's fairly important to get this committed to end such issues.
Comment #65
justdave CreditAttribution: justdave commentedAt the risk of being yet another "me too" I'll confirm the patch in #44 works to fix the problem for me, too.
Comment #66
treksler CreditAttribution: treksler commentedAll this patch does is add a check to see if variables are set before using them. I simply cannot believe the amount of discussion (from February 2012 to December 2013) around steps to reproduce the problem, etc. etc.
Here is my two cents. The patch is obvious and trivial. Commit it already. Mind blown.
Comment #67
Renee S CreditAttribution: Renee S commentedThis fix worked for me.
Wow, treksler, seconded. It's a small thing, and fixes big bad behaviour.
Comment #68
hanoiiworks for me too.
Comment #69
jetwodru CreditAttribution: jetwodru commented32: entity-undefined_property-1440928-32.patch queued for re-testing.
Comment #70
jetwodru CreditAttribution: jetwodru commented44: 1440928_fix_fatal_error_for_entity_tokens-44.patch queued for re-testing.
Comment #71
jetwodru CreditAttribution: jetwodru commented#44 FAILED, it does NOT fix the Mult-Value File Field . I tested it on a clean installation of Drupal 7.24 with Rules 7.12. When I used [node:field-file:description] or [entityform:field-file:description] in email, nothing was shown, it's BLANK.
The patch only fix the following error from showing but does NOT fix the missing value of Multi-Value File Field. Thanks
this Fatal error: Call to a member function value() on a non-object in public_html/sites/all/modules/entity/entity_token.tokens.inc on line 297
Comment #72
jetwodru CreditAttribution: jetwodru commented#44 PARTIALLY PASSED , after further testing, it finally works as follows. But I really doubt if I should have to list each and every file uploaded this way ? Since my file field is of unlimited value, how do I know the number of files uploaded by user ? Why can't I use [entityform:field-file:file] to automatically list out all the files uploaded ? Other field types have no problems listing all the values being bound with it. Currently, only File Field has to be specified as tested below.
[entityform:field-file:file] = Nothing was shown (why not listing all the files uploaded ?)
[entityform:field-file:*:file] = shows the 1st file uploaded (since * is a wildcard, why not listing all the files ?)
[entityform:field-file:0:file] = shows the 1st file uploaded (this is rather dumb doing so but no choices currently and just assume the users won't upload more than 5 files)
[entityform:field-file:1:file] = shows the 2nd file uploaded
[entityform:field-file:2:file] = shows the 3rd file uploaded
[entityform:field-file:3:file] = shows the 4th file uploaded
[entityform:field-file:4:file] = shows the 5th file uploaded
Comment #73
ar-jan CreditAttribution: ar-jan commentedRe 71 and 72: this issue is about fixing the fatal error. The token not working as expected should be another issue (see #52 and #57). I'm not sure if there already is one or if you should create a new issue.
I think this is still RTBC as per #45, #51, #52, #58, #59, #61, #62, #63, #64, #65, #67, #68.
Comment #74
jetwodru CreditAttribution: jetwodru commented#73 ok, created a new issue Multi-value File Field Token did NOT list all files uploaded https://drupal.org/node/2165511 for the said in #72 , thanks
Comment #75
klonos@jetwong98: you can use this format for issues: [#issue_number]
So if you write
#2165511: Multi-value File Field Token with :file property is empty
, it automatically becomes #2165511: Multi-value File Field Token with :file property is emptyComment #76
sukh.singh CreditAttribution: sukh.singh commentedI am using date field under content type Event, which has start and end date during creation of the node.
I am trying to create email notification with the help of rules module. Everything is fine with rules. In the body of the email notification field I tried to insert following replacement token
[node:field-oa-date]: Event Date Field "field_oa_date". The following properties may be appended to the token: value (Start date), value2 (End date), duration (Duration)
So what I did is as follows:
However when I try to create the event and clicking on save button I am getting following error
I tried patching with patch #1440928-44: Entity tokens for multi-value fields produce a fatal error and #1440928-34: Entity tokens for multi-value fields produce a fatal error with no success. I am using 7.2 version of entity module.
Comment #77
ar-jan CreditAttribution: ar-jan commented#76: Did you apply the patch in #44 and it didn't solve the problem? Or were you unable to apply the patch.
Because once applied, patch in #44 is reported by dozens of people to solve the fatal error.
Comment #78
treksler CreditAttribution: treksler commentedSo 1.3 came out yesterday without a patch, which obviously fixes fatal errors for dozens of people. Fatal errors! There have been a dozen reviews of a patch so trivial it boggles the mind, and it was still not part of the release.
Anybody with any programming experience can plainly see that this patch should have been part of the release.
Any further discussion should be part of another issue ticket.
The patch in #44 does fix this problem. Period.
Comment #79
treksler CreditAttribution: treksler commenteddoesn't get any more critical than fatal errors that break your site
Comment #80
jetwodru CreditAttribution: jetwodru commented#78, sorry, does it mean that the latest 7.1.3 did NOT include the patch to fix the fatal errors yet ? Last night, I'm in doubt of whether to upgrade as my drupal keeps prompting me the Red Alert , Now I keep a long list of patched modules and check before going to click the upgrade.
Entity API and Rules modules form the main pillars of my Drupal website, upgrading them is said more critical than upgrading core, any issues would break my website seriously. Quite often, some problems would only surface when interacting with other modules. Thanks
Comment #81
justdave CreditAttribution: justdave commentedjetwong98: that's correct, it doesn't have this in it, so you'll need to re-apply this patch after upgrading.
Comment #82
klonosLets help people coming to this issue by pointing the latest patch and hiding the rest.
Comment #83
NancyDruGosh, I had to re-discover this after updating to 7.x-1.3. Please commit it.
Comment #84
fenstratConfirming the patch in #44 is RTBC.
Comment #85
manuscle CreditAttribution: manuscle commentedThe patch worked for me
Comment #86
firfin CreditAttribution: firfin commentedProbably needs another re-roll before it can be committed. Will try and see if I can spare some time the coming days. Please re-set to reviewed & tested if it still applies cleanly to latest dev... haha :P
Comment #87
thumb CreditAttribution: thumb commentedApplied to 2014-Jan-21 -dev version and it works as advertised :)
Comment #88
Sata CreditAttribution: Sata commentedApplied patch 44 to
version = "7.x-1.3+4-dev"
core = "7.x"
project = "entity"
datestamp = "1390318420"
Worked perfectly! Thank you very much.
Comment #89
fagoPatch looks ok and seems to solve troubles for lots of people, thus committed, finally - thanks!
Comment #90
justdave CreditAttribution: justdave commentedI'm guessing this wasn't included in the 1.4 release? I have 7.x-1.4 that I thought I just updated to, and it does not have it, I just had to re-apply the patch after cron started yelling again.
Comment #91
ar-jan CreditAttribution: ar-jan commented@justdave: it was committed just after the 1.4 release, so it's not included.
Comment #93
E Johnson CreditAttribution: E Johnson commentedI was going around in circles between the many threads on this issue. Anyone that stumbles across this thread, this is how I managed to get it to work.
Hope that helps others from spinning their wheels here.
Comment #94
RaulMuroc CreditAttribution: RaulMuroc commentedSince applied latest patch I cannot create any entity. I keep getting error:
Comment #95
markusd1984 CreditAttribution: markusd1984 commentedHas anyone been able to use this successfully?
I went even back to Entity 7.x-1.2 with patch #44 yet still not working [event-node:field-datetime:0:value:custom:Y].
I also tried with Entity 7.x-1.9 and dev which seems to have this patch built in but no success, when using it in a rule to send a mail within the body I get no output at all.
Only [event-node:field-datetime] which outputs
Wed, 01/04/2020 - 18:00
And [event-node:field_datetime] which outputs
22020-04-01 18:00:00 to 2020-04-01 18:30:00
I want it similar to the way the field is displayed on the node
Wednesday, 1 April, 2020 - 18:00 to 18:30
I looked through all issues in date and entity queues to no avail.