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.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | php-52-fix.patch | 1.55 KB | hargobind |
| #3 | php-52-fix-1880186-3.patch | 1014 bytes | Anonymous (not verified) |
Comments
Comment #1
douggreen commentedOops, 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.
Comment #2
kaizerking commentedthis 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
Comment #3
Anonymous (not verified) commentedpatched
Comment #4
johnvUsing 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)
Comment #5
johnvI 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).
Comment #6
praandy commentedHi,
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?
Comment #7
wwedding commented@johnv
Yeah, you're correct. It's more of the same issue, new PHP language functionality.
Comment #8
wwedding commentedPatch 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.
Comment #9
uccio commentedHi,
the packaged version of the module does not work with php 5.2.17
Comment #10
snehamay commentedI 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.
Comment #11
snehamay commentedwe 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.
Comment #12
hargobindConfirming 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.
Comment #13
hargobindOops, 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.
Comment #14
dineshw commentedThis works perfect! Patch tested and works fine!
Comment #15
jgullstr commentedI confirm #13 works.
Comment #16
technikh commented#13 worked for me. Thanks hargobind
Comment #17
hargobindWe've got three testers above saying it's RTBC. Would be nice to get this committed.
Comment #18
klausiCommitted, 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.