I'm working on a project to use the migrate module to import data in a general fashion from one Drupal site to another. I'm looking at using Services 3 and rest_server to deliver the content from the source site. Naturally, the destination side (migrate module) needs to discover what content is available - i.e., it needs index actions on any data type to be migrated. Nodes and users are all set, but we also need indexing on taxonomy terms, comments, and files. I will see if I can provide a patch or patches (my first time with the Services API, please be gentle!).

Comments

mikeryan’s picture

Status: Active » Needs review
StatusFileSize
new23.53 KB

Easier than I thought! Here's a patch adding index support to vocabularies, terms, comments and files.

marcingy’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

Moving to 7.3 as we implement there and then backport. As there is a patch leaving at for review rather than marking as postponed.

kylebrowning’s picture

Status: Needs review » Needs work

This also needs to be done with git format-patch instead of cvs diff :P

marcingy’s picture

Assigned: Unassigned » marcingy

Grabbing as I'll work on this over the next couple of days

marcingy’s picture

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

Initial patch - lacking tests but I'm intrested on comments about the vocabulary index approach s I'm not sure if this is the right way to go or not.

ygerasimov’s picture

Status: Needs review » Needs work

Regarding taxonomy vocabulary index. I would even kept all information about fields not only about bundles. So to make it like

if ($field['module'] == 'taxonomy' && $field['settings']['allowed_values'][0]['vocabulary'] == $vocab->machine_name) {
  $vocab->bundles[] = $field;
}

But I don't know whether we really need that information in index method as it is quite specific. Maybe it is more reasonable to have it in retrieve.

Another point is not to use default values in callback arguments. So instead of

function _taxonomy_vocabulary_resource_index($page = 0, $fields = '*', $parameters = array()) {

should use

function _taxonomy_vocabulary_resource_index($page, $fields, $parameters) {

What I am thinking also is to use EntityFieldQuery to select objects as nearly everything now are entities. This will help to unify functions a lot.

And of course we need tests. Also please check formattings as some trailing spaces were introduced and tabs instead of spaces used.

marcingy’s picture

Status: Needs work » Needs review
StatusFileSize
new17.02 KB

New patch tidying up the issues above, and simplifying the vocab index as per irc. This patch also unifies the index building code. Still need to work on tests. Marking as needs review given the amends in this patch to how we build indes lists and queries.

marcingy’s picture

StatusFileSize
new17.02 KB

Typo

marcingy’s picture

StatusFileSize
new17.02 KB

Hopefully this time this is good.

marcingy’s picture

StatusFileSize
new17.02 KB

Wrong patch above.

kylebrowning’s picture

Status: Needs review » Needs work

This gets my vote, everything looks good to me. WE just need to write some tests for it.

ygerasimov’s picture

+ * Return an array of optionally paged cids baed on a set of criteria.

typo here

+  $comment_select = db_select('comment', 't')
+    ->orderBy('sticky', 'DESC')
+    ->orderBy('created', 'DESC');

I believe comments can't be sticky.

I really like idea with functions services_resource_build_index_list() and services_resource_build_index_query().

Is it reasonable to add tags to queries. For example add tag "node_access" to node index query and "comment_filter" to comment query.

And surely we need tests for these methods.

kylebrowning’s picture

StatusFileSize
new26.95 KB

updated patch, includes tests. still missing files tests, but i got al the other tests working.

kylebrowning’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs work » Patch (to be ported)
StatusFileSize
new30.85 KB

ok ive added all the tests, everything passes, heres updated patch, marking this as to be ported,

marcingy’s picture

Assigned: marcingy » Unassigned
marcingy’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Patch (to be ported) » Needs work

The patch committed has one issue in terms of style

if(isset($comment->nid))
  $node = node_load($comment->nid);

should be

if (isset($comment->nid)) {
  $node = node_load($comment->nid);
}
kylebrowning’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs work » Patch (to be ported)

Fixed

marcingy’s picture

The patch originally supplied should be good for 6.x.3.x of course this lacks the helper functions that were introduced in the 7 branch but functionally it looks good from reading assuming tests pass.

kylebrowning’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.