The Are You A Human PlayThru module integrates an alternative CAPTCHA with Drupal forms. Instead of trying to read sometimes unreadable text the user is asked to play a simple game. Once the game is completed the user is verified and continues on.

The makers of PlayThru have asked me to get the module in shape for Drupal.org. The module code that they had seems to match up with this thread: http://drupal.org/node/1408104.

I made the changes suggested there.

The project page is here: http://drupal.org/sandbox/tomgeekery/1858086

Git:
git clone http://git.drupal.org/sandbox/tomgeekery/1858086.git are_you_a_human_playthru

This is a Drupal 7 module.

I will be reviewing some other modules to gain the review bonus status.

Thanks!

Comments

tomgeekery’s picture

Issue summary: View changes

Changed git branch.

cweagans’s picture

Status: Needs review » Needs work

I don't have long to review this, but it looks really really awesome. Couple of quick notes:

1) Wow! It has a readme! That's better than like 80% of other modules on Drupal.org! =P
2) Any reason not to merge ayah.inc into ayah.module? ayah.module is not nearly big enough for that to be a concern, and it does save on some file loading operations, though that's kind of a microoptimization. I'm okay with that setup as-is, but in an ideal world, ayah.inc wouldn't exist.
3) It is kind of concerning that this module disables page caching. Have you thought about adding some static javascript to the page that dynamically loads the captcha from a separate script? Check out how the statistics module works in Drupal 8 for an example. The benefit of doing this is that page caching can still be enabled and you could even put it behind varnish or something if you exclude the captcha path in your VCL file. Also, have you looked at the Mollom module or any of the other captcha modules? None of them disable the page cache...I suspect that there's a better way to do this that doesn't involve killing performance.
4) Do you really need a separate table to store the form IDs? I bet you could get away with just dumping that data into a variable. I know that it seems a little less clean, but variables get statically cached IIRC, so if you need to check the form IDs multiple times, it's not going to be a database query every time. And really, most of the time, it'll only be used on node forms, comment forms, and user signup forms anyways, so we're not talking a whole lot of data here.

In general, this code was really clean as far as coding standards go. Like *really* clean. I'm really excited about this module and I'd love to see it published as a full module - I know that I would definitely use it on my site!

tomgeekery’s picture

Thanks so much for the review!

1. Glad you appreciate the README =]

2. No good reason they are separate, I will merge them together. The less files the better.

3 and 4. Thanks a bunch for these, the page caching is a concern and I will check out the modules and ideas you listed to see what I can do. I will also investigate using a variable as opposed to the table for the form id's.

Thanks again for the great suggestions, review, and compliments on the code.

jpstrikesback’s picture

Quickly, and to reiterate #3 above, the page caching disable precludes this from use on any high volume site I think (at minimum including the ones I want to test this on).

fenstrat’s picture

Nice module, and quality of code. However like @jpstrikesback disabling page caching is a heavy price to pay. The captcha module does the same, but mollom does not.

tomgeekery’s picture

Hey guys,

Thanks for the feedback. I forgot to mention above that the page caching method used was from the captcha module.

I also was digging through the Mollom module and I found this in mollom.module:

// Prevent the page cache from storing a form containing a CAPTCHA element.
  drupal_page_is_cacheable(FALSE);

If I am understanding this correctly, does this mean that Mollom also disables the page cache when there is a CAPTCHA element?

I also found an interesting thread talking about Drupal, CAPTCHA, and page cache here.

I am by no means a cache expert so any input would be very helpful. I would love to get rid of this big performance hit I am just not sure if it is something I am capable of if these other major modules haven't figured out a way to do it either. I could be wrong on Mollom though, please let me know if I am.

I will be working on getting rid of the table for the form_id's in the mean time.

jhaskins’s picture

First, a disclaimer: it will be fairly obvious to anyone who looks at our profiles that I work for the same company as the person submitting this module. That said, I'm not directly involved with this project. I'm reviewing it on my own time because I think the concept is interesting & it looks like things have started to stall here. Don't worry, I'll try to be extra strict to avoid looking biased :)

Next, I agree with what was said about the caching issue. If other modules such as captcha are disabling caching, I'm not sure there is a way around it. If there was, someone would have probably found it by now. If somone knows differently, I think nearly anyone who uses the captcha module would be interested to hear about it.

Now, for the review:

  • In ayah_set_form_id_setting in ayah.inc you are using db_query for delete & insert operations. These should be using the query builder object instead (see http://drupal.org/node/310081 & http://drupal.org/node/310079).
  • The permissions 'Administer AYAH settings' & 'Skip AYAH' are not being created because hook_perm does not exist in Druapl 7. You need hook_permission & it looks like that is actually what you are implementing; it should just be a matter of changing the function name.
  • In ayah_validate in ayah.module, the need for the login form hack seems a bit odd. Have you tried making it a form validation function instead of a field validation function? I think that an error in a form validation function should prevent the login from hapening.
  • Why not add a 'configure = admin path' line in the .info so people get the handy "configure" link on the module admin page?
AngryWookie’s picture

I didn't do much in terms of a code evaluation but I did go through and test the user experience and found that everything was working as I would expect without any errors.

tomgeekery’s picture

Thanks for the reviews everyone.

I made the changes that were suggested above, including removing the form id table and replacing it with a variable. I was not able to remove the page caching however.

That being said, if you have already installed this module, please uninstall it before trying it out again as there was some major changes in how the module interacts with the database.

If anyone has time to check it out again that would be great.

jhaskins’s picture

Status: Needs work » Needs review

I've looked this over & don't see any more issues. Marking this "needs review" to get some more eyes on it.

klausi’s picture

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

manual review:

  1. "module_load_include('inc', 'ayah');": no need to use module_load_include as you are including files from your own module which you already know where they are. Use something like require_once 'mymodule.inc';
  2. "@return null": if the function does not return anything the @return doc should be omitted. See http://drupal.org/node/1354#functions . And it should specify the type on the first line, not a value.
  3. ayah_get_form_id_setting(): you could save the the form IDs as array keys, then you can simply use isset() on the variable array. This function might not even be necessary then.
  4. _ayah_get_ayah_placement(): since variable_get() is already statically cached your static cache does not make sense.

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

cweagans’s picture

Status: Reviewed & tested by the community » Needs work

Not so fast. module_load_include('inc', 'ayah') needs to go away because ayah.inc doesn't exist, though the reason that klausi gave is also legitimate.

I also agree that you don't need a second static cache for _ayah_get_ayah_placement(). The built-in static cache for variables should work just fine.

I don't think that the caching issue is a release-blocker, but the above two issues are. The former will cause warnings, I think. The latter contributes to overuse of memory on a page request, which is a bad thing.

If you fix the above two issues, I think this is RTBC. Also, after this is promoted to a full project, if you want a hand with figuring out how to get page caching working, I'd be interested in helping out (I'll be using this module on my site, so I may as well, right?)

tomgeekery’s picture

Status: Needs work » Needs review

Hey guys, thanks for the reviews.

Removed the line referring to the .inc file that I merged with the .module file.

Cleaned up the returns in the docs.

Was able to remove the ayah_get_form_id_setting and use the form ID's as array keys.

Removed the first level of cache checking in _ayah_get_ayah_placement.

There are again some changes to how the form ids are stored, so best disable and uninstall the module before testing the new code.

Thanks!

cweagans’s picture

Status: Needs review » Needs work

I'm not seeing the changes here: http://drupalcode.org/sandbox/tomgeekery/1858086.git/shortlog/refs/heads...

Did you forget to push? Or perhaps you missed the other module_load_include() (there were two, IIRC)

tomgeekery’s picture

Status: Needs work » Needs review

Bah, sorry about that. I did forget about the other line in there. It should be gone now.

Also, I appreciate the offer to help out with the page cache once this is approved, that would be great.

Thanks!

cweagans’s picture

Status: Needs review » Fixed

Per earlier reviews here, this is ready. tomgeekery, enjoy your new git access. Feel free to promote your project when you feel that it is appropriate. Thanks for contributing!

klausi’s picture

Thanks for your contribution, tomgeekery!

cweagans 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.

@cweagans: Thanks for helping out here! I added you to the list of code review administrator at http://groups.drupal.org/node/142454

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Changed git command to something everyone could use.