Heres the first patch at this attempt.

Can be found here. http://drupalcode.org/project/services.git/shortlog/refs/heads/feature/h... as

2 things have been added
The ability to set a default resource version. The idea is, you can change the version that is returned if no version is supplied. SO if you wanted to release a 1.0 api, the best idea is to clone your endpoint, name it endpoint 1.0 and don't ever change it, This will assure your clients won't break. Heres the documentation i wrote explaining it, hopefully someone can help me word it a little bit better.

* All functions that want to be considered for updates need to use a specific naming convetion
* WE took the same approach as the standard Drupal hook_instal and .install methods.
* For clients that want to request a specific version they need to pass a certain header
* services_RESOURCE_METHOD_version = version
* as an example, services_system_set_variable_version = 1.2
* Services by default will always use the originl resource shipped
* with services. If you wish to change this you can goto the resource page,
* and select an api version for the specific resource. The version option will
* only be enabled if version changes exists

Comments

Status: Needs review » Needs work

The last submitted patch, 0002-Fixes-for-historical-resources.patch, failed testing.

kylebrowning’s picture

Status: Needs work » Needs review
StatusFileSize
new20.69 KB

heres one patch.

Status: Needs review » Needs work

The last submitted patch, 0001-historical_resources.patch, failed testing.

kylebrowning’s picture

Status: Needs work » Needs review

#2: 0001-historical_resources.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 0001-historical_resources.patch, failed testing.

kylebrowning’s picture

Status: Needs work » Needs review

#2: 0001-historical_resources.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 0001-historical_resources.patch, failed testing.

kylebrowning’s picture

I guess the tests are breaking soo ill try and fix those.

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new20.26 KB

In services_get_updates do we want a real cache as well as a static cache? - otherwise looks sensible as it does what core does with its updates :)

In services_get_update_versions I don't like the use of

extract($update);

bit too 'magic' I would rather we did, I haven't updated this until we discusss

$value = $update['major'] .'.'. $update['minor'];

Do we want to add an option at the server level to disable versioning have added - not sure the best way to deal with it when we are in _services_build_resources - I think this important so as sites aren't forced to run versioning (maybe we make the variable global which would simplify things.)

  if (variable_get('services_rest_service_versioning_enabled', TRUE) {

I can't think of a better way to do the actual version call because of where it needs to happen? No matter what a server is going to need to add a new call to get versioning.

Again in services_request_apply_version can we avoid extract?

In services_request_apply_version if this is true can we stop processing so throw the rest in an if statement?

if (isset($version) && $version == '1.0') {
  $controller = $controller['original'];
}

New patch attached.

Status: Needs review » Needs work

The last submitted patch, historical-updates.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new20.08 KB

can't see a syntax issue locally.

Status: Needs review » Needs work

The last submitted patch, historical.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new20.2 KB

This should fix all exception simplification of Kyle's change

Status: Needs review » Needs work

The last submitted patch, historical-2.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new20.49 KB

And some other notices

Status: Needs review » Needs work

The last submitted patch, historical-3.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new20.5 KB

Check if we have a $method before processing.

Status: Needs review » Needs work

The last submitted patch, historical-4.patch, failed testing.

marcingy’s picture

Issue tags: +Needs tests

Adding needs tests tag because it does.

marcingy’s picture

StatusFileSize
new21.17 KB
marcingy’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, historical-5.patch, failed testing.

marcingy’s picture

StatusFileSize
new21.17 KB

So the method does exist - bit wtf, lets try changing the assert which is strange in the first place as the logic is reversed.

marcingy’s picture

Status: Needs work » Needs review
boombatower’s picture

Will my example module work with this patch (no API changes right?)? I hope to try it out sometime this weekend.

kylebrowning’s picture

I think theres a few API changes from the services_historical method of doing things, BUT they dont conflict, your module will continue to work.

marcingy’s picture

boombatower's example module may well be the way to go as a basis for a test :) We know that it should work therefore if we have a test then we should be able to spot the bugs.

kylebrowning’s picture

StatusFileSize
new38.68 KB

Heres an updated patch with tests and some fixes that resulted from those tests :P

kylebrowning’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)
kylebrowning’s picture

Issue tags: -Needs tests

It has tests :P

damien tournoud’s picture

Title: Ability to version a resource. » Ability to version a resource
Version: 6.x-3.x-dev » 7.x-3.x-dev
Category: feature » bug
Priority: Normal » Critical
-    $resource['endpoint'] = $cres;
+    $resource['settings'] = $cres;

This is an API change (and a significant one). It broke a couple of things in Services itself:

    foreach ($resources as $key => $def) {
      if (!empty($def['endpoint']['alias'])) {
        $aliased[$def['endpoint']['alias']] = $def;
      }
      else {
        $aliased[$key] = $def;
      }
    }

^ The alias feature doesn't work at all anymore.

  if (isset($method['endpoint']['services_oauth'])) {
    $endpoint += array_filter($method['endpoint']['services_oauth']);
  }

^ I haven't tested, but I suppose it completely broke per-resource oauth settings too?

kylebrowning’s picture

Status: Patch (to be ported) » Active

Wow great find. I guess we dont have test coverage for alias'

Ill write a test and a patch but I wont be able to get to it till tomorrow.

damien tournoud’s picture

StatusFileSize
new38 KB

This is a revert patch, just so that I can target it in a make file.

I think this patch should be reverted until its impact in terms of API change are figured out. Changing a datastructure that can be consumed or altered by other modules inside a stable is an API change that is not welcome in a stable branch.

kylebrowning’s picture

I mean, its not THAT big of a deal, itll just go back to being called "endpoint", which makes no effin sense whatsoever.

marcingy’s picture

After Damien's comment I am wondering if this patch should be reverted and a 4.x branch opened with this patch applied. I am not doing anything myself as I not really active as a maintainer on the services project at the moment beyond reviewing simple patches and bug reports due to lack of time.

kylebrowning’s picture

Assigned: Unassigned » kylebrowning

I dont believe it requires a rollback because the specific changes I mmade hes referring to was cleanup I did to make things make more sense. I didnt realize its tehcnically an API change at the time but I totally see why it is now.

Ill fix it.

mradcliffe’s picture

ServicesWebTestCase::setUp argument handling changed in this patch as well. Darn. Now it will be a bit more difficult to sub class my sub class of that and pass in modules to enable.

kylebrowning’s picture

mradcliffe we can move it back to the old way, I did that to speed up things and I left it in there. Fuck.

Once again Ill take care of it. Sorry for the wait. Would everyone prefer that i revert this until it is better?

mradcliffe’s picture

I can create a different issue so that it's separate from this one. I wasn't sure how critical the change to setUp was.

ygerasimov’s picture

Status: Active » Needs review
StatusFileSize
new4.16 KB

Here is the patch that reverts

-    $resource['endpoint'] = $cres;
+    $resource['settings'] = $cres;

and adds test for alias functionality.

kylebrowning’s picture

ygerasimov, did you verify that setting an alias in the interface works? WHen i did that exact change, I couldnt get it to work.

EDIT: these tests only cover if its perfectly set in the endpoint storage. But if you goto the ctools page, it doesnt seem able to save.

ygerasimov’s picture

Status: Needs review » Needs work

kylebrowning, you are right. I also have difficulties with ui. Will check it out.

kylebrowning’s picture

Status: Needs work » Needs review
StatusFileSize
new3.4 KB

Hers a new patch. lets see if it passes.

This fixes aliases , and reverts it back to 'endpoint' from 'settings'

kylebrowning’s picture

Woops, heres both patches.

kylebrowning’s picture

Status: Needs review » Needs work

bah, those are bad one sec.

kylebrowning’s picture

Status: Needs work » Needs review
StatusFileSize
new12.35 KB

Alright one more try.

kylebrowning’s picture

StatusFileSize
new13.4 KB

And another to fix the tests.

ygerasimov’s picture

Well done! Here is patch from #47 with some minor code style fixes. If tests pass it is RTBC to me.

ygerasimov’s picture

Status: Needs review » Reviewed & tested by the community
marcingy’s picture

Status: Reviewed & tested by the community » Needs work
+ *  Update the current user logout callback to the new callback with a better return value.
+ */
+function _user_resource_logout_update_1_1() {

Missing empty line.

Also does this patch solve the issue original brought up by damz

ygerasimov’s picture

Assigned: kylebrowning » Unassigned
Status: Needs work » Needs review
StatusFileSize
new11.83 KB

Yes, patch solves issue brought by Damien.

Here is updated patch to add empty line.

kylebrowning’s picture

Status: Needs review » Fixed
kylebrowning’s picture

Now the question. Do we backport?

ygerasimov’s picture

Woo-hooo! Great commit Kyle!

I don't want to volunteer to backport this patch.

kylebrowning’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Category: bug » feature
Status: Fixed » Active

Going to port this soon.

kylebrowning’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Active » Closed (fixed)

Im not going to port this, its too much work for something thats going to be dropped when 8.x comes out. If someone wants to take a stab, go ahead.

boombatower’s picture

Dropped completely or what do you mean by dropped?

kylebrowning’s picture

When 8.x comes out I don't plan on supporting 6.x

I may still back port it but it won't be anytime soon and I didn't wanted to hold up another release. This is working in 7.x though

kylebrowning’s picture

And historical endpoints still work with your code

boombatower’s picture

I thought you meant the historical api was going to be dropped from a 8.x services.