After updating to 7.x-1.4 the following String warning is logged:

Strict warning: Only variables should be passed by reference in ctools_entity_from_field_context() (line 179 of ctools/plugins/relationships/entity_from_field.inc).

Comments

damienmckenna’s picture

StatusFileSize
new1.05 KB

This resolves the problem by storing an array in a variable before its passed to array_shift().

damienmckenna’s picture

Status: Active » Needs review
jaydarnell’s picture

I don't know much about patches. I've applied a couple over the last few years but I've never written one. When is it safe to say that a patch is good to go? Can I apply this now?

damienmckenna’s picture

Please follow the instructions on this page to apply the patch: https://drupal.org/patch/apply

jaydarnell’s picture

Hi Damien,

I actually have git. I've downloaded the patch. Would I simply want to place it in the ctools directory, navigate to that directory and issue the command: git apply -v [patch-name.patch]

Or does it not matter where the patch file is physically located when issuing this command?

Thanks!

damienmckenna’s picture

In order to apply the patch you have to 'cd' to the appropriate directory, i.e. the sites directory, then just make sure you provide the proper path to the patch - you can drag 'n drop the patch file to your command prompt / terminal if that makes it easier.

Soos’s picture

CopperBot: I encountered this bug when I was doing a tutorial today and applied the patch in the video: http://www.youtube.com/watch?v=3stsc2BQj6s in 4:05. Hope that helps!

damienmckenna’s picture

Issue tags: +PHP 5.4

Tag.

czigor’s picture

Status: Needs review » Reviewed & tested by the community

The patch works great and since it is pretty straightforward I mark this as RTBC.

Ravenight’s picture

Status: Reviewed & tested by the community » Needs review
Related issues: +#2195211: Warning after update: Missing argument 4 for entity_metadata_taxonomy_access

The patch #1 here didn't solve the issue with commerce, however, as @maximpodorov pointed out, the issue #2195211: Warning after update has a patch that did solve this issue when coupled with the patch here.

The issue comes down to this line:
if (function_exists($to_entity_info['access callback']) && !call_user_func($to_entity_info['access callback'], 'view', $loaded_to_entity)) {
and is fixed in the other issue with:
if (function_exists($to_entity_info['access callback']) && !call_user_func($to_entity_info['access callback'], 'view', $loaded_to_entity, $account, $to_entity)) {

Since the original patch did not solve the problem, I am marking this back to "needs review".

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

This issue has nothing to do with Commerce, putting the status back the way it was.

damienmckenna’s picture

@ravenight: Just to be clear, this issue is limited in scope to a very small bug, it has nothing to do with the bug related to entity_metadata_taxonomy_access, or anything else, it is just this one small bug. The patch above fixes this one problem, it does not need to solve any other problem, so the status of other bugs has no bearing on this patch.

Please do not change the status unless you know of a reason why the patch does not solve the problem described in the issue.

mudderklirren’s picture

First post on Drupal.org :-)
I needed to combine this patch with https://drupal.org/node/2195211, so I have complied both patches, and git diff'et to this file.

It is for 7.x.1-4

joecanti’s picture

After addingthis patch, the strict warning goes, but I get this error:

Notice: Undefined index: access callback in ctools_entity_from_field_context() (line 181 of /home3/alphasa1/public_html/sites/all/modules/ctools/plugins/relationships/entity_from_field.inc).

Any ideas?

Many thanks, Joe

q11q11’s picture

#14 is not combined completely, warning about 4 parameters still remains, so I`m making another one

maximpodorov’s picture

Why do you combine patches for different issues?

mrharolda’s picture

Hiding combined patches to prevent confusion.

drupov’s picture

Patch from #1 made the strict warning disappear for me.

nikolay shapovalov’s picture

I've same issue using entity refernce as context in panels.
After pacth apply all warnings disappear.

manuelBS’s picture

This patch works for me, too

ergophobe’s picture

Works for me

eric_a’s picture

Issue tags: +Needs reroll

#2195211: Warning after update: Missing argument 4 for entity_metadata_taxonomy_access went in, and the bonus coding standards fix in #1 conflicted with that fix, so I'm pretty sure this needs rerolling now.

eric_a’s picture

1: ctools-n2195471-1.patch queued for re-testing.

eric_a’s picture

Well, it still passes here because for some reason the d.o. bot is currently testing against the 7.x-1.4 release.

Output: [18319cd Require ctools 1.4].

If it keeps doing that then a re-rolled patch against a 7.x-1.x checkout would fail...

czigor’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
czigor’s picture

1: ctools-n2195471-1.patch queued for re-testing.

The last submitted patch, 1: ctools-n2195471-1.patch, failed testing.

eric_a’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs reroll
StatusFileSize
new923 bytes

Ah, thanks!

Rerolled patch attached.

eric_a’s picture

Green! @czigor, can you take a look and RTBC this once more?

czigor’s picture

Status: Needs review » Reviewed & tested by the community

Works and also looks good and trivial.

damienmckenna’s picture

The patch in #1 still applies to the 7.x-1.x branch.

damienmckenna’s picture

1: ctools-n2195471-1.patch queued for re-testing.

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new923 bytes

Patch #1 with a new filename.

The last submitted patch, 1: ctools-n2195471-1.patch, failed testing.

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Oh. Wait.

*cleans glasses*

Yes, sorry, Eric_A's patch was correct.

eric_a’s picture

Patch in #34 passed because it's a renamed #29, not a renamed #1. :-)

And #1 does not apply anymore but it does apply against the current 7.x-1.x-dev build, which is 7.x-1.4+1-dev and needs rebuilding to 7.x-1.4+2-dev to sync with latest 7.x-1.x.

I did a simple reroll, commit credit goes to @DamienMcKenna!

damienmckenna’s picture

@Eric_A: yeah, I blame not cleaning my glasses for mixing up my patch in #1 with yours in #29. Or something. *whistles innocently* Sorry about that.

bjlewis2’s picture

#29 works for me too!

japerry’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

markbannister’s picture

OK confused, using 7.x-1.4 and the patch fails.

jaydarnell’s picture

I made the same mistake markbannister. This patch is not for 7.x-1.4. It is for 7.x-1.x dev (I believe)

When I downloaded the patch and looked at it the line numbers didn't match up with 7.x-1.4. I hope this is fixed with a new release (7.x-1.5) soon. I don't like having such an important module on my life site with a security vulnerability but I can't exactly go with 7.x-1.4 (due to this error message) and I'm not about to put a dev copy on my live site either.

That being said thank you to all the parties involved in working on this module.

mrharolda’s picture

It's a strict warning, not a security error or such. And it's also generally advised to not display warnings on a live/production site.

If the patch won't apply (usually line numbers don't have to be exact), just edit the file yourself if you really can't stand the warning.

boobaa’s picture

StatusFileSize
new912 bytes

Attaching a patch that cleanly applies to 7.x-1.4 – and of course it solves the problem: there's no warning any more.

mudderklirren’s picture

Update to my comment #14

Issue n2195211 address some issues with Entity entity_metadata_user_access and this issue addresses ctools_entity_from_field_context - both patches are for the same file in ctools/plugins/ and when trying to apply both it fails - thats the reason for this patch - overlapping linenumbers.

mudderklirren’s picture

And third update (this IS my first patch on Drupal) - now with a file actually working, combining the overlapping issues from n2195471 and n2195211

damienmckenna’s picture

It's recommended that everyone use the -dev release until the next stable release can be rolled out, there's no need to keep rerolling patches.

q11q11’s picture

@mudderklirren, you made exact patch that i did in #16, but with one syntactis mistake, no space after last "if"

jaydarnell’s picture

It was my understanding it is never recommended to use dev copies of a module on a production site DamienMcKenna.

damienmckenna’s picture

@CopperBot: There's little difference IMHO between using a -dev copy vs applying a bunch of patches, but YMMV. I don't think I've ever launched a Drupal site that didn't have at least a handful of -dev modules.

smira’s picture

Hey @DamienMcKenna, just curious to know a potential timeline for a stable release that will include this fix?
Thank you for all your hard work here!
-Miro

damienmckenna’s picture

@smiro: As I'm not a comaintainer of CTools I cannot answer that question. Sorry. In the meantime you should be safe running the latest -dev release, I've used it on some production sites without any problems.

jvinci queued 29: ctools-n2195471-29.patch for re-testing.

The last submitted patch, 29: ctools-n2195471-29.patch, failed testing.

jvinci’s picture

For the record: #47 worked for me as applied to ctools 7.x-1.4.

Thanks everyone.

juanramonperez’s picture

I fixed changing this line (ctools 7.x-1.4)

$loaded_to_entity = array_shift(entity_load($to_entity, array($to_entity_id)));

for this ones

$loaded_to_entity = entity_load($to_entity, array($to_entity_id));
$loaded_to_entity = array_shift($loaded_to_entity);

Only variables should be passed by reference

http://php.net/manual/es/function.array-shift.php

mrharolda’s picture

@juanramonperez, just use the 1.5 version of Ctools, it has this fix in it.

juanramonperez’s picture

@MrHaroldA sure I will. thanks.