Closed (fixed)
Project:
Libraries API
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
15 Jul 2010 at 12:42 UTC
Updated:
2 Aug 2010 at 21:10 UTC
PHP deprecated call time pass by reference, but the module does this:
function libraries_detect($libraries) {
foreach ($libraries as $name => $library) {
libraries_detect_library(&$libraries[$name]);
}
return $libraries;
}
function libraries_detect_library(&$library) {
// ...
}
Basically it tries to avoid foreach copying the value and instead would like to get the original value to work with. We can do that much easier with PHP 5's foreach reference syntax, just need to move the &, so it becomes:
function libraries_detect($libraries) {
foreach ($libraries as &$library) {
libraries_detect_library($library);
}
return $libraries;
}
function libraries_detect_library(&$library) {
// ...
}
The attached patch does this. Foreach is capable to do this in PHP 5 and Drupal 7 already requires PHP 5, so I did not bother putting the PHP requirement into the .info file.
| Comment | File | Size | Author |
|---|---|---|---|
| avoid-call-time-pass-by-ref.patch | 663 bytes | gábor hojtsy |
Comments
Comment #1
sunThanks, looks good.
Comment #2
gábor hojtsyGreat :) Looking forward to the commit.
Comment #3
sunSorry, forgot to grant you access in #1. Could you just go ahead and commit? :)
Comment #4
sunBut also please note that #719896: Add a hook_libraries_info() still holds a follow-up patch, which will probably change key aspects of these new functions. Contributions, reviews, feedback, commits welcome.
Comment #5
tstoecklerCommitted the above patch. See http://drupal.org/cvs?commit=395090. (I feel very powerful right now :))
Thanks for the patch!