Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, remove-libraries.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
FileSize
40.76 KB

Status: Needs review » Needs work

The last submitted patch, remove-libraries.patch, failed testing.

ygerasimov’s picture

Status: Needs work » Postponed

I don't like the idea of removing these libraries. It will break the bot that we really don't like to do. In the next version of services we hopefully would be able to avoid these libraries by using Symfony components.

Moving the issue to postponed.

marcingy’s picture

Status: Postponed » Needs review

The point is more I don't believe these libraries should even be in the drupal repo - see http://drupal.org/node/422996

kylebrowning’s picture

Im kind of the same opinion. We just got our bot working and now its going to break again plus add an extra step to the install process.

I really don't mind continuing to apply patches for updates to these libraries, but I understand its a drupal rule to not put them in there.

marcingy’s picture

I agree it will be sad the bot won't work but given that we seem to be in violation of the rules for third party libraries I don't think we have any option
* had to be modified to work with Drupal and the modifications were not accepted by the original author. - I don't believe this is the case
* is generally difficult to find in the needed version. - Not at all links provided in the patch
* is no longer maintained by the original author. - The code seems to be maintained spyc certainly is.

ygerasimov’s picture

Status: Needs review » Needs work

If we decide to remove libraries we should have proper documentation in README.txt file.

@marcingy could you please add chapter for installation notes there.

marcingy’s picture

Before I do that do we have agreement that we are taking them out - because if there is no agreement I am not going to waste my time adding info to a readme file ;)

marcingy’s picture

FileSize
41.59 KB

Patch with install instructions

kylebrowning’s picture

Status: Needs work » Reviewed & tested by the community

Looks great!

marcingy’s picture

Status: Reviewed & tested by the community » Fixed
kevin.dutra’s picture

FWIW, I'd suggest that those libraries be installed (and looked for) under sites/all/libraries rather than in a directory in the module. This avoids the hassle of having to replace the libraries every time a module update is installed. ...Maybe even directly integrate with the LibrariesAPI (http://drupal.org/project/libraries).

kylebrowning’s picture

I noticed this today as well, and I tend to agree.

Patches welcome!

marcingy’s picture

Title: Remove third party libraries » Integrate services with the libraries module to improve handling of third paty libraries.
Status: Fixed » Active

No issue with me if we look to use the libraries project, yes it is an additional dependency but it makes logic sense because we are dealing with libraries after all.

dandirks’s picture

Here is a patch that adds Libraries API support for the YAML parser. Patch applies to D6 services 3.1.

Users will need to download spyc from http://code.google.com/p/spyc/downloads/list and put it in their sites/all/libraries/spyc folder.

dandirks’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Active » Needs review
kylebrowning’s picture

Status: Needs review » Needs work

Does libraries give the ability to require a dependency when certain conditions are met?

Do we need to remove the hook_requirments for the spyc library?

Also of note, the spyc is only needed for YAML so Id like to see this stuff only required when application/yaml response format is enabled in the Server Settings of the endpoint.

marcingy’s picture

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

This also needs to be against d7 as we backport from there.

rypit’s picture

I think the best approach is probably to use libraries api if it exists for all 3rd party libraries -- falling back to a hard coded or configurable location if it does not, and to keep all dependency checks in hook_requirements.

jobeirne’s picture

Status: Needs work » Needs review
FileSize
6.37 KB
6.41 KB

Attached is a patch that decouples spyc (and, for that matter, YAML) from rest_server. The patch looks in both the libraries location and the old location (lib/spyc); if it detects spyc in either location, it uses that. If it doesn't detect spyc, it removes YAML from the rest_server options cleanly.

This introduces a new dependency on libraries to rest_server. I think this is a preferable trade-off since we are no longer hard-wiring a dependency on spyc.

I'm attaching one patch that is git apply-able. The other ("spyc-decoupling-makeable-1325572-22.patch") works with Drush make. I have tested this patch for all cases described above.

kylebrowning’s picture

Status: Needs review » Needs work

omg jobeirne++++

It would be nice if this came with tests that verify things work with YAML

And after that id say commit and port to 6.x

jobeirne’s picture

Will do. Can I get commit access to add tests/update README, etc? I have plans to library-ize the rest of the dependencies as well.

kylebrowning’s picture

You shouldn't need commit access to provide a patch just as you have done.

jobeirne’s picture

No problem, so long as the commits are attributed properly.

marcingy’s picture

Can we have this all on one line rather than randomly split between 3 lines

+        'value' => $t('To enable YAML HTTP requets/responses, please download <a href="@download">spyc</a> '
+                      . 'and create a file called spyc.php in rest_server/lib or use Libraries to retrieve spyc.', 
+                      array('@download' =>  'http://code.google.com/p/spyc/downloads/list')),

An extra space has been introduced

-      'yaml' => array(
-        'mime types' => array('text/plain', 'application/x-yaml', 'text/yaml'),
-        'view' => 'RESTServerViewBuiltIn',
-        'view arguments' => array('format' => 'yaml'),
-      ),
+      

The doxygen should describe what a function does this does not

+
+/**
+ * Internal function.
+ *
+ * @return the location of the spyc library, if it exists; else return false.
+ */

Also this does not meet drupal coding standards.

+  if(file_exists($libraries_spyc_loc))
+    return $libraries_spyc_loc;
+  else if(file_exists($services_spyc_loc))
+    return $services_spyc_loc;
+  else
+    return false;
+}
jobeirne’s picture

> multi-line string
Drupal standards indicate 80col should be respected. The string was broken up to accomodate this.

> extra space
Oops.

> insufficient doxygen
The @return line pretty clearly indicates exactly what the function does. I'm not sure what else to tell you. As a side note, you should probably look into semi-colons and other forms of punctuation.

> "drupal coding standards"
I'm not sure how the body of that function "doesn't meet Drupal coding standards." Could you elaborate?

marcingy’s picture

The hard 80 column limit is only for doxygen and comments.

Internal function does not describe what it does, ther should a single line (under 80 characters) that provides a description of what the function does. @return should not be used for doing this.

With regards code standards please read http://drupal.org/coding-standards#controlstruct

jobeirne’s picture

From the link you posted above:

In general, all lines of code should not be longer than 80 chars.

There are no exceptions listed for strings or function calls that I have found.

As far as the control structures qualm, the standard does not mandate but only "strongly recommend[s]" braces.

Enjoy the patch.

marcingy’s picture

Status: Needs work » Closed (won't fix)

So the patch is not going to be committed as it stands plan and simple, and given your comments above that makes this a won't fix.

marcingy’s picture

To note the 80 character standards we introduced after drupal 7 was released - coding standards are not backwards comptable. Also core (in d8) continues to ignore the 80 character limit especially in areas such as t() and watchdog() the key is readability, hence the 'general' comment. In a similar way control structures also use {} for readability and to prevent breakages happening when code is amended.

jobeirne’s picture

Status: Closed (won't fix) » Needs review
FileSize
6.39 KB
6.43 KB

Alright, your changes have been made. Again, it'd be really nice if a non-patched Services could be used with programmatic builds. This patch allows that to happen.

marcingy’s picture

Thank for that - I'm happy with patch now, there are some minor code layout issues but I'll tidy those up when I do the commit rather than bikesheding the issue. @kylebrowning could the tests be a follow up? Or maybe we could ask @cotto to test as I know he uses yaml.

RobLoach’s picture

Just a note that lots has been going on in the Libraries API 2.x branch. Might be good to expose the yaml formatter in a separate module via rest_server_response_formatters_alter().

stovak’s picture

getting this error with the patch installed when turning on REST server.

Fatal error: Call to undefined function _rest_server_get_spyc_location() in /var/www/v4docs-dev.apigee.com/webapp/sites/all/modules/contrib/services/servers/rest_server/rest_server.install on line 15

If the rest server is not activated, you need to do a "module_load_include" or something to make sure the .module file is available to provide the function.

jobeirne’s picture

Ah, that's a big one. :)

I'll fix and re-roll.

jobeirne’s picture

Fixed. I tested an install on a clean instance of 7.

kylebrowning’s picture

Im fine with the tests as a later patch. this patch looks good to me and can be attributed to jobeirne with --author="jobeirne "

kylebrowning’s picture

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

I dont understand the differences between the patches though, which one would you like committed, also can you provide a 6.x patch as well?

jobeirne’s picture

Good news. One patch is apply-able with drush make, one is apply-able with git's apply. I don't know 6.x very well --- all of my dev experience is in 7; if lacking a 6.x patch is a deal-breaker, I can look into it.

RobLoach’s picture

Although I don't want to bike-shed the issue, I just wanted to point out that Drupal 8 is adopting some parts of Symfony. Considering that, it might be a good idea to switch over to Symfony YAML sometime. I've been putting some time into the Symfony module if you want to add some support for it in there itself.

kylebrowning’s picture

Yeah Drupal 8 services is going to be an entirely different thing with the wscci and all most of this probably won't matter to us at that point and services will just be a REST provider of some sort.

MrMaksimize’s picture

Hey Guys,

Not sure what the current status is here. Currently the 7.x-3.1 tag does not include the spyc.php library, and downloading it into libraries does nothing and still breaks the install. The patches seem to fail too.
Thanks!!

MrMaksimize’s picture

Oh wait never mind, saw the message on the project page. Sorry about that :)

BassistJimmyJam’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
6.56 KB
6.56 KB

If this module is being installed before the libraries modules has actually been enabled (such as from an installation profile) then libraries_get_path() will not be available when rest_server_requirements() is actually installed. I added a module_load_include() to rest_server_requirements() to ensure the function is available.

marcingy’s picture

Status: Needs review » Patch (to be ported)

This needs to be ported to d6 but is committed to d7. Thanks to everyone involved.

marcingy’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
jobeirne’s picture

The commit is appreciated, but in the future it'd be nice if you used proper attribution for the commit ("--author=...").

marcingy’s picture

Services use the approach of attribution as detailed in this issue which is the drupal standard - http://drupal.org/node/52287, comma seperated list of all those involved. Until the standard is use the --author this project will not do that.

kylebrowning’s picture

As an aside, i always apply git format-patch patches which include the author http://drupal.org/node/1146430

glennpratt’s picture

Status: Patch (to be ported) » Needs review
FileSize
6.52 KB

This patch seemed to apply to Git and tarball, so I skipped the makeable trend going in this thread.

kylebrowning’s picture

looks good.

kylebrowning’s picture

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

Status: Reviewed & tested by the community » Fixed

Fixed thanks guys!!!

Status: Fixed » Closed (fixed)

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

heshanlk’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Closed (fixed) » Needs review
FileSize
4.29 KB

Here is some recommended way to use Libraries module for Services module. This is against 7.x-3.x branch.

Status: Needs review » Needs work

The last submitted patch, 1325572-services-with-the-libraries-58.diff, failed testing.

marcingy’s picture

Status: Needs work » Fixed

This is already in d7

heshanlk’s picture

Status: Fixed » Needs review

The way it #58 currently implemented is the standard usage of the Libraries module, it should implement the hook_libraries_info() to compatible with the other library functionality like drush libraries and all the other. This patch may does the same but in proper way with hook_libraries_info(). Worth reviewing so changing to need review.

marcingy’s picture

Status: Needs review » Needs work

Ok that makes sense. The patch has a number of style issues with tabs being used insteda of spaces and obviously there is the problem with failing tests, but what the patch is doing conceptually looks good.

heshanlk’s picture

Status: Needs work » Needs review
FileSize
4.33 KB

Styles issues has been fixed.

Status: Needs review » Needs work

The last submitted patch, 1325572-services-with-the-libraries-63.diff, failed testing.

heshanlk’s picture

Status: Needs work » Needs review
FileSize
4.33 KB

With do not test flag, since MySQL failed.

heshanlk’s picture

Title: Integrate services with the libraries module to improve handling of third paty libraries. » Integrate services with the libraries module to improve handling of third party libraries.
kylebrowning’s picture

Status: Needs review » Needs work

Are tests currently failing? Why is this patch failing?

marcingy’s picture

Tests are failing but the only 6 failures seem to be occuring not 165 as here

mradcliffe’s picture

Status: Needs work » Needs review
FileSize
5.1 KB

The patch fails due to undefined function call because it was removed. It looks like the calls to the function should be removed and are not used anymore.

Let's see how it likes this.

Status: Needs review » Needs work

The last submitted patch, 1325572-services-with-the-libraries-69.patch, failed testing.

mradcliffe’s picture

Status: Needs work » Needs review
FileSize
16.38 KB

Do we have another test that can't pass pifr-only? :(

mradcliffe’s picture

I still only get 6 fails in another issue. Hmm...

kylebrowning’s picture

kylebrowning’s picture

Status: Needs review » Needs work

The last submitted patch, 1325572-services-with-the-libraries-69.patch, failed testing.

heshanlk’s picture

Status: Needs work » Needs review
kylebrowning’s picture

ITs failing because it doesnt apply cleanly.

heshanlk’s picture

Here is the new patch.

kylebrowning’s picture

Status: Needs review » Fixed
incaic’s picture

Think there's a typo in rest_server.install.

change

if (($library = libraries_load('spyc')) && !empty($library['loaded'])) {
...
}

to

if (($library = libraries_load('spyc')) && empty($library['loaded'])) {
...
}

so that the error message is shown only when spyc is not loaded?

heshanlk’s picture

Status: Fixed » Needs review

Good call.

kylebrowning’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

rszrama’s picture

Is it just me or was this change never actually documented? I can't see any mention of it in the README.txt, docs, or project page.

mradcliffe’s picture

It was in the 3.1 release notes, but it was hard to notice.

rszrama’s picture

I just reviewed the release notes again, and I still don't see it though I'm sure it's in an issue title or something.

For such a huge change, it would be good to provide information at the top of the release notes above the changelog indicating an API change has taken place. See for example how I outline major changes in Commerce release notes: http://drupal.org/node/1819278 (including the note about the Drupal >= 7.15 dependency)

I really think the project page should be updated to include mention of the dependency on Libraries. And anywhere that you talk about downloading Spyc.php to the REST server module's lib folder, should that not be replaced with a mention of the sites/all/libraries/spyc directory? Or perhaps I don't even know what Spyc.php is for, because I put it in the libraries directory and haven't had any problems yet.

Additionally, the project page should be updated to remove the outdated reference to http://drupal.org/node/1313976.

I'd really like to standardize on the Services module for sites needing to build Drupal Commerce REST web services, but I'm wondering if I should be more involved to ensure the product documentation and maintenance is more complete / stable for our end users. It would be disappointing to recommend a solution that might sneak API changes / dependencies into minor releases every now and then. : P

Would you like me to reopen this issue or perhaps post a follow-up for documentation?

rszrama’s picture

Another big API change came in #1154420: Readd support for rich options for resources - needed by auth mechanism that I completely missed, with the addition of an "operations" array as a wrapper around resource callbacks that wasn't there before. Ostensibly this is backwards compatible, because my test server never broke, but something like this should be declared in big letters at the top of a release. (Or better yet, relegated to a new branch of development.)

kylebrowning’s picture

Id open a new task for documentation.

Ill make betty release notes in the future documenting changes like this.

THe operations array will fallback on the original api version and that documentation exists here http://drupalcode.org/project/services.git/blob/refs/heads/7.x-3.x:/serv...

Libraries is only required for YAML response format to work.

rszrama’s picture

lol Ok, then I've been worried about it for nothing. Doing all my work with JSON. : P

rszrama’s picture

Ok, I see now the #api_version key, but I don't see anywhere where the differences in API versions are documented. Additionally, the docs do simply state that an operations array is required without any indication that the default API version in the absence of an #api_version parameter means that the operations array is not required.

I don't really think it's a great idea to have one hook with multiple response formats, but if you're going to do that, perhaps you should include two different doc blocks representing the format for the different versions of the API? Or at least some sort of inline notation about the differences.