Description
This is an extremely simple module with one very specific purpose: create a block containing a button enabled for specific roles (especially editors, content managers) that clears the cache for the page on which it is located. A couple use cases include:
- Improperly rendered page (for whatever reason) gets cached in broken state.
- Content is edited, but old content is displayed until the cache expires "naturally."
Project Page
http://drupal.org/sandbox/iamEAP/1329802
Repository
git clone --branch 6.x-1.x http://git.drupal.org/sandbox/iamEAP/1329802.git
Versions
Drupal 6.x
Background
I've been working with Drupal in site building, theming, and development contexts for approximately two years and have been using PHP and MySQL for work and play back five years prior. I hold bachelor's degrees in Computer Science and Digital Media studies from the University of Denver. I currently work fulltime as a developer on a Drupal website for a software company in Seattle. My first exposure to the community surrounding Drupal was about a month ago at the Pacific Northwest Drupal Summit in Portland.
Comments
Comment #1
bailey86 commentedAfter a very quick look I would say that the code needs to be tidied to meet the coding standards. See:
http://drupal.org/coding-standards
Indents should only be two spaces and if using curly braces they should be like:
if (condition1 || condition2) {
action1;
}
and not
if (condition1 || condition2)
{
action1;
}
The easiest way is to install the coder module which will quickly show any non-standard coding.
Comment #2
klausiComment #3
iamEAP commentedUpdated code to the standards specified.
Also took a quick look at other issues in the Project Application queue and made a few additional changes including...
Comment #4
doitDave commentedI just installed your module in a "virgin" D6 environment, activated the block - noting happens, no block at all!
D6, Windows, Apache, MySQL5, PHP5. Tested as user #1.
Comment #5
iamEAP commentedThe module has no effect unless you enable "normal" page caching under admin/settings/performance. Did you enable caching?
Comment #6
doitDave commentedAh. Now I've got it. Ok and sorry for not thinking logically ;)
Walking through your code, I found something else:
In page_cache_clear_button.module, line 85:
db_query("DELETE FROM {cache_content} WHERE cid LIKE '%content:%d%'", $nid);Clearing the content cache table for node 13 would also clear all nodes with nid 131, 1364438, and so on
Since content entries are always in the form
content:nid:vid, you should change that line intodb_query("DELETE FROM {cache_content} WHERE cid LIKE '%content:%d:%'", $nid);or, probably even better, also use the vid and work without "%" SQL wildcards here.
Comment #7
iamEAP commentedGood catch! Changes made.
I also rearranged the logic to allow anyone to call page_cache_clear_button_get_button() arbitrarily (rather than having to place a block somewhere) and still have it respect the module's permissions.
Comment #8
chakrapani commentedThis automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.
Comment #9
iamEAP commentedThanks, chakrapani!
I ran coder and fixed all of the coding standard issues.
Additionally, I made some changes so that the module utilizes block configuration settings more fully and better integrates with block configurations generally. Namely:
Comment #10
klausiReview of the 6.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. Go and review some other project applications, so we can get back to yours sooner.
Comment #11
iamEAP commentedKlausi,
I made the two concat changes (surprisingly, both were in sections of code I'd copied from Drupal core).
I believe all of my text files already end in newlines, is this not the case?
Comment #11.0
iamEAP commentedChanging repository reference from branch master to 6.x-1.x.
Comment #12
doitDave commentedYes, especially the D6 core would never ever pass any review based on current coding standards ;)
No more issues in the automated review.
Manual review:
Comment #13
iamEAP commentedThanks Dave,
Cleared out the master branch.
The reasoning behind the permission settings over the block visibility settings is to be as robust as possible down the line. As the module is, you can place the button in two ways:
In order to support the latter, and all other possibilities, it made more sense to define a permission. After that, it made the most sense to overwrite the block role visibility setting to minimize possible confusion.
And, if it's relevant, some future plans for the module down the line:
Comment #14
iamEAP commentedWhoops. Needs review.
Comment #15
doitDave commentedHi,
thanks for clarifying. Here are some few remarks of the latest review scripts:
Review of the 6.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. Go and review some other project applications, so we can get back to yours sooner.
Regarding newlines, note my comment: http://drupal.org/coding-standards#comment-5262644
hth, dave
Comment #16
iamEAP commentedI've made changes to address the paren issues and the concat issue. I believe I've also taken care of the newline issues.
I appreciate your reviews Dave; however the process of being beaten over the head with extremely minor stylistic issues that's been going on (for nearly a month now) has left me pretty dissatisfied overall with the project application process (almost to the point of being disinterested in my project and contributing generally). This isn't a complaint against you, just a complaint about the process generally.
Comment #17
djg_tram commentedI feel your pain... :-) As someone with 25+ years of programming experience, I also have my own PHP coding style, which usually is not that far from the Drupal standards, actually, quite close in important issues while I also consider some minor requirements pretty moot. For instance, the 80-char line length limit in files when today's monitors usually show 250 or more in a line is very aged and really can't be justified any more.
But you have to view the process in its entirety. First, reviewers are scarce. Many automated tests are copied into the issue queues by fellow applicants waiting for their approval themselves. We have the right to comment on other people's projects, run the git through the automaton but not to decide in deeper code issues or about the overall worthiness of the project. We might have the knowledge but not the right. There are very different kinds of people waiting for their approval here, some of us have dozens of modules behind our backs, long experience in programming, only never needed to apply for contrib rights before. Others might really be fighting with the very first Drupal (or even PHP) module of their lives. The process still has to accommodate all of us.
Besides, there is no straight documentation on how to get a project approved. There are various bits in various places, but not a single description from git or contents of .info files to the automated code reviewers. The veteran reviewers only could tell us why but I have an inkling that this isn't purely due to lack of somebody collecting and writing it. It seems to me more like an intentional hurdle: collecting all pieces of information and presenting our test projects in the first place must be the first grade.
Still, there is one point that should be worked upon but, as I understand, it is fairly new in the review process, that's why it's not really advertised yet in the What to Do for Approval descriptions: these automated test tools. It would really spare a lot of grief if applicants could be sent to Ventral in the first place (provided the infrastructure is sufficient to cope with it). Let them test their projects and apply for approval when the code comes out clean. Let them know up front that this will be the entry test, so there is no point in presenting their projects before the test script returns a blank list of problems.
But as to the actual issues pointed out, we know we don't always agree with every point. Also, there are occasional glitches in the tools themselves, turning up an error where there isn't any. Still, this is something like a university exam. We might do things slightly differently later on but still we have to show that we can adapt to requirements and play by the rules, at least once...
Comment #18
bailey86 commentedI would say that the challenge is to get the automated tools working on your local system - that way you can fully test your code yourself and make sure there are absolutely no errors in your code.
There are basically three tools which should be used to review your code.
1. Install the modules coder and coder_tough_love. These tests can then be run by going to the module list and selecting 'Code review'.
2. Install pareview_sh module - then it should be possible to get the review running with
sites/all/modules/pareview_sh> ./pareview.sh ../data_export_import 6.x-1.xThe output is in HTML format but you should be able to pipe it into a file for easy review via a browser etc.
3. Install phpcs - this does not need to bootstrap a drupal instance - so can be used from the command line on a locally downloaded copy of the module.
phpcs --standard=DrupalCodingStandard --extensions=php,module,inc,install,test,profile,theme ~/tmp/smoothscroll/smoothscroll/What I'll try to do is to document this a bit more and add it as a comment on the review process.
Also, you should use http://ventral.org/pareview - I'm not sure if this runs the full suite of coder, coder_tough_love, pareview.sh, phpcs - but it's a really useful resource.
Comment #19
djg_tram commentedI would add that as long as some of the tools assume a Unix environment, this can't really be prescribed. Only those running under Drupal are really viable: after all, everybody developing a module has a Drupal to run and test it on...
Comment #20
iamEAP commentedI think what would be most useful is a set of goals, or at the very least, a summary paragraph explaining the goals of the project application review process.
Obviously it's understood that the end goal is to ensure that contributions meet a certain standard and functional duplication is minimized, but an explanation of how the current review process accomplishes that would be great and could provide insight into what areas prospective applicants should focus their efforts.
Comment #21
bailey86 commentedI would suggest that Drupal is primarily developed and hosted on the LAMP stack - it can be made to work with Windows but that's the minority.
It would probably be better in the long term to get hold of an Ubuntu disk and work on Drupal from there - possibly as a Vmware session under Windows. Otherwise you may spend the next several years bumping up against the limitations of running Drupal on Windows.
Comment #22
djg_tram commentedI never host Drupal on Windows for sure, I'm not that much of a masochist... :-) But development is something quite different. For minor things, you simply edit your PHP files and upload to the server. A PHP is a PHP is a PHP, it makes no difference what platform you type it on (OK, there are CRLF troubles with Git but those can be solved). And for more involved development where I prefer local work and not to upload every other second, I always use Windows running in a VM, under Wampserver. The opsystem is Windows but the environment Drupal sees, AMP is perfectly the same, so I never had the slightest problem with it (and although this is the first time I apply for approval, this is not the first module I write, very far from it :-) ).
I do have an Ubuntu in a VM, of course (I'd even work on it as a full install, I started with Linux in 1994 :-), but as I'm also active in desktop publishing and that's about the only major area that's still practically non-existent on Linux, so that's the way it is, I'm stuck with it).
Comment #23
doublejosh commentedSo anyway, what about this "Page Cache Clear Button" module? :)
Looking forward to it.
Comment #24
iamEAP commentedUpping priority to critical as per the Review Process docs:
http://drupal.org/node/539608
Comment #25
klausiComment #26
iamEAP commentedA module was recently created that purports to do exactly what I set out to do, so I'm going to put my energy into helping the maintainer.
http://drupal.org/project/flush_page_cache
Closing this issue. I would still like full project permissions, but I'll submit a different module from my sandbox pool for that.
Thanks, all.
Comment #27
bailey86 commentedIf you want to use Windows then that's up to you. I was just pointing out that getting the code review tools to run under Windows would be either a PITA or impossible.
Anyway, after much pushing on my part I've helped with the coding reviews which you were finding conflicting and problematic (as I was).
Basically, it is now sort of accepted that if your code passes the review tool at http://www.ventral.org/pareview then since that combines the current automatic tools you code can be considered to be formatted properly.
Comment #27.0
bailey86 commentedAdding a "background" section for better context.