Hello,
mysql_wait_timeout is a simple module which aims at setting different values for MySQL's "wait_timeout" parameter depending on what Drupal is about to do: regular execution (= generate a HTTP response), cron job or Drush command.
It is more simple than db_tweaks, which is Drupal 6-only and covers more MySQL settings but without achieving the single goal of wait_timeout.
More details about this module can be found on its project page : https://www.drupal.org/sandbox/xavier_g/2364137
The code can be cloned this way:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/xavier_g/2364137.git mysql_wait_timeout
Alas, I must confess I never reviewed any sandbox project so far.
Thanks in advance for your review.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | patch_undefined_variables.txt | 434 bytes | cllamas |
Comments
Comment #1
PA robot commentedWe are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxxavier_g2364137git
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
xavier_g commentedComment #4
xavier_g commentedI have realized that Drupal 7 allows setting "init_commands" when defining the $databases array in settings.php:
I will dive into this approach and determine if, in the end, this module is really needed.
Comment #5
xavier_g commentedI finally decided to convert the D7 module into a D6 one (because Drupal 6 does not provide the "init_commands" mechanism and thus still benefit from the initial approach. The D7 module itself was replaced with a simple file to be included in settings.php.
Comment #6
xavier_g commentedComment #7
Chetan Sharma commentedFOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
12 | WARNING | Variable $conf is undefined.
remove $conf from if condition and keep it outside from the condition thanks.
http://pareview.sh/pareview/httpgitdrupalorgsandboxxavierg2364137git
Comment #8
xavier_g commentedRegarding #7: I am afraid none of this makes any sense to me...
For the record, we are speaking of the following piece of code, meant to be included into settings.php:
Comment #9
rajeev_drupal commentedReviewing this
Comment #10
rajeev_drupal commentedAutomated Review
Below issues are found in pareview.sh
DrupalPractice has found some issues with your code, but could be false positives.
FILE: /var/www/drupal-7-pareview/pareview_temp/wait_timeout.inc.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
12 | WARNING | Variable $conf is undefined.
----------------------------------------------------------------------
Time: 17ms; Memory: 3Mb
Manual Review
<
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #11
naveenvalechaUnassigned.So that other will take a look at it.Thanks for the review.
Comment #12
tgates commentedBecause this project is MySQL specific, I suggest that you put MySQL in the project name.
The D7 file wait_timeout.inc.php assumes that $databases['default']['default'] is a MySQL database. However Drupal support other databases as well, the 'init_commands' won't work on some non-MySQL databases. You can test for the presence of MySQL by looking for $databases['default']['default']['driver'] to be "mysql".
Comment #13
mojiferousManual Review
1. You can probably quiet down the undefined $conf by using a ternary like
$conf = (isset($conf)) ? $conf : array();2. Line 15 can probably be just
if(empty($databases)){since empty will return true for a null or unassigned variable.Comment #14
chandrasekhar539 commentedAutomated Review
everything fine
Manual Review
Individual user account
Yes: Follows follow the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements. / No: List of security issues identified.]
Comment #15
Chetan Sharma commentedYou can use ternary operator rather than if condition
if (!isset($conf)) {
$conf = array();
}
Example : $conf = (isset($conf)) ? $conf : array();
Comment #16
monojnath commentedHi
I tried to use your module.
But, it seems to lack the basic documention for the project.
Please visit "https://www.drupal.org/node/2190239".
Also I have seen some issues logged by "http://pareview.sh/pareview/httpgitdrupalorgsandboxxavierg2364137git".
And its a simple .inc file.
So it would be great if you can create your own .module file that would include the .inc file when enabled. :)
Comment #17
fabian.fernandes_30 commentedHi xavier_g,
good work
there are couple of issues that are simple fixes,
Review of the 7.x-1.x branch (commit e3fc4f4):
DrupalPractice has found some issues with your code, but could be false positives.
FILE: /var/www/drupal-7-pareview/pareview_temp/wait_timeout.inc.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
15 | WARNING | Variable $databases is undefined.
15 | WARNING | Variable $databases is undefined.
20 | WARNING | Variable $conf is undefined.
----------------------------------------------------------------------
Comment #18
cllamas commentedI've modified the code to fix the undefined variables warnings. (patch attached)
Comment #19
Chetan Sharma commentedif (isset($databases) && empty($databases)) {
return 1;
}
Hi cllamas,
this condition will never execute.
Comment #20
patrickscheffer commentedHi! Great idea to address this MySQL problem in a seperate script. You're right it needs no complete module.
The automated tests gave still some issues:
This one is easy to fix.
24 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, colons, or question marks
I guess the following can be ignored as the Drupal Best Practices does not take script including into account.
15 | WARNING | Variable $databases is undefined.
15 | WARNING | Variable $databases is undefined.
20 | WARNING | Variable $conf is undefined.
However, as Chetan Sharma above noted: the first if statement is incorrect. A variable can never be 'isset' and 'empty' at the same time. I think the empty check would be enough as that one also contains an isset. Check it out here.
Comment #21
xavier_g commentedHey guys! Long time no see :')
So, let's review the reviews...
tgates:
Two excellent suggestions in a single comment! THAT is a review! I will apply these advices :)
Mojiferous:
Working around pareview with a ternary? Ok, I guess it is worth a try...
empty() instead of isset() && empty() makes sense too (as "empty() does not generate a warning if the variable does not exist" according to the PHP documentation), I will apply that advice.
monojnath:
I believe you forgot to read README.txt :)
PatrickScheffer:
Ah! Some common sense, at least! Thank you, thank you so much.
Never say never -- consider this:
It will output:
So, here is what I am going to do: I will take these suggestions into account so that mysql_wait_timeout checks it is dealing with a MySQL database and I will strive to reduce the pareview output as much as possible. However, as some of you understood, this is not intended to be a real, complete module (that's more of a common configuration snippet that ought to be standardized) and at some point, it would be wise to ignore the output of the almighty automated review tools :)
Thanks to all of you for the reviews.
Comment #22
xavier_g commentedComment #23
xavier_g commentedAnd done. Alas, The automated review still cries about undefined variables:
Again, I suggest we simply ignore those warnings.
Comment #24
patrickscheffer commentedIs your code ready for review? If so, please update your status to Needs review so we know it's our turn to do something.
Comment #25
xavier_g commentedComment #26
patrickscheffer commentedAlright, I've confirmed the requested changes are processed so I'll update the status to RTBC.
If you'd like to get rid of those annoying warnings in the automated review you can wrap those pieces of code in ignore tags:
Of course, you don't have to do this, but maybe you're as paranoid as me and must have a clean test result. ;-)
Comment #27
mlncn commentedThanks for your contribution! Congratulations, you are now a vetted Git user. You can promote this to a full project.
When you create new projects (typically as a sandbox to start) you can then promote them to 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 stay 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.
Comment #29
xavier_g commentedPatrickScheffer: thanks for the @codingStandardsIgnore advice, I have just applied it.
mlncn: thanks a lot :)