Reviews of other projects

http://drupal.org/node/1400086#comment-5590504
http://drupal.org/node/1423362#comment-5624952
http://drupal.org/node/1416752#comment-5624916
http://drupal.org/node/1390218#comment-5624884
New: Below reviews: On Feb 29th, 2012
http://drupal.org/node/1426386#comment-5670738
http://drupal.org/node/1431424#comment-5670808
http://drupal.org/node/1399684#comment-5671004
http://drupal.org/node/1281690#comment-5671138
http://drupal.org/node/1447752#comment-5671246

Description:

The googlebook module (for Drupal 7) is a filter module and an API for the http://books.google.com, that allows a user to insert rich Google Book data into nodes via filters with data retrieved from the http://books.google.com domain.

The user of this filter module will be able to easily insert:

  • book data from Google into pages using Drupal filters, There are options to include / exclude any data fields,
  • a book cover image when it exists
  • and for books with a full or partial preview, the Google book reader for the volume.

The starting framework of the code was based on the Book Post module to get ideas which gets data from Open Library instead of the Google Books API although little remains of that module other than the framework. The googlebook module API is different based on the data returned as well as the final aims of the module, although they do both return book data. The Google Book module can output a page image as well as the built in book reader from Google.

There are many search options with Google books and many options to display that data within the Google Book module.

Link to Google Books module project page

http://drupal.org/sandbox/darrellulm/1372154
Promoted to full module at: http://drupal.org/project/google_books

A direct link to Google Books git repository

Git page link: http://drupal.org/node/1372154/git-instructions/7.x-1.x/nonmaintainer

Git instructions:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/darrellulm/1372154.git googlebook

Link to running demo of module

http://superpowerplanet.com/content/drupal-google-book-filter-module

How to use the inline options

In line display options to override the global Google Book filter settings can be made by options after the search string. The format for the search strings and options are:

Use global display options:
[google_book: search string]

In line options always come after the search string and are separated by a vertical bar, i.e. a '|' character.
[google_book: search string | option 1 | option 2 | option 3 | ... ]

Options to include are just used normally, like 'worldcat' while options to exclude in the display are prefaced by the 'no_' prefix.

Example:
[google_book: The Hobbit | no_librarything | no_image | viewer | title | no_description]

These are the content options:

  • worldcat / no_worldcat
  • openlibrary / no_openlibrary
  • librarything / no_librarything
  • pagecurl / no_pagecurl
  • titlelink / no_titlelink
  • image / no_image
  • reader / no_reader

Also each an every data field can be turned on or off overriding the Google Books filter global default.

The in_line field settings are below

  • kind
  • id
  • etag
  • selfLink
  • volumeInfo
  • title
  • authors
  • publisher
  • publishedDate
  • description
  • industryIdentifiers
  • type
  • identifier
  • pageCount
  • dimensions
  • height
  • width
  • thickness
  • printType
  • mainCategory
  • categories
  • averageRating
  • ratingsCount
  • contentVersion
  • imageLinks
  • smallThumbnail
  • thumbnail
  • small
  • medium
  • large
  • extraLarge
  • language
  • previewLink
  • infoLink
  • canonicalVolumeLink
  • saleInfo
  • country
  • saleability
  • isEbook
  • listPrice
  • amount
  • currencyCode
  • buyLink
  • accessInfo
  • viewability
  • embeddable
  • publicDomain
  • textToSpeechPermission
  • epub
  • acsTokenLink
  • accessViewStatus

Contact Darrell Ulm if you need any information on this module at:
http://drupal.org/user/46284/

Comments

natemow’s picture

Status: Needs review » Needs work

Automated review:

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

  • Remove "project" from the info file, it will be added by drupal.org packaging automatically.
  • googlebook.module in googlebook.info: It's only necessary to declare files[] if they declare a class or interface.
  • ./googlebook.module: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming
    function filter_googlebook_tips( $filter, $format, $long = FALSE ) {
    function make_html_link( $address ) {
    function set_param( $params, &$flag_var, $value, $set ) {
    function add_googlebooks_javascript() {
    function add_googlebooks_viewer_inline( $isbn ) {
    
  • ./googlebookapi.module: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming
    function bib_field_array() {
    function get_googlebook_data( $id, $version_num ) {
    function json_extract( & $barr ) {
    function assign_bib_array( & $bib_array, $index, $value ) {
    function get_googlebook_version_count( $id ) {
    function clean_search_id( $id ) {
    
  • Run coder to check your style, some issues were found (please check the Drupal coding standards). See attachment.

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Go and review some other project applications, so we can get back to yours sooner.

Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards

sites/all/modules/pareview_temp/test_candidate/googlebook.module:
 +315: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
 +329: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
 +360: [minor] There should be no trailing spaces

Status Messages:
 Coder found 1 projects, 1 files, 3 minor warnings, 0 warnings were flagged to be ignored
ERROR: the "DrupalCodingStandard" coding standard is not installed. The installed coding standards are MySource, PEAR, Zend, Squiz and PHPCS
natemow’s picture

Issue summary: View changes

Took out link that was not useful.

darrell_ulm’s picture

Status: Needs work » Needs review

Made the changes to formatting and repositories as indicated in feedback. Thank you.

natemow’s picture

Status: Needs review » Needs work

Looking better...still a few issues found.

Automated review:

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Go and review some other project applications, so we can get back to yours sooner.

Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards

sites/all/modules/pareview_temp/test_candidate/googlebook.module:
 +103: [minor] Use an indent of 2 spaces, with no tabs
 +319: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
 +333: [minor] in most cases, replace the string function with the drupal_ equivalent string functions

Status Messages:
 Coder found 1 projects, 1 files, 3 minor warnings, 0 warnings were flagged to be ignored
darrell_ulm’s picture

Status: Needs work » Needs review

OK, master is cleared out all but README, and I replaced the string functions with drupal_string

When testing at http://ventral.org/pareview/httpgitdrupalorgsandboxdarrellulm1372154git-...
Everything came up clear, i.e. no errors.

Local tests with the coder module also came up clear.

Thanks!

-Darrell

misc’s picture

I tested it and worked as described. Did a manual review of the code, and it looks correct. So for me it is thumbs up.
EDIT: Just to be clear, did not find any security issues, and could not find a similar module for drupal 7 that does the same thing. Code is well written and uses drupal functions, and is well documented.

darrell_ulm’s picture

Status: Needs review » Reviewed & tested by the community

MISc,

Thank you! Much appreciated!

darrell_ulm’s picture

MISc,

By the way, what is the next step?

Thanks in advance!

misc’s picture

Next step is, if no other reviewer here thinks otherwise, is to be granted git acces to grant full project release by one of the Git administrators.

darrell_ulm’s picture

MISc,

Sounds good. Thanks again!

klausi’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.56 KB

The following git branches do not match the release branch pattern, you should remove/rename them. See http://drupal.org/node/1015226

* 7.x-1.x-dev
  remotes/origin/7.x-1.x-dev

Review of the 7.x-1.x-dev branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

manual review:

  • googlebookapi.install: remove the copyright notice, all code on drupal.org is GPL anyway + downloadable tarballs get an extra LICENSE.txt file. Also in the other files.
  • googlebookapi_uninstall(): empty function, so remove it.
  • googlebookapi_get_googlebook_data(): for documenting function parameters you should use the @param syntax, see http://drupal.org/node/1354#functions . Also on other functions.
  • "json_decode($bookkeys, TRUE);": you should use drupal_json_decode() instead. Also elsewehere.
  • googlebookapi_get_googlebook_data(): $obj is a bad variable name, use something more descriptive, e.g. $cached_books, $cache etc.
  • googlebookapi_get_googlebook_version_count(): useless docblock, please at least explain the function in one sentence. Also elsewhere.
  • "'#title' => 'Google Book Data Fields',": all user facing text should run through t() for translation. Please check all your strings.
  • googlebook_filter_process(): you could use a foreach() loop here, then you don't need the counter. You can add new array elements simply with $book[] = ...
  • googlebook_retrieve_bookdata(): what is you strategy to sanitize the third party provided data before printing it? You have to use the appropriate sanitization function (check_plain(), check_url() etc.) before embedding any user provided property (or google provided in this case) into your HTML output. See http://drupal.org/node/28984 and http://drupalscout.com/knowledge-base/drupal-text-filtering-cheat-sheet-...
  • Also you should split up googlebook_retrieve_bookdata(): this function should only assemble the necessary data and pass it to a theme function that actually renders the output. So other modules/themes can easily override and customize it.
klausi’s picture

Issue summary: View changes

Updated instructions for 7.x-1.x-dev branch.

darrell_ulm’s picture

OK, all clear on my local test at:
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme .

and remote test at http://ventral.org/.

I addressed these issues:

  • googlebookapi.install: remove the copyright notice, all code on drupal.org is GPL anyway + downloadable tarballs get an extra LICENSE.txt file. Also in the other files.
  • googlebookapi_uninstall(): empty function, so remove it.
  • googlebookapi_get_googlebook_data(): for documenting function parameters you should use the @param syntax, see http://drupal.org/node/1354#functions . Also on other functions.
  • "json_decode($bookkeys, TRUE);": you should use drupal_json_decode() instead. Also elsewehere.
  • googlebookapi_get_googlebook_data(): $obj is a bad variable name, use something more descriptive, e.g. $cached_books, $cache etc.
  • googlebookapi_get_googlebook_version_count(): useless docblock, please at least explain the function in one sentence. Also elsewhere.
  • "'#title' => 'Google Book Data Fields',": all user facing text should run through t() for translation. Please check all your strings.
  • googlebook_filter_process(): you could use a foreach() loop here, then you don't need the counter. You can add new array elements simply with $book[] = ...
  • googlebook_retrieve_bookdata(): what is you strategy to sanitize the third party provided data before printing it? You have to use the appropriate sanitization function (check_plain(), check_url() etc.) before embedding any user provided property (or google provided in this case) into your HTML output. See http://drupal.org/node/28984 and http://drupalscout.com/knowledge-base/drupal-text-filtering-cheat-sheet-...
  • Also you should split up googlebook_retrieve_bookdata(): this function should only assemble the necessary data and pass it to a theme function that actually renders the output. So other modules/themes can easily override and customize it.

Again, thanks to the reviewers in advance!

Cheers,
~Darrell Ulm

darrell_ulm’s picture

Status: Needs work » Needs review

OK, I checked off everything in comment:
http://drupal.org/node/1387232#comment-5556090

I ran through and made the changes I was given on the list and all the automated tests come up clear.

Thanks in advance!

Cheers,
~Darrell Ulm

misc’s picture

Status: Needs review » Reviewed & tested by the community

So I approve again, hope that other reviewers feel the same :-)

darrell_ulm’s picture

MISc, Thanks again. - Darrell Ulm

elc’s picture

Issue tags: -PAreview: security

blockers

googlebook_filter_settings
When user can enter anything they want, but you want them to enter an integer, validate for it instead of accepting and storing anything and then having to do output processing on it everywhere. It looks like all the textfield inputs need to be integers - use a full blown #validate function, or #element_validate on each of them.
It seems these values are used verbatim later on so they should be validated on input.
googlebook_retrieve_bookdata, googlebookapi_get_googlebook_data, googlebookapi_cached_request
None of these functions takes into account the request failing for whatever reason. The last one even caches the faulty result.
googlebookapi_cached_request
cache id can easily be longer than the 255 limit on the cid. Usually cid is set to module specific prefix, sub-area specific prefix, and then a hash of the user provided data so that the length of the cid is always known to be less than the limit.
theme function - preprocess_method
Name is generic and does not indicate at all that this is a google books theme function. Perhaps it would be better called 'googlebook'?

non-blockers

too much growth hormone
Please remove the 7.x-1.x-dev branch from the d.o git repository if you are no longer using it. 7.x-N.x is the normal major version branch naming convention and you seem to have one of those too. Both branches seem to be identical. Just in case you hadn't seen it before - Release naming conventions
git commit messages and attribution
Please refer to Commit messages - providing history and credit about giving yourself some credit and properly formatting commit messages.
googlebook_filter_process
It seems the module should be looking for a marker, not just everything inside {{}}. Other modules may use this same "signal" elsewhere. Most other modules use square brackets - eg [node:5] in node link. {{googlebooks:drupal+7+development}}
googlebookapi_json_extract
API duplication? http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_j...
darrell_ulm’s picture

Issue tags: -PAreview: security

Answer them as I get through each:

googlebookapi_json_extract
API duplication? http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_j...

Not at all: The link you gave has code of:

<?php
function drupal_json_decode($var) {
  return json_decode($var, TRUE);
}
?>

googlebookapi_json_extract (my code) as you can see, works with the specific results of calling drupal_json_decode. It is part of the JSON processing to avoid 100 separate if then statements to pull out the required fields by name for each element of the returned JSON array and a way to collapse the hierarchical array into a flat array using recursion. It is possible it could look like a JSON string parser but is far more simple.
FIXED: OK, renamed googlebookapi_json_extract to more accurate and descriptive googlebookapi_demark_and_flatten

googlebook_filter_process
It seems the module should be looking for a marker, not just everything inside {{}}. Other modules may use this same "signal" elsewhere. Most other modules use square brackets - eg [node:5] in node link. {{googlebooks:drupal+7+development}}

This can be changed to [googlebooks:drupal+7+development]. Is this what you are indicating?
FIXED

too much growth hormone
Please remove the 7.x-1.x-dev branch from the d.o git repository if you are no longer using it. 7.x-N.x is the normal major version branch naming convention and you seem to have one of those too. Both branches seem to be identical. Just in case you hadn't seen it before -

Can remove.
FIXED

git commit messages and attribution
Please refer to Commit messages - providing history and credit about giving yourself some credit and properly formatting commit messages.

Yes/ I read this link, now adding my own issues and fixing them. Then indicating in the patch.
FIXED

googlebook_filter_settings
When user can enter anything they want, but you want them to enter an integer, validate for it instead of accepting and storing anything and then having to do output processing on it everywhere. It looks like all the textfield inputs need to be integers - use a full blown #validate function, or #element_validate on each of them.
It seems these values are used verbatim later on so they should be validated on input.
FIXED

googlebook_retrieve_bookdata, googlebookapi_get_googlebook_data, googlebookapi_cached_request
None of these functions takes into account the request failing for whatever reason. The last one even caches the faulty result.

FIXED

googlebookapi_cached_request
cache id can easily be longer than the 255 limit on the cid. Usually cid is set to module specific prefix, sub-area specific prefix, and then a hash of the user provided data so that the length of the cid is always known to be less than the limit.


Added sha256 hashing function to cache as indicated on drupal.org as the new standard.

And as you probably saw in the code, the GoogleBook module has an install function with it's own cache table for efficiency, rather than the bulk Drupal cache. So as one would expect, I did not add the

module specific prefix

I assume you already saw that in the code and didn't really want me to add the prefix for a cache table already created specifically for GoogleBook.

function googlebookapi_schema() {
  $schema['cache_googlebookapi'] = drupal_get_schema_unprocessed('system', 'cache');
  return $schema;
}

Also I did miss documenting the return param on that schema function, so added the 1 line of doc.
FIXED

theme function - preprocess_method
Name is generic and does not indicate at all that this is a google books theme function. Perhaps it would be better called 'googlebook'?

Changed to 'googlebook_theme_template'
FIXED

misc’s picture

Here I go again.
Seriously, @ELC, I think this is to picky. It is obvious that @darrellulm has an understanding of Drupal standards, and the module works, and is easily to setup. Improvements could always be done when you release your project as a full project, how many sandbox projects is a stable release on the first day they become full projects?

elc’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +PAreview: security

@misc This is not the correct forum for such arguments. If you have issues with my reviews you may ask for a second opinion or talk to me directly. This is not your application?

The project has a security issue which it seems I forgot to add the tag for. The unvalidated user input is entered directly into the HTML output. This is a canary for understanding the security implications of trusting user input and using the forms API. Security and understanding the Drupal API are some goals of this process.

The unhandled error states on http requests, and cache id key length are not as important but are serious enough that they will cause unexpected errors and warnings, and could be potentially difficult to diagnose at a later date as they will not be easily reproduced.

@darrellulm

googlebookapi_json_extract
That seems perfectly reasonable.
googlebook_filter_process
This can be changed to [googlebooks:drupal+7+development]. Is this what you are indicating? Yes, that would work. It then makes that tag uniquely identifiable as being from googlebooks. You can stick with {{}} if you want, but yes, most modules seem to use the [].

I look forward to the other fixes.

misc’s picture

@ELC, I am also doing review of this applicant, and raised my concern in the issue there I think we are to picky. Further discussion on the subject could be done here: http://groups.drupal.org/node/208403

darrell_ulm’s picture

Issue tags: +PAreview: security

I will rename googlebookapi_json_extract to something more descriptive. I can see where the naming similarity is not the best way to go given that the function is doing something specific to my module and is not really an extraction. So I will rename when I get a chance.

Will work on other issues soon.

-Cheers,
~Darrell

darrell_ulm’s picture

Status: Needs work » Needs review
Issue tags: +PAreview: security

OK @ELC and @MISc, I made all the changes indicated. Coming up clean. Thanks for all of both of your suggestions, made it a better module.

I checked off each of the tasks at the comment above:
http://drupal.org/node/1387232#comment-5573508

Cheers,
@darrellulm

elc’s picture

Status: Needs review » Reviewed & tested by the community

Main security issue addressed; admin input is now validated as a number before being accepted and included in output html.

The second blocking issue listed in #15 is still at large. I'll open a bug on the project page as they will cause errors to displayed to the user, not outright break or be a security issue. Hmm.. one of them doesn't cause errors. It appears that access an non-existent index on a NULL value does not throw an E_NOTICE. The property still throws one though.

Caching; fixed. I agree that it doesn't need a module specific identifier. Perhaps you should make the search string lower case before hashing it so that differences in case don't mean keeping a cached copy for each.

Theme name; it's certainly module specific!

Also fixed the non-blockers.

other mild suggestions

googlebook_make_html_link
this function should be using the l() function to build a link, allowing it go through the theme engine for other modules to manipulate. http://api.drupal.org/api/drupal/includes%21common.inc/function/l/7
out of date reference
Put a Google Book search term between double brackets like this:
[googlebook:The Hobbit] or [googlebook:9780618154012] or [googlebook:Rucker+Software]
and this will filter the input to replace with Google Book data
and images from http://books.google.com

So, the next step from here is for another git admin to come along and review it again and if they find it to be all good, they'll set it to "fixed" and grant the git vetted status. If they find any issues, it will be bouced back to needs work with appropriate instructions.

klausi’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new3.26 KB

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

There is a git tag that has the same name as the branch 7.x-1.x. Make sure to remove this tag to avoid confusion.

manual review:

  • "'#default_value' => isset($filter->settings['googlebook_link']['worldcat']) ? check_plain(...": The form API will run check_plain() on #default_value, so you should not use check_plain() here. Double escaping is bad.
  • function doc blocks: The first line e.g. "Implements: googlebook_filter_info()" does not contain any information. You are just repeating the function name here. The first line should contain the short description, see http://drupal.org/node/1354#functions
  • "array_walk($params, create_function('&$val', '$val = trim($val);'));": why can't you use $params = array_map('trim', $params); ?
  • googlebook.tpl.php: a template file should be HTML code that has PHP code snippets embedded, not the other way around. So you would not need all that print statements. On the other hand, if there is more theming logic than HTML code you should consider using a theme function instead.
  • "htmlentities($info_link)": you should use check_url() here instead. Even better: use the l() function to generate link markup and read its documentation, it will sanitize things for you if you want.
  • $html_coverimage: do not create the image markup yourself, use theme('image', ...) instead.
  • Do not embed javascript yourself in the HTML output, use drupal_add_js() instead. This is required so that Drupal is able to aggregate javascript, other modules could alter it, etc.

Sorry to bump this back to needs work, but you need to know where to use check_plain() and where not.

klausi’s picture

Issue summary: View changes

Changed information to indicate 7.x.1.x normal release branch for naming conventions.

darrell_ulm’s picture

OK, handled these and set to the 7.x-1.x repo.

darrell_ulm’s picture

Hey, fixed most of them, now making a theme function(s) for the output.

Reply to:

Sorry to bump this back to needs work, but you need to know where to use check_plain() and where not.

Also I knew that the form #default already checked the input but I tossed them in anyway in case you (or whoever reviewed it) didn't know since I wanted a pass! ;)

Took those out and resubmitted.

How to handle the Javascript, I assume you are aware that drupal_add_js does not work with hook_filter() with caching? I don't believe this was ever fixed in Drupal 7. Please advise, are you sure you want me to use drupal_add_js() with hook_filter? Due the to processing order, the filter is rendered only once when the cache is cleared or reset, then of course the drupal_add_js() cannot render from the cached version!
Do you have a preference on how you add javascript, I assume you did not mean drupal_add_js, for non hook_filter modules, of course it works, but not with hook_filter (the point of the module.)
See:
http://mostrey.be/hookfilter-versus-drupaladdjs
http://drupal.org/update/modules/6/7#attached_js

Cheers,
~Darrell

darrell_ulm’s picture

Status: Needs work » Needs review

Sorry to bump this back to you, fixed most of the issues, but because you are asking me to use drupal_add_js() within hook_filter(), that just isn't going to work because of the processing order.

See my prior comment.
http://drupal.org/node/1387232#comment-5593036

So I had to fix what I could and sorry, had to pass it back until I get advisement on the drupal_add_js() request. Yes, works well everywhere, not inside hook_filter. I can just take the JavaScript out if Drupal cannot handle adding JavaScript from a filter.

Request to please advise on drupal_add_js() so I can continue.

Thanks again.

elc’s picture

re: that javascript

After looking at what it is and asking for some advice about it, here's MESHO on the subject ;)

There are two parts to the javascript for a book; a file which is pulled in from google - define('GOOGLE_BOOK_EXTERN_JS', 'https://www.google.com/jsapi');, and a dynamic chunk of script based on the ISBN of the book.

The file from google should be included on any page that needs it - teaser or full node display, or random entity. Due to that being stupendously hard to figure out, just always add it during hook_init() with drupal_add_js().

The dynamic piece of script is entirely based on the exact entry of text being replace, it should remain there as inline javascript. There is no way to add it to the top of the page without ruining caching and generally getting in the way.

darrell_ulm’s picture

Status: Needs review » Needs work

@ELC, thanks for verifying this. I have been looking for a better way to do this in Drupal, and everywhere else drupal_add_js() works pretty well. I was hoping not to add anything globally, as it would be nice to only put it on the needed pages, but that does seem to be pretty tricky.

Again, thanks for the feedback, will munch away at the code when time permits again.

Yep, just verified hook_init() works as stated; hook_init() is all pervasive.

Now working on the theme functions and better pre-processing. This process is good and will produce a better module. My hope is that people who post book information find it useful, so polish can only help.

Thanks again.

darrell_ulm’s picture

Status: Needs work » Needs review

klausi & ELC,
OK, below I go through each point.

  • There is a git tag that has the same name as the branch 7.x-1.x. Make sure to remove this tag to avoid confusion.

Removed.

manual review:
Crossed out each one completed.

  1. "'#default_value' => isset($filter->settings['googlebook_link']['worldcat']) ? check_plain(...": The form API will run check_plain() on #default_value, so you should not use check_plain() here. Double escaping is bad.Yes.
  2. function doc blocks: The first line e.g. "Implements: googlebook_filter_info()" does not contain any information. You are just repeating the function name here. The first line should contain the short description, see http://drupal.org/node/1354#functionsMissed that one.
  3. "array_walk($params, create_function('&$val', '$val = trim($val);'));": why can't you use $params = array_map('trim', $params); ?Good Point!
  4. googlebook.tpl.php: a template file should be HTML code that has PHP code snippets embedded, not the other way around. So you would not need all that print statements. On the other hand, if there is more theming logic than HTML code you should consider using a theme function instead.Cleaned template file up and added theme function for Biblio fields.
  5. "htmlentities($info_link)": you should use check_url() here instead. Even better: use the l() function to generate link markup and read its documentation, it will sanitize things for you if you want.Updated.
  6. $html_coverimage: do not create the image markup yourself, use theme('image', ...) instead.Done.
  7. Do not embed javascript yourself in the HTML output, use drupal_add_js() instead. This is required so that Drupal is able to aggregate javascript, other modules could alter it, etc.Handled this as advised in above comments.

Also added googlebook.css as starting place for styling displayed book data. Added the CSS file also through the hook_init() like the global JavaScript.

Klausi & ELC, thanks again for review, very instructive and very good to clean up the templates whenever possible.
-Darrell Ulm

darrell_ulm’s picture

Issue summary: View changes

Changed bracket notation.

jordojuice’s picture

Correct me if I'm wrong: shouldn't googlebook be google_book and googlebookapi be google_book_api?

jordojuice’s picture

I won't set it to needs review because I just glanced at the code, but I found this line in googlebookapi.module
277 drupal_set_message($message = t('Googlebooks: Could not retrieve data from google.com. @err', array('@err' => check_plain($url_data->error))), $type = 'error');
Using the @err will already ensure that the string is passed through check_plain(), and assigning the $message variable is kind of pointless.

elc’s picture

Status: Needs review » Needs work

Looks good, however you have processing and logic in the template file and template function. The theme functions are meant to only be printing out things that have been completely prepared already. Or looping through and array of completely prepared stuff, or conditionally including wrapper divs around prepared stuff.

In googlebook.tpl.php, the call to theme('image') and theme('googlebookbiblio') should have already been done in the preprocess funtion and their output should simply be "print $whatever;", or "if ($whatever) .. etc." Or if you setup render arrays in the preprocess function, if ($whatver) drupal_render($whatever).
http://drupal.org/node/223430

Please note that full render arrays for everything is new to Drupal 7 and so not many modules will have this implemented.

Still back on needs work because of the logic in themes.

darrell_ulm’s picture

OK, this makes sense and proved easy and sensible enough.
This is done and now I cleaned up the large function in googlebook.module to separate it into function in a more sensible way and put the data setup in the theme pre-process function.

I won't set it to needs review because I just glanced at the code, but I found this line in googlebookapi.module
277 drupal_set_message($message = t('Googlebooks: Could not retrieve data from google.com. @err', array('@err' => check_plain($url_data->error))), $type = 'error');
Using the @err will already ensure that the string is passed through check_plain(), and assigning the $message variable is kind of pointless.

Fixed

Working on: from: http://drupal.org/node/1387232#comment-5630260
Correct me if I'm wrong: shouldn't googlebook be google_book and googlebookapi be google_book_api?

darrell_ulm’s picture

Status: Needs work » Needs review

OK, made all changes as indicated in:

And, added 1 space in the CSS file to pass the code formatting style guide.

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

manual review:

  • google_books_theme(): this is a hook and should be documented as such, see http://drupal.org/node/1354#hookimpl . Same for google_books_init(). Please check all your hook implementations.

Otherwise this looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

darrell_ulm’s picture

Status: Reviewed & tested by the community » Needs review

Added documentation as per:
http://drupal.org/comment/reply/1387232/5660790#comment-5660790

  • Provided more documentation for callbacks that http://api.drupal.org defines as not really a hook.
  • Inserted @see references where needed as per: http://drupal.org/node/1354#hookimpl and also fully documented theme.tpl.php as well as the preprocess function and other theme elements with comment list.
  • Also changed a long an awkward function name,
  • and extended the #size of the filter config page in the form for the biblio select list.

Documentation changes committed.

darrell_ulm’s picture

Issue summary: View changes

PAReview: review bonus
updates

patrickd’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

your application was already RTBC, read about the workflow of applications.

darrell_ulm’s picture

@patrickd
Right. I made the changes as in:
http://drupal.org/node/1387232#comment-5664900
and from the description assumed it needed to be reviewed again.

Thanks for the information.

elc’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, Darrell! Welcome to the community of project contributors on drupal.org.

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

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

That last paragraph seems like it might need a different template for people who have actually participated in the review process ;)

darrell_ulm’s picture

Great, thanks for the review.
It is a good process and worth going through.

Cheers,

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

Anonymous’s picture

Issue summary: View changes

Inserted link to full module node at http://drupal.org/project/google_books