I think this is a bug, but I'm not sure.
I have a working API based on the services module for one year now. And today I started working on a second version.
I browsed through the code to find out how I should build my resource files in order to support different versions.
At the moment it works but I had to "hack" the services module.
Look at this function:
/**
* Returns currently set api version for an endpoint resource method.
*
* @param $endpoint
* A fully loadded endpoint.
* @param $resource
* A resource name.
* @param $method
* A method name.
* @return
* an array with the major and minor api versions
*/
function services_get_resource_api_version($endpoint, $resource, $method) {
if (isset($endpoint->resources[$resource]) ) {
$class_info = services_operation_class_info();
foreach ($class_info as $class_name => $class) {
if (!empty($resource[$class_name])) {
if (isset($endpoint->resources[$resource][$class_name][$method]['settings']['services']['resource_api_version'])) {
if($version = _services_version_header_options()) {
$split = explode('.', $version);
} else {
$split = explode('.', $endpoint->resources[$resource][$class_name][$method]['settings']['services']['resource_api_version']);
}
return array(
'major' => $split[0],
'minor' => $split[1],
);
}
}
}
}
}
It defines in it's docblock that "@param $resource" is a String, the name of the resource.
In my case it is "frontpage".
A few lines beneath that you'll see the following line
if (!empty($resource[$class_name])) {
I wonder how this can work as
- $resource is a string an not an array
- $classname can only be one of these: 'operations', 'actions', 'relationships', 'targeted_actions'
After removing that line everything seems to work, but I'm not sure if it causes any problems I can't think off.
Comments
Comment #1
aspilicious commentedComment #2
kylebrowning commentedThis is interesting.
I wrote that code a long time ago and can't seem to remember why.
Can you upload a patch with this change and set to needs review? If it passes I will commit.
Comment #3
aspilicious commentedI still wonder why I'm the first to report this :s
Comment #4
aspilicious commentedWhy is he patch postponed?
Comment #5
kylebrowning commentedIts not postponed, i think the issue is our current 7.x-3.x branch is failing.
Comment #6
aspilicious commentedDo you have an estimate time of arrival for the testbot fixes?
Comment #7
alejo ddon't need delete
just validate with
And at services/plugins/export_ui/services_ctools_export_ui.class.php
Line: 379
Replace the disabled to FALSE, so it can be saved and can be use the header version Services-User-Login-Version: 2.1
Comment #8
kylebrowning commentedPlease provide a patch.
Comment #9
alejo dhere is the patch to fix the version selector and use it
Comment #10
alejo dcan you see my patch ? its working very well :D
Comment #11
kylebrowning commentedComment #12
marcingy commentedMerged thanks!
Comment #15
kristiaanvandeneyndeThis introduced a notice. See #2585413: Notice: Undefined index: actions in services_edit_form_endpoint_resources() (line 377 of C:\...\sites\all\modules\contrib\services\plugins\export_ui\services_ctools_export_ui.class.php).
Comment #16
kristiaanvandeneynde