/**
* Return the location of the spyc library, if any.
*
* @return the location of the spyc library, if it exists; else return false.
*/
function _rest_server_get_spyc_location() {
if (function_exists('libraries_get_path')) {
$libraries_spyc_loc = libraries_get_path('spyc') . '/spyc.php';
} else {
return false;
}
$services_spyc_loc = dirname(__FILE__) . '/lib/spyc.php';
if (file_exists($libraries_spyc_loc)) {
return $libraries_spyc_loc;
}
else if (file_exists($services_spyc_loc)) {
return $services_spyc_loc;
}
return false;
}If libraries_get_path doesn't exist this always returns false.
2 solutions:
---------------
- Remove the else with the return false
- Remove all the other code and make a dependency on the libraries module
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 1476788-spyc-detect-refactor.patch | 1.21 KB | cotto |
| #4 | 1476788-logic-error-4.patch | 987 bytes | aspilicious |
| #3 | 1476788-logic-error-3.patch | 987 bytes | aspilicious |
Comments
Comment #1
cotto commentedThat does look like a logic error. Thanks for reporting. If you have the tuits, a patch would be appreciated. Otherwise, it should be a pretty straightforward fix.
Comment #2
aspilicious commentedI'm going to patch this today. Just removing the else to prevent a dependency on libraries.
Comment #3
aspilicious commentedComment #4
aspilicious commentedThis one is better I think, we always have to ensure there is something in $libraries_spyc_loc, else we possible get notices when libraries is not installed.
Comment #5
marcingy commentedThe above patch looks good but to be honest that entire function could be refactored and cleaned up on a second look at the code I am happy for #4 to be committed but will try and role a follow up when I am at my desktop but basically
Comment #6
marcingy commentedActually patch in #4 will still give notices as it stands after further review of the code.
Comment #7
aspilicious commentedYour code looks good, push that and I'm happy :)
Comment #8
cotto commentedHere's a patch with marcingy's changes against 7.x-3.x. I've tested both with Libraries installed and with the conditional hard-coded to check for a non-existent function, both with and without the spyc library installed. All tests pass in all cases.
Comment #9
cotto commentedComment #10
aspilicious commentedTrailing whitespaces
On every line
Comment #11
marcingy commentedWhite space fixed and committed to d7, I believe this needs to be ported to d6.
Thanks to everyones help on this.
Comment #12
cotto commentedThe part of the Libraries api we use is the same between 6.x and 7.x, so I've cherry-picked the commit into 6.x-3.x. Unless something horribly breaks, we can call this closed. aspilicious, thanks for reporting.