Closed (fixed)
Project:
Drupal.org security advisory coverage applications
Component:
module
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
8 Jan 2012 at 16:23 UTC
Updated:
21 Jul 2012 at 10:31 UTC
The objective of this module is to provide a drush extension allows developers to quickly clone modules or features to speed up writing code reusing custom templates or creating custom entity models using the Model Entities module.
This module was inspired by the Features clone module.
Clone a module:
drush module-clone <src_module_name> <target_module_name>
Clone a feature:
drush feature-clone <src_feature_name> <target_feature_name>
Clone a model:
drush model-clone <target_entity_name>
http://drupal.org/sandbox/lucor/1397300
git clone --branch 7.x-1.x lucor@git.drupal.org:sandbox/lucor/1397300.git drush_clone
Drupal 7
Comments
Comment #1
martinbutt commentedReview of the 7.x-1.x branch:
Drupal Code Sniffer has found some code style issues (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.
FILE: ...al-7-pareview/sites/all/modules/pareview_temp/test_candidate/README.txt
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
2 | WARNING | Line exceeds 80 characters; contains 86 characters
--------------------------------------------------------------------------------
FILE: ...ew/sites/all/modules/pareview_temp/test_candidate/drush_clone.drush.inc
--------------------------------------------------------------------------------
FOUND 20 ERROR(S) AND 1 WARNING(S) AFFECTING 15 LINE(S)
--------------------------------------------------------------------------------
4 | ERROR | The second line in the file doc comment must be " * @file"
6 | ERROR | Missing function doc comment
95 | WARNING | Line exceeds 80 characters; contains 90 characters
96 | ERROR | Inline comments must end in full-stops, exclamation marks, or
| | question marks
102 | ERROR | else must start on a new line
103 | ERROR | Inline comments must end in full-stops, exclamation marks, or
| | question marks
112 | ERROR | There must be an empty line before the parameter block
112 | ERROR | Last parameter comment requires a blank newline after it
112 | ERROR | Parameter comment must be on the next line at position 1
113 | ERROR | Missing comment for @return statement
116 | ERROR | No space before comment text; expected "// File extensions we
| | need to handle." but found "//File extensions we need to
| | handle."
123 | ERROR | There must be an empty line before the parameter block
123 | ERROR | Last parameter comment requires a blank newline after it
123 | ERROR | Parameter comment must be on the next line at position 1
124 | ERROR | Missing comment for @return statement
127 | ERROR | No space before comment text; expected "// File extensions we
| | need to handle." but found "//File extensions we need to
| | handle."
134 | ERROR | There must be an empty line before the parameter block
134 | ERROR | Parameter comment must be on the next line at position 1
135 | ERROR | Last parameter comment requires a blank newline after it
135 | ERROR | Parameter comment must be on the next line at position 2
136 | ERROR | Return comment must be on the next line
--------------------------------------------------------------------------------
Source: http://ventral.org/pareview - PAReview.sh online service
Comment #2
lucor commentedFixed code style issues
Comment #3
andrewyager commentedIs there any difference between your implementation of feature-clone and the existing one? It would be nice to have all of these in one module, but does this make the two mutually exclusive? (i.e. will drush break when I install your module and the features-clone module?)
Comment #4
andrewyager commentedComment #5
lucor commentedThe mainly difference in the implementation is the Drupal version target. Drush clone is build using Drupal 7 API and no conflicts are possible with the Features-clone module since it supports only Drupal 6 at the moment.
BTW, in the future, an eventual backport to Drupal 6 of Drush clone will coexist with a Features clone installation.
Comment #6
andrewyager commentedThanks for clarifying. When running with drush 7.x-4.5 the extra commands you have added appear in my drush help, but the individual commands do not execute (can not be found).
Are any additional steps required to get this working?
Comment #7
andrewyager commentedComment #8
lucor commenteddrush_clone is a drush command so the installation steps are different than module installation.
The simplest way to do it is:
drush dl drush_clonethe command must be executed outside any Drupal project (i.e. in your user home).
Please note this command could be executed when drush_clone will be an official module, in the meanwhile you can clone the repo or copy the drush_clone folder in:
a) In a .drush folder in your HOME folder. Note, that you have to create the .drush folder yourself.
b) In the system-wide Drush commands folder, e.g. /usr/share/drush/commands
More detailed install instructions can be found at
http://drupalcode.org/project/drush.git/blob/HEAD:/README.txt.
It contains a section (COMMANDS) about installing other commands like
drush_clone.
BTW I've added the INSTALL.txt to the git repo.
Thanks to report it.
Comment #9
andrewyager commentedThanks for the tips regarding where this has to be to work. I'm used to Drush commands that are part of modules and so normally place them inside the sites/all/modules directory. You should make it clear in your INSTALL.txt that the only valid options for locations are the two you have mentioned above, and that the commands won't work if you place them:
it won't work as this module isn't actually attached to a full Drupal module.
Manual code review
You should modify your code to accept no arguments so as to prevent the PHP warnings regarding missing arguments.
Comment #10
andrewyager commentedComment #11
lucor commentedFixed INSTALL.txt documentation and code issues in git.
Comment #12
rudiedirkx commentedAfter 'installing':
Where's the rest?
Priority+ after 4 weeks.
Comment #13
lucor commentedMay you report your step installation and info about your env?
I've tried to install in a clean env following the INSTALL.txt and it works fine.
Comment #14
crobinson commentedNote to other reviewers: I do not have much experience with Model Entities, so I'm focusing on Features and pure code review here.
1. I'm not sure I understand the installation instructions completely. These are steps for installing on a server. But drush works just fine with Drupal modules that have Drush hooks inside a site hierarchy as long as they're enabled. Is there a reason this can't or shouldn't be used within a virtual host? If you just flesh out your INFO file this could be a standard Drupal module. (If you don't plan to release it on Drupal.org as a full module I don't understand why you would go through this process...?)
2. @file needs a more expressive comment. This is here for scripts and code tools to look for: "Provide implementation of drush command" doesn't tell me which Drush command.
3. You're obeying the 80-col limit which is good, but you don't need to be so aggressive about it. There's an exception for things like long strings especially where it improves readability to keep it on one line. This:
is preferable to this:
4. This is nit-picking, but there are some odd whitespace uses for newlines:
is more readable than:
5. You are not checking user input very much. I do not believe this is a security risk: Anybody with Drush access can do whatever they want with a site so the usual check_plain category of checks is probably a waste of time.
However, DUPE detection would be very handy. You don't do much in the way of checking to be sure the target doesn't already exist before overwriting it. Currently you call module_exists but that only returns true if the module is enabled. What if it's there but not enabled? What if I clone, modify some code in the new clone, and then accidentally re-clone? My work gets overwritten.
6. You do not copy recursively. If I try to clone a module with subdirectories (templates are very common) this fails.
7. You should probably also check to be sure $source != $target.
8. The behavior where I try to clone a system module is not consistent. Modules are cloned to and from the same path, so if I clone "user" I get modules/user_clone, where I would have expected it to go to sites/all/modules (outside core-space). Can this be an option? What about multi-site installations, too?
9. You should warn the user when copying .tpl.php files. Once the clone is enabled Drupal will scan for and find these files in the new folder automatically, which can be a problem when cloning some types of modules. I do not think you can fix this - it is up to the user to address it. But you should ask or tell them so they know.
10. I SORT OF understand why you are copying only certain extensions. But not really. Why do you not copy .txt files? What about modules with JS/CSS? Many module break without these files. Are there types of files where it actually is useful to not copy them? I think as a user I would want them all.
This looks very useful. Thank you for your contribution.
Comment #15
jlyon commentedThis has been really useful to me already! Do you think it would be possible to extend this into cloning themes. This would be really helpful for setting up "starterkits".
Comment #16
lucor commented@crobinson
1. Since this drush plugin is generic like drush_make IMHO should be installed outside the drupal dir. BTW it seems there is a hidden feature so a drush plugin (after is approved on drupal.org) could be installed in ~/.drush simply executing:
2 to 5 -> Done.
6. I'm not able to replicate the issue. I've tried to clone for example views and it seems work fine. May you give me info about the module and your env?
7. Done
8 - 9. Good point. Added to the new features list.
10. See point 6. The txt, css, js files are copied correctly. They are simply excluded by the "clone" rewrite functionality.
@jlyon Sure. Added on the new features list.
Comment #17
jlyon commentedAnother feature that would be nice for the model clone would be to be able to have different module and entity names. For example, a course_registration module that created a registration entity.
Comment #18
crobinson commented@jlyon that would be a nice feature... but because this is on hold for code review, not suggestions, that doesn't look like a blocker.
Other reviewers: the items I identified in my own review were addressed. As I said above, I'm not a Model Entities guru, but the enhancements were enough to address the points that I found.
Unfortunately, PAReview has been enhanced to look for new issues, and this project now fails those issues:
http://ventral.org/pareview/httpgitdrupalorgsandboxlucor1397300git
@patrickd and @MiSC have been correcting statuses from needs work -> needs review when this happens but only when a project hasn't had a proper, human-driven review. This project HAS had that review. So I'm marking it needs work so @lucor is alerted that they need to be addressed. After those issues are resolved this project is ready for RTBC IMHO.
Comment #19
lucor commented@crobinson I've fixed the PAReview issues. At moment there is only an error: http://ventral.org/pareview/httpgitdrupalorgsandboxlucor1397300git-7x-1x but I've not found any docs about the handling of the "@return void" in the php doc. IMHO I think it is trivial but BTW if there is a best practice please let me know and I'll fix it.
Comment #20
crobinson commentedI think you're getting this error because normally the @return comment should read:
@return [type] [comment]
as in:
@return string The formatted HTML tag
In your case you aren't returning anything so you shouldn't need this @return at all - I would try removing it and see if that passes. It is not necessary to specify @return unless you return something.
Nonetheless, all other points have been addressed from both manual and automated code review. This looks RTBC to me.
Comment #21
lucor commentedRemoving the
@return voidstatement seems to work fine: http://ventral.org/pareview/httpgitdrupalorgsandboxlucor1397300git-7x-1xComment #22
klausiWe 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 :-)
Comment #23
mitchell commentedThanks for your contribution, lucor!
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 crobinson, jlyon, andrewyager for your awesome reviews and great questions for lucor! It was very helpful to me. I encourage you to continue working together and posting issues for any potential improvements you've come across. Thanks again!