Hi guys.

New project at:
http://drupal.org/sandbox/danmatthews/1864818

You can check it out of version control using:

git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/danmatthews/1864818.git dx_cache
cd dx_cache

118 lines, 5 functions, really small useful utility module.

Comments

balintcsaba’s picture

Hi danmatthews,

I cant access your git , please edit version control access at this page with the following:
Go to your project page , at the Version control menu select the version 7.x-1.x , check the Non-maintainer? checkbox and click Show.
Copy that and edit this page.

Also edit the description page of your module , is hard to have a code review without to know how and what does your module exactly.

jhaskins’s picture

Status: Needs review » Needs work

PAReview.sh comes up clean (http://ventral.org/pareview/httpgitdrupalorgsandboxdanmatthews1864818git).

I did spot one issue: in several locations, you are using db_query("DELETE.... You should be using a query builder object with db_delete instead (see http://drupal.org/node/310081).

Also, one nitpick on your README.txt; you say

$myvalue = dx_cache_get('my.key'); // Returns the value if valid,
false if expired.

Perhaps you should also indicate that it will also return false if the key doesn't exist (just a thought; not a big deal).

danmatthews’s picture

Status: Needs work » Needs review

Thanks, nitpicks and query builder objects taken care of :)

klausi’s picture

We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

anwar_max’s picture

Status: Needs review » Needs work
Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: http://drupal.org/sandbox/danmatthews/1728120

Project 2: http://drupal.org/sandbox/danmatthews/1864818

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

Please take a moment to make your project page follow tips for a great project page.

Manual Review:
1) Table name is wrong in dx_cache_cron() function.
$results = db_query("DELETE FROM {ox_cache} WHERE expires < %d", time());

danmatthews’s picture

Status: Needs work » Needs review

Hi,

I've cleaned up all of the mistakes pointed out, thanks for that. And i'll leave this one open for review.

Thanks very much.

Dan.

sadashiv’s picture

Status: Needs review » Needs work

Table names should be enclosed in {curly_brackets} in db_query in dx_cache_has function. Ideally you should use db_select() instead of db_query.

Will be good if you also write hook_help.

Regards,
Sadashiv.

danmatthews’s picture

Status: Needs work » Needs review

Hook help written, and field names enclosed in curly braces, i'm going to stick with db_query and placeholders for now - i find them more readable to maintain, and they're just as safe when using placeholders.

Thanks.
Dan.

hhhc’s picture

Nice little tool.

danmatthews’s picture

Thanks,

Fixed!

ain’s picture

Automated review

Everything in order, no errors.

Manual review

  1. Sync your README with the project page. You've got a lot of useful data there that is of great use for those just navigating to your module page.
  2. I'd also advise to check_plain() the data, see Writing secure code.
klausi’s picture

Status: Needs review » Needs work

Do NOT run check_plain() on data that you are storing, only run it when you output things.

"When handling data, the golden rule is to store exactly what the user typed. When a user edits a post they created earlier, the form should contain the same things as it did when they first submitted it. This means that conversions are performed when content is output, not when saved to the database." http://drupal.org/node/28984

danmatthews’s picture

Hi Both,

Is check_plain not completely obsolete unless the person is storing a string? And what if they don't want the information they retrieve from the database to be HTML-encoded? For example to be passed into something like a markdown parser.

I"m loathed to put something like that in there that alters the output of the original data stored in any way, but i can definitely add a paragraph to the README that states that you should treat information from the table as you would any other unsafe input? Or rather, you should do that before inserting data.

ain’s picture

Good idea Re README, but I think the module is generally RTBC.

danmatthews’s picture

Status: Needs work » Needs review

There we go, i've updated the readme with an advisory section on sanitisation, and also updated the project page with usage examples.

http://drupal.org/sandbox/danmatthews/1864818

Thanks.

danmatthews’s picture

Status: Needs review » Reviewed & tested by the community

Changing status to try and bump up.

sadashiv’s picture

I think you should change the priority to bump up and the status should remain needs review.

Refer application prioriy on http://drupal.org/node/894256

danmatthews’s picture

Priority: Normal » Major
Status: Reviewed & tested by the community » Needs review
tenken’s picture

Project Review:

Automated Test results:

Manual Review:

  • Project installed without errors via Drush installation of drupal + project.
  • In this section of code:
        'expires'    => isset($ttl) ? (time() + $ttl) : NULL,
        'created_at' => time(),
    


    consider defining time() somewhere once before you set the values in the array. This way time() is atomically used once in this function and there is no chance that expires vs created_at are off by a second or two when using this library with alot of data, or lots of calls at once.

Eg,

  $timestamp = time();
  ...
    'expires'    => isset($ttl) ? ($timestamp + $ttl) : NULL,
    'created_at' => $timestamp,

... you're not doing any big work between these two time() calls, but this approach is more futureproof and atomic.

tenken’s picture

Status: Needs review » Needs work

oops forgot to change status in #19.

danmatthews’s picture

Status: Needs work » Needs review
snufkin’s picture

Status: Needs review » Reviewed & tested by the community

What I would add is to use http://api.drupal.org/api/drupal/includes%21bootstrap.inc/constant/REQUE... instead of time(), however this is a really minor issue, plus the module is fairly simple.

I'd say this is ready to be published, marking it as RTBC.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Git default branch is not set, see the documentation on setting a default branch.

Sorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.

manual review:

  1. dx_cache_set(): instead of delete/insert you could us db_merge()?
  2. dx_cache_schema(): primary key is missing.
  3. README.txt: data should NOT be sanitized when saved to the database, only when it is printed to HTML on output. You should remove that and please read http://drupal.org/node/28984 again. "When handling data, the golden rule is to store exactly what the user typed. When a user edits a post they created earlier, the form should contain the same things as it did when they first submitted it. This means that conversions are performed when content is output, not when saved to the database."

But that are not application blockers, so ...

Thanks for your contribution, danmatthews!

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.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Changed git clone URL to be for non-maintainers.

avpaderno’s picture

Title: dx_cache module » [D7] dx_cache module
Priority: Major » Normal
Issue summary: View changes