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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Title: Fatal error on multi-value fields » Fatal error when retrieving token for multi-value link field
Status: Active » Postponed (maintainer needs more info)

Please make sure are running the latest dev versions of both modules (and clear caches after updating). Is the error still there?

Hendry Lee’s picture

I'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.

fago’s picture

Including the link-module dev version?

Hendry Lee’s picture

I 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

Hendry Lee’s picture

Status: Postponed (maintainer needs more info) » Active

(Forget to set status back to active.)

mitchell’s picture

Title: Fatal error when retrieving token for multi-value link field » Entity tokens for multi-value link fields produce a fatal error
Project: Entity API » Link
Component: Core integration » Code

Continued from #1058856: Entity tokens not created for multi-value fields. 3 users reported this issue.

recrit’s picture

I 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:

Notice: Undefined property: EntityListWrapper::$0:file:name in entity_token_tokens() (line 183 of [...]modules/entity/entity_token.tokens.inc).
Yuri’s picture

I report the same issue with the latest dev versions of all modules like D7, link, entity token, entity reference

mwidner’s picture

I can also confirm this bug.

Yuri’s picture

Priority: Normal » Critical

Setting to critical because of fatal error

Yuri’s picture

Priority: Critical » Normal

Ok 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.

BWPanda’s picture

Title: Entity tokens for multi-value link fields produce a fatal error » Entity tokens for multi-value fields produce a fatal error
Project: Link » Entity API
Component: Code » Entity tokens
Priority: Normal » Major

I'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...

Lukas von Blarer’s picture

Is there on progress on this? I am getting this error by using the metatag to use a token of a multivalue image field.

Cray Flatline’s picture

Completely same to @Lukas von Blarer

Tsubo’s picture

can confirm:

Notice: Undefined property: EntityListWrapper::$file in entity_token_tokens() (line 183 of x/sites/all/modules/entity/entity_token.tokens.inc).

Tsubo’s picture

Seems 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).

deadlydexter’s picture

changing the offending line 297 to the following fixed my issue (with multiple date fields) with no ill effects:

if (!$wrapper || $wrapper->value() === NULL) {

yannickoo’s picture

I can confirm that #17 removes the fatal but still get the error from #16.

Zero4ffect’s picture

FileSize
10.19 KB

The fix in #17 stopped the WSOD but I am still getting the error "Undefined property: EntityListWrapper::$value in entity_token_tokens() (line 183",,,

Subscribing

spgd01’s picture

I can confirm this bug when trying to use a Date field token to rename a file. I am using latest Dev versions.

spgd01’s picture

opps wrong module. please delete attachment

mradcliffe’s picture

After 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.

gudm.d.haralds’s picture

FileSize
388 bytes

Using 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

jm.federico’s picture

I 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

steveaps’s picture

#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

klokie’s picture

re: #25 - same for me

klonos’s picture

...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.

bforchhammer’s picture

vinoth.3v’s picture

same here
Call to a member function value() on a non-object in entity_token.tokens.inc

pandominox’s picture

Version: 7.x-1.x-dev » 7.x-1.0

For 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"):

if (isset($wrapper->$property_name)) {    
}

for block starting from line 183

$replacement = _entity_token_get_token($wrapper->$property_name, $options);
if (isset($replacement)) {
   $replacements[$original] = $replacement;
}

Best regards!

GreenSkunk’s picture

#23 & #30 for the win!

yannickoo’s picture

Status: Active » Needs review
FileSize
477 bytes

So here is a patch for #23.

@GreenSkunk what do you mean with following code? Because that is already in entity_token.tokens.inc

$replacement = _entity_token_get_token($wrapper->$property_name, $options);
if (isset($replacement)) {
   $replacements[$original] = $replacement;
}
cbergmann’s picture

I think he means that you should replace

$replacement = _entity_token_get_token($wrapper->$property_name, $options);
if (isset($replacement)) {
   $replacements[$original] = $replacement;
}

with

if (isset($wrapper->$property_name)) {    
  $replacement = _entity_token_get_token($wrapper->$property_name, $options);
  if (isset($replacement)) {
     $replacements[$original] = $replacement;
  }
}
yannickoo’s picture

Ah, got it! Here is the new patch :)

dlx’s picture

Thanks! However, entity-7.x-1.1 hasn't been patched yet.

nodecode’s picture

@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!

nodecode’s picture

Version: 7.x-1.0 » 7.x-1.1

Sorry, 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)

aj2’s picture

The 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.

manoloka’s picture

#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 ?¿?¿?¿

wickwood’s picture

I 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

nothinghere’s picture

#34 work for me too. Applied to 1.1. Please, add it to 1.2 ! :)

hathi_ndg’s picture

#34 works for me too, thanks a lot !

firfin’s picture

Version: 7.x-1.1 » 7.x-1.2

Problem still exists in 1.2 applying patch manually still fixes the problem.
Will re-roll a patch for dev version tomorrow.

firfin’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
FileSize
1.58 KB

Bit 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 !

Mel55113’s picture

Patch #44 (manually applied) fixed my problem.

fcedillo’s picture

ok, 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

firfin’s picture

Someone 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

klonos’s picture

I'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 ;)

klonos’s picture

...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 ;)

firfin’s picture

@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

petu’s picture

Thanks! #44 helps me!

ar-jan’s picture

I 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.

klonos’s picture

I 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.

klonos’s picture

ar-jan’s picture

In #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.

drush dl entity-7.x-1.x-dev
cd entity
wget https://drupal.org/files/1440928_fix_fatal_error_for_entity_tokens-44.patch
patch -p1 < 1440928_fix_fatal_error_for_entity_tokens-44.patch
patching file entity_token.tokens.inc

firfin’s picture

I 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

git clone --branch 7.x-1.x http://git.drupal.org/project/entity.git
cd entity
git apply -v 1440928_fix_fatal_error_for_entity_tokens-44.patch

firfin’s picture

@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.

NancyDru’s picture

I applied manually, so I can't say if it applies cleanly. But my error is gone.

cgreenoh’s picture

The 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).

NancyDru’s picture

Status: Needs review » Reviewed & tested by the community
13rac1’s picture

Applied to current dev and works as described.

alexweber’s picture

+1 works as expected for me

interestingaftermath’s picture

+ 1 works as expected for me too

adammalone’s picture

+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.

justdave’s picture

At the risk of being yet another "me too" I'll confirm the patch in #44 works to fix the problem for me, too.

treksler’s picture

All 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.

Renee S’s picture

This fix worked for me.

Wow, treksler, seconded. It's a small thing, and fixes big bad behaviour.

hanoii’s picture

works for me too.

jetwodru’s picture

jetwodru’s picture

jetwodru’s picture

#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

jetwodru’s picture

#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

ar-jan’s picture

Re 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.

jetwodru’s picture

#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

klonos’s picture

@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 empty

sukh.singh’s picture

I 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:

Hello [user:name]

[node:body]

Event Date:[node:field-oa-date:value] to [node:field-oa-date:value2], duration: [node:field-oa-date:duration]

Thanks & Regards
Admin

However when I try to create the event and clicking on save button I am getting following error

Fatal error: Call to a member function value() on a non-object in /var/www/oa2/profiles/openatrium/modules/contrib/entity/entity_token.tokens.inc on line 297 

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.

ar-jan’s picture

#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.

treksler’s picture

So 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.

treksler’s picture

Priority: Major » Critical
Issue summary: View changes

doesn't get any more critical than fatal errors that break your site

jetwodru’s picture

#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

justdave’s picture

jetwong98: that's correct, it doesn't have this in it, so you'll need to re-apply this patch after upgrading.

klonos’s picture

Lets help people coming to this issue by pointing the latest patch and hiding the rest.

NancyDru’s picture

Gosh, I had to re-discover this after updating to 7.x-1.3. Please commit it.

fenstrat’s picture

Confirming the patch in #44 is RTBC.

manuscle’s picture

The patch worked for me

firfin’s picture

Assigned: Unassigned » firfin
Status: Reviewed & tested by the community » Needs work

Probably 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

thumb’s picture

Status: Needs work » Reviewed & tested by the community

Applied to 2014-Jan-21 -dev version and it works as advertised :)

Sata’s picture

Applied patch 44 to
version = "7.x-1.3+4-dev"
core = "7.x"
project = "entity"
datestamp = "1390318420"

Worked perfectly! Thank you very much.

fago’s picture

Status: Reviewed & tested by the community » Fixed

Patch looks ok and seems to solve troubles for lots of people, thus committed, finally - thanks!

justdave’s picture

I'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.

ar-jan’s picture

@justdave: it was committed just after the 1.4 release, so it's not included.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

E Johnson’s picture

I 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.

  • Went back to Entity 7.x-1.2
  • Applied patch 44
  • Used the following tokens in my alias pattern: meetings/[node:field-meeting-date-time:0:value:custom:Y]/[node:field-meeting-date-time:0:value:custom:m]/[node:field-meeting-date-time:0:value:custom:d]/[node:title]

Hope that helps others from spinning their wheels here.

RaulMuroc’s picture

Since applied latest patch I cannot create any entity. I keep getting error:

EntityMalformedException: Missing package property on an element of type node. in entity_extract_ids () (line 7721 of / Users / raul.cabestany / sites / manner / brand / includes / common.inc).

markusd1984’s picture

Has 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.