Drupal Core Version: 7
Sandbox Project link: http://drupal.org/sandbox/jared_sprague/1866090
git repo: git clone http://git.drupal.org/sandbox/jared_sprague/1866090.git services_content_lock
Original Services Issue: http://drupal.org/node/1866136

Overview

This module exposes the main operations of content_lock through Services as a resource, so that content locking can be done over a web service API such as REST for mobile applications or thrid party integrations. The main operations it currently implements are retrieve, create, and delete.

Installation and Testing Video

Step-by-Step Instaillation and Testing Video (Best viewed in HD 720p)

Documentation

Services Content Lock Documentation

Reviews I've done

http://drupal.org/node/1846814#comment-7166712
http://drupal.org/node/1940684#comment-7170018
http://drupal.org/node/1191490#comment-7170236

Comments

jared_sprague’s picture

Issue summary: View changes

Adding section for review bounus reviews

theodorosploumis’s picture

Hi jared_sprague.

1. Pareview

pareview gives almost no errors. WARNING | Line exceeds 80 characters; contains 81 characters is pretty minor issue. So there are no errors from here.

2. Documentation

Move the documentation from the pdf file into Drupal Documentation pages. Write the documentation on the proper category for example at "Connecting to other Sites, System and Data" with a book node structure. This will make the documentation more useful and accessible for users as also as will leave space for comments, tips and proposals. See more at 5. of "Best practices for creating and maintaining projects".

3. Project page

Please move the "Dependencies" section after "Description", then show "Install" and finally show "Use Case Example".

You may, also, do the same on the README.txt

Generally, it is better if you can follow the D.O. "Tips for a great project page". According to this guide "Description" should be "Overview", ""Dependancies" should be "Requirements" etc.

4. services_content_lock.module

Please add translation support for strings. Lines 15, 25, 32, 42, 49, 59 of services_content_lock.module. You already did that for other functions of the module.

Example WITHOUT translation support:
'help' => 'Retrieves info about a lock',

Example WITH translation support:
'help' => t('Retrieves info about a lock'),

5. Coding Standards

Your code seems clean and well written.

Furthermore, try using a common coding style for quotes all over the module files. For example try using single quotes (') instead of double quotes (") except if necessary. See more at Coding Standards.

6. Drupal API

Function on line 35 of services_content_lock.inc can be written with a shorthand according to Drupal API db_select () documentation. Is there any reason you chose to split the functions?

function _services_content_lock_node_exists($nid) {
  $query = db_select('node', 'n')
          ->condition('n.nid', $nid, '=')
          ->fields('n', array('nid'))
          ->execute()
          ->fetchField();
  return !empty($query);
}
The only major problem with this module is that it is not easy to test it while working... and if you can supply a solution it would be great.
jared_sprague’s picture

Hi TheodorosPloumis!
Thank you so much for the review! I've completed the work on all the items you suggested, here they are listed:

Pareview

Fixed the few lines that were over 80 characters

Documentation

Moved the documentation here: http://drupal.org/node/1933330

Project page

Fixed up the project page and README.txt files per this suggestion.

services_content_lock.module

Adding missing t() functions.

Coding Standards

Now all quotes are consistent and only single quotes. Nowhere is double quotes required.

Drupal API

This was the only item I left unchanged. I was under the impression that this is the correct and secure way to use the database API.

Testing

Testing is actually very simple. All you need is a basic understanding of REST and CURL, access to a Bash Shell, and follow the installation steps above and use the example testing Bash scripts provided in the documentation here: http://drupal.org/node/1933330

Please let me know if you have any questions about testing!

Thanks!

jared_sprague’s picture

Issue summary: View changes

Added some install steps

jared_sprague’s picture

Issue summary: View changes

updated based on the review

theodorosploumis’s picture

I am back. I studied a little the Services API just to check the codes. Here are some minor issues and a propose.

1) Project page

- Remove the "Documentation Services Content Lock Documentation" section or make the link open on the same window (Drupal.org rules)
- Try to make all the links relative (Content style guide)

2) services_content_lock.module

- line 5 should probably go out. You only need @file and a description for the starting comment (the same for line 4 of .inc)
- lines 26, 60. Since path => 0 refers to an index its value needs no quotes. Althought it works right now the correct code should be:
'source' => array('path' => 0),
There is an issue for that actually, #1917432: Relationships' source arg (path) only accepts numeric values.

3) services_content_lock.inc

- There are some inline comments inside function (lines 43, 65, 106). This is probably a not good commenting method. You can move these comments out of the functions.
- You can shortcode the function on line 114 without problem. Drupal core blog for example does it already.

4) Local testing

- I tried to test it but had no luck. I do not know much about xml-rpc and REST and I always got errors like "Parse error. Request not well formed..." (with XML-RPC server) as also as Access denied for Anonymous user (with REST)...
Cookie is the sid on the {session} table of drupal installation? I think I am making the mistake with Cookie value on the example script.

By the way, you can export the endpoint you created for the documentation examples and attach the codes on these pages so the user can try with the same settings.

theodorosploumis’s picture

Issue summary: View changes

added testing section

jared_sprague’s picture

Hi TheodorosPloumis!
Thanks again for looking at my module! I've implemented all the suggestions so please do a git pull.You had some great suggestions, my responses below:
1) Project page
- Documentation link, no longer opens in a new window
- All links changed to relative links

2) services_content_lock.module
- removed the unnecessary lines from the top comment block of both files
- removed quotes from so it's now: 'source' => array('path' => 0),
Great catch!

3) services_content_lock.inc
- moved inline comments out of function arg list
- changed the db method to shorthand like suggested thanks!

4) Local testing
- I thought a lot about this. Setting up for testing REST services can be complicated and if you miss one step even slightly the whole thing won't work. So I decided to record a step-by-step video that walks through installing and testing this module from scratch.

Installation and Testing Video!

Step-by-Step Instaillation and Testing Video (Best viewed in HD 720p)

I also Added this video to the Project page.

Thank you for the tip about exporting the endpoint that was a great suggestion!

Let me know how the testing goes!

theodorosploumis’s picture

Status: Needs review » Reviewed & tested by the community

Everything works great now! The video is great!

My only concern is any security issues the examples folder may have but I do not know much about .sh files and REST. Probably there will be no issues but this can be tested by a Review admin.

theodorosploumis’s picture

Issue summary: View changes

changed link

jared_sprague’s picture

Issue summary: View changes

triming down

jared_sprague’s picture

Excellent!
Good point about the examples/ directory. I added a .htaccess file to that directory to prevent, indexes, file access, script execution of .sh files in that directory.

I also added a note to the Project page and README.txt that it's a good idea to delete that directory on production environments since it's not used.

jared_sprague’s picture

Issue summary: View changes

trimming down

jared_sprague’s picture

Issue summary: View changes

fix

jared_sprague’s picture

Issue tags: +PAreview: review bonus

I completed 3 reviews yay! So added the review bonus tag, hopefully since this is already RTBC it can get assigned to an admin now.

Thanks! :)

klausi’s picture

Status: Reviewed & tested by the community » Fixed

manual review:

  1. "t('Lock successfully created on node') . ': ' . $nid;": do not concatenate translatable strings with dynamic variables like that, use placeholders with t() instead. Also elsewhere.
  2. _services_content_lock_node_exists(): Do not use db_select() for simple static queries, use db_query() instead. See http://drupal.org/node/310075

But that are not application blockers, so ...

Thanks for your contribution, jared_sprague!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

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

Anonymous’s picture

Issue summary: View changes

added reviews