Comments

ygerasimov’s picture

Here is patch with trailing spaces removal.

ygerasimov’s picture

Title: Taxonomy resource. Delete method argument type » Taxonomy resource. Port to D7
StatusFileSize
new3.47 KB

I have found a lot issues in taxonomy resource so I propose to join them all together here and have one patch that fix them all.

At the moment following fixes applied:
1. argument types in delete methods
2. _taxonomy_term_resource_retrieve: use taxonomy_term_load instead of D6 taxonomy_term_load
3. _taxonomy_term_resource_update: load vid of term in case it is not passed with argument
4. _taxonomy_vocabulary_resource_create: use taxonomy_vocabulary_save() instead of D6 taxonomy_save_vocabulary
5. _taxonomy_vocabulary_resource_delete: use taxonomy_vocabulary_delete instead of D6 taxonomy_del_vocabulary

gdd’s picture

Status: Active » Needs work
+++ resources/taxonomy_resource.inc
@@ -277,6 +279,12 @@ function _taxonomy_term_resource_create($term) {
+  if (!isset($term->vid)) {

This is the only part I have a question about. Is it really necessary? Drupal generally doesn't protect users from errors like this, and I kind of feel like if someone passes in a malformed term then that is their problem.

The rest of the patch looks good though

Powered by Dreditor.

gdd’s picture

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

Taxonomy resource is a mess. Here is a new patch that combines yuriy's changes with a rewritten permissions concept that is much more sane. As far as the piece I questioned above, I was talking in IRC about how we need a coherent way to deal with updates where the identifier in the body doesn't match the identifier in the path. Patch for that forthcoming.

gdd’s picture

StatusFileSize
new9.24 KB

New patch with less typos

kylebrowning’s picture

Patch looks good,

My one an only concern are things like this,
+ $vocabulary = (object) $vocabulary;

WE are typecasting through the entirety of Services and I believe its caused issue in the pass about struct vs array.

What are we doing about this? Should we define a standard for handling this, like, Everything we deal with should be an object, and converted to an array if necessary? Or everything should be an array and converted to an object if necessary?

It just seems to keep coming up and maybe this should be in another Task, but I just want to know what your thoughts are.

Edit: RE #3. I think its absolutely imperative that we try and mae the development experience of Services as easy to use as possible. Without it adoption will be extremely slow unless we have like the best documentation ever done on a drupal project. If we can do that great, but it might be easier to catch things like that in the long run.

ygerasimov’s picture

Regarding #3. I think we should keep helping user to form arguments properly. Why not?

I had tests that were running smoothly on my patch but now they fail in many places. I would like to ask to hold with committing this patch for couple of days. I will publish patch with test here.

ygerasimov’s picture

StatusFileSize
new26.46 KB

Here is patch with tests for taxonomy.

It depends on #1060124: Remove inheritance logic for relationships and actions.

ygerasimov’s picture

StatusFileSize
new26.48 KB

Patch rerolled against current HEAD.

bestenator’s picture

Hello ygerasimov, I'm a newbie with drupal, php and opensource software. I don't know if this is the metod to report bugs, so sorry if not is this.

I found a bug using taxonomy get terms, for example, trying http://myserver/my endpoint-rest/term/2 produce Fatal error: Call to undefined function taxonomy_get_term() in C:\wamp\www\sites\all\modules\services\resources\taxonomy_resource.inc on line 247

When Reading the taxonomy_resource.inc on line 247, there is a call to the function taxonomy_get_term() that not is in the 7.x version.

Thank you very much for your work!

ygerasimov’s picture

@bestenator yes, there are some functions in taxonomy resource that were not ported to D7. Please apply my patch above and check if the problem is still there.

bestenator’s picture

ygerasimov, great and quick! :-D . Aplying the #2 patch, this http://myserver/my-endopoint-rest/vocabulary/2 and this http://myserver/my-endopoint-rest/term/2 ARE OK!.

This http://myserver/my-endopoint-rest/node are OK but http://myserver/my-endopoint-rest/vocabulary and this http://myserver/my-endopoint-rest/term don't return results. It's must to return the collections of vocabulary and terms?. I'm not sure if this is a bug, because the index clausule in taxonomy vocabulary resource and the index clausule in taxonomy term resource not exist.

Thank you again!

kylebrowning’s picture

Status: Needs review » Needs work

Tests and patches look great, however the public function dsm($var) { probably needs to be moved elsewhere.

Do that and Ill commit

ygerasimov’s picture

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

@kylebrowning Thank you for the review. I completely agree on removing dsm().

ygerasimov’s picture

Resubmitting patch (previous didn't had actual test).

ygerasimov’s picture

@bestenator The proper urls to calls are http://www.example.com/endpoint/taxonomy_term/X and http://www.example.com/endpoint/taxonomy_vocabulary/X

There are no index calls for taxonomy_vocabulary or taxonomy_term so it not a bug. Please descibe in what case do you need index calls for these resources. If you need those calls please create separate issue for that.

Thank you for comments.

kylebrowning’s picture

Status: Needs review » Reviewed & tested by the community

Nice job, this is RTBC for me.

bestenator’s picture

Ok, I created two alias, one to vocabulary and another for terms, this is the reason form my urls...

I needed the index in term and vocabulary to expose to a client aplication the diferent values, for example of a term inside a vocabulary.

I thought that this was a functionality similar than "Get comments: GET /services/rest/node/123/comments"

I Understand that this must be a diferent issue.

Thank you very much!

gdd’s picture

Status: Reviewed & tested by the community » Needs work

This needs a reroll after recent commits. I made the changes but I am having trouble with the patch. Will get it up tomorrow, but I think it looks good. One thing I would like to see not just here but elsewhere is tests that assure users without access fail (in addition to that users with access succeed.)

ygerasimov’s picture

Status: Needs work » Needs review
StatusFileSize
new26.32 KB

Here is reroll of this patch.

ygerasimov’s picture

Oops. This patch is without CVS header.

gdd’s picture

Status: Needs review » Closed (fixed)

I finally committed this! Thank you ygerasimov for all the work.

kylebrowning’s picture

Yayy

kylebrowning’s picture

Yayy