In coder_review.admin.inc, on line 61, a closure (inline or anonymous function) is used as the parameter for array_filter. This behaviour requires 5.3 according to the PHP docs (http://php.net/manual/en/functions.anonymous.php). Yet coder_review is not set up with a php version to indicate this and Drupal still functions with 5.2.

It would be good to either break this out into a proper function or add a php = 5.3 tag to the info file for coder_review.

CommentFileSizeAuthor
#13 php-52-fix.patch1.55 KBhargobind
#3 php-52-fix-1880186-3.patch1014 bytesAnonymous (not verified)

Comments

douggreen’s picture

Oops, thanks, I don't want to force 7.x to use PHP 5.3, so we should break it out to a separate function. Feel free to attach a patch, otherwise, I'll try to get to it soonish.

kaizerking’s picture

this is not fixed yet, can some one supply a patch for this
$links = array_filter(array_keys($form[$key]['links']), function ($var) {
this is the line needs to be changed to work with php 5.2

Anonymous’s picture

StatusFileSize
new1014 bytes

patched

johnv’s picture

Title: PHP 5.3 required for closures » Parse error: syntax error, unexpected T_FUNCTION in coder_review.admin.inc on line 61 (PHP 5.3 required for closures)
Priority: Normal » Critical
Status: Active » Needs review

Using PHP 5.2, Coder review throws this error message:
" Parse error: syntax error, unexpected T_FUNCTION in coder_review.admin.inc on line 61 "

Updating Priority to critical, since this breaks my site, and I cannot disable the module without hacking. (the error appears on the admin/modules page)

johnv’s picture

I guess the following error are of the same type:

Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in coder_review_page_form() (line 552 \coder\coder_review\coder_review.module).

Warning: require_once(/coder_review.common.inc) [function.require-once]: failed to open stream: No such file or directory in coder_review_page_form() (line 552 of \coder\coder_review\coder_review.module).

praandy’s picture

Hi,
I resolve the problem in coder_review.module on line 522 with this substitution:
-require_once realpath(__DIR__) . '/coder_review.common.inc';
+require_once drupal_get_path('module', 'coder_review') . '/coder_review.common.inc';

Could it be a good solution?

wwedding’s picture

@johnv

Yeah, you're correct. It's more of the same issue, new PHP language functionality.

wwedding’s picture

Status: Needs review » Reviewed & tested by the community

Patch applied fine for me and it's been sitting here for a while. Could be worth checking for additional instances since other PHP 5.3 things slipped in.

uccio’s picture

Hi,

the packaged version of the module does not work with php 5.2.17

snehamay’s picture

Assigned: Unassigned » snehamay

I have a solution to avoid this error for those who are using PHP 5.2 and above:

First create a custom function same as below:

function return_var($var) {
return $var && $var[0] != '#';
}

After that modify the foreach loop by specifying the call back function name "return_var"

foreach ($children as $key) {
$links = array_filter(array_keys($form[$key]['links']), "return_var");
if ($links) {
$operations += drupal_map_assoc($links);
}
}

Hope the above solution will help you.

snehamay’s picture

we can just use "require_once 'coder_review.common.inc';" to avoid this error, because the file "coder_review.common.inc" is there in the same directory.

hargobind’s picture

Version: 7.x-2.0-beta1 » 7.x-2.x-dev

Confirming that the patch in #3 works as advertised. I'm switching this issue to the 2.x-dev version, but it applies to 2.0-beta2 as well (and the code for both is the same). Keeping the issue marked as critical priority because it will WSOD any site that's running PHP 2.9 or prior which is kind of a big deal.

hargobind’s picture

StatusFileSize
new1.55 KB

Oops, spoke too soon. I ran into the "require" issue as well. The change suggested in #11 fixes it. Here's a new patch which includes both #3 and #11.

dineshw’s picture

Issue summary: View changes

This works perfect! Patch tested and works fine!

jgullstr’s picture

I confirm #13 works.

technikh’s picture

#13 worked for me. Thanks hargobind

hargobind’s picture

We've got three testers above saying it's RTBC. Would be nice to get this committed.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Coder Review is a bit lagging behind and has been removed from 8.x-2.x. Coder Sniffer is recommended to check your code. But since it also seems this does not hurt either I went ahead and committed it.

  • klausi committed 0e52162 on 7.x-2.x authored by hargobind
    Issue #1880186 by hargobind, rsmylski: PHP 5.2 legacy compatibility:...

Status: Fixed » Closed (fixed)

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