Posted by arrays on November 5, 2010 at 7:53am
6 followers
| Project: | Devel |
| Version: | 7.x-1.x-dev |
| Component: | devel_generate |
| Category: | feature request |
| Priority: | normal |
| Assigned: | arrays |
| Status: | needs work |
| Issue tags: | devel patch |
Issue Summary
Hi,
While using devel for one of my projects. i came across a situation where i wanted to generate bulk content for a particular user only, say xyz with user id 2 or 3 or whatever. I could not find a way to do so in the current devel module. I searched issue queues too but could not find a way.
Then i write a small patch to provide the same functionality, which I would like to contribute.
Find the patch below.
Regards,
Aradhana
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| devel_generate.patch | 1.34 KB | Idle | FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate_5.patch. | View details | Re-test |
| devel_generate_inc.patch | 878 bytes | Idle | FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate_inc.patch. | View details | Re-test |
Comments
#1
The last submitted patch, devel_generate_inc.patch, failed testing.
#2
Resubmitting patch against latest version.
#3
The last submitted patch, devel_generate_inc.patch, failed testing.
#4
#5
Needs to show up in the UI and in drush. Also should go into D7 at same time.
#6
Hi Moshe,
I did not get your point "Needs to show up in the UI and in drush. Also should go into D7 at same time." Can you please explain a bit?
Regards,
Aradhana
#7
Sorry, I only looked at one patch. The other had the form stuff. Please enhance form description so that folks know what happens when they omit that field. Also, needs a drush option for genu command.
If you can, try to include all the changes in one file. See http://drupal.org/patch/create. If not, is OK.
#8
Thanks for the reply :)
Lemme review it again and will submit the modified files.
Thanks.
#9
Hi Moshe,
Made the necessary changes and resubmitting the file. Please see if it can be approved.
Thanks in Advance. :)
Aradhana
#10
#11
Please name it .patch, so that the testbot will pick it up. The testbot is your friend.
#12
Awesome work !! I was about to pull my hair off on this.
Just to give out a helping hand, I have aggregated the patch and re-submitted it. The patch is against the 6.x-1.x-dev branch's codebase.
Love & Drupal
sudhirporwal
#13
Thanks Sudhir for your help.
I am glad that you find this patch helpful. :)
Regards,
Aradhana
#14
The patch in #12 is missing half of what was in #9. It cured some of the formatting errors (e.g. missing space after if), but it introduced new ones.
I think we should go with arrays' patch, but please re-upload it with the .patch extension, so that it can be tested and reviewed. Follow the http://drupal.org/coding-standards. Get it to pass through the testbot and look at it with Dreditor.
#15
apologies, i took the wrong patch as the base. i will fix it as soon i get in front on my desktop.
Love & Drupal
sudhirporwal
#16
Resubmitting patch again.
#17
#16 has 7 new lines with trailing spaces or tabs.
Other than that it looks reasonable, but someone more familiar with devel_generate will have to look at it.
#18
Resubmitting it after removing extra spaces and tabs.
Thanks.
Aradhana
#19
New code gets committed first for Drupal 7 and then for D6. So, we need two patches here. Sorry for not being clearer #5.
#20
Hi,
I am submitting the patch in d7. Patch for d6 is in the last second comment above this comment.
Please find the attached patch for d7.
Regards,
Aradhana
#21
#22
The last submitted patch, devel_generate.963034-d7_1.patch, failed testing.
#23
#24
#20: devel_generate.963034-d7_1.patch queued for re-testing.
#25
The last submitted patch, devel_generate.963034-d7_1.patch, failed testing.
#26
Please re-roll #20 against HEAD.
#27
#18 no longer applies cleanly to 6.x-1.x-dev
Here's a fresh copy
Leaving on needs work since the 7.x-1.x version of the patch still must be done.
#28
#29
The last submitted patch, 6.x-devel_generate.963034_27.patch, failed testing.
#30
resubmitting the 7.x patch only to appease testbot.
#31
+++ b/devel_generate/devel_generate.drush.inc@@ -47,6 +47,7 @@ function devel_generate_drush_command() {
+ 'user_ref' => 'Username for whom you want to create content.',
Is there a reason for calling the user name argument 'user_ref' rather than 'user_name'?
Drupal guidelines call for avoiding addressing the user directly, if possible — just drop "you want".
+++ b/devel_generate/devel_generate.drush.inc@@ -123,7 +124,7 @@ function drush_devel_generate_vocabs($num_vocab = 1) {
-function drush_devel_generate_content($num_nodes = NULL, $max_comments = NULL) {
+function drush_devel_generate_content($user_ref = NULL, $num_nodes = NULL, $max_comments = NULL) {
Shouldn't the new parameter be added at the end rather than at the beginning, to avoid breaking an API.
+++ b/devel_generate/devel_generate.drush.inc@@ -142,7 +143,12 @@ function drush_devel_generate_content($num_nodes = NULL, $max_comments = NULL) {
+ if(!empty($user_ref) ) {
Drupal Coding Guidelines call for a space after 'if', but not inside the closing brace.
+++ b/devel_generate/devel_generate.drush.inc@@ -142,7 +143,12 @@ function drush_devel_generate_content($num_nodes = NULL, $max_comments = NULL) {
+ $user_one = user_load(array('name' => $user_ref));
Since it's not necessarily user 1, let's call it $account.
+++ b/devel_generate/devel_generate.drush.inc@@ -154,7 +160,7 @@ function drush_devel_generate_content($num_nodes = NULL, $max_comments = NULL) {
- drush_log(t('Generated @num_nodes nodes, @max_comments comments (or less) per node.', array('@num_nodes' => (int)$num_nodes, '@max_comments' => (int)$max_comments)), 'success');
+ drush_log(dt('Generated @num_nodes nodes for @user_ref user, @max_comments comments per node', array('@user_ref'=>$user_ref, '@num_nodes' => $num_nodes, '@max_comments' => $max_comments)), 'ok');
You've made a number of changes that may not necessarily be beneficial:
Also add spaces around '=>'.
+++ b/devel_generate/devel_generate.inc@@ -672,7 +678,13 @@ function devel_generate_content_add_node(&$results) {
+ if (isset($results['user_ref']) && !empty($results['user_ref']) ) {
The first condition is contained in the second one. Extraneous space, too.
+++ b/devel_generate/devel_generate.inc@@ -672,7 +678,13 @@ function devel_generate_content_add_node(&$results) {
+ $user_ref = user_load(array('name' => $results['user_ref']));
Oops, let's call it $account; fix double space.
+++ b/devel_generate/devel_generate.module@@ -147,6 +147,15 @@ function devel_generate_content_form() {
+ '#title' => t('For which user you would like to create nodes?'),
+ '#description' => t('Type the username for which you want to create the content.If you leave it empty, content authors will be selected randomly.'),
Avoid addressing the user if you can, because it doesn't translate well.
Add a space between the sentences.
Lots of formal nits — someone more familiar with devel_generate and Drush needs to review and test the actual functionality.