Download & Extend

Generate Content for a particular user

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

AttachmentSizeStatusTest resultOperations
devel_generate.patch1.34 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate_5.patch.View details | Re-test
devel_generate_inc.patch878 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate_inc.patch.View details | Re-test

Comments

#1

Status:needs review» needs work

The last submitted patch, devel_generate_inc.patch, failed testing.

#2

Version:6.x-1.6» 6.x-1.x-dev
Status:needs work» needs review

Resubmitting patch against latest version.

AttachmentSizeStatusTest resultOperations
devel_generate.patch827 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate_6.patch.View details | Re-test
devel_generate_inc.patch837 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate_inc_0.patch.View details | Re-test

#3

Status:needs review» needs work

The last submitted patch, devel_generate_inc.patch, failed testing.

#4

AttachmentSizeStatusTest resultOperations
devel_generate.txt827 bytesIgnored: Check issue status.NoneNone
devel_generate_inc.txt837 bytesIgnored: Check issue status.NoneNone

#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

AttachmentSizeStatusTest resultOperations
devel_generate.txt4.28 KBIgnored: Check issue status.NoneNone

#10

Status:needs work» needs review

#11

Status:needs review» needs work

Please name it .patch, so that the testbot will pick it up. The testbot is your friend.

#12

Status:needs work» needs review

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

AttachmentSizeStatusTest resultOperations
devel_generate.963034_1.patch1.99 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details | Re-test

#13

Thanks Sudhir for your help.

I am glad that you find this patch helpful. :)

Regards,
Aradhana

#14

Status:needs review» needs work

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

Status:needs work» needs review

Resubmitting patch again.

AttachmentSizeStatusTest resultOperations
devel_generate.963034_2.patch4.67 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details | Re-test

#17

Status:needs review» needs work

#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

Status:needs work» needs review

Resubmitting it after removing extra spaces and tabs.

Thanks.
Aradhana

AttachmentSizeStatusTest resultOperations
devel_generate.963034_3.patch4.64 KBIdlePASSED: [[SimpleTest]]: [MySQL] 188 pass(es).View details | Re-test

#19

Status:needs review» needs work

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

AttachmentSizeStatusTest resultOperations
devel_generate.963034-d7_1.patch4.13 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate.963034-d7_1.patch.View details | Re-test

#21

Status:needs work» needs review

#22

Status:needs review» needs work

The last submitted patch, devel_generate.963034-d7_1.patch, failed testing.

#23

Version:6.x-1.x-dev» 7.x-1.x-dev
Status:needs work» needs review

#24

#20: devel_generate.963034-d7_1.patch queued for re-testing.

#25

Status:needs review» needs work

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.

AttachmentSizeStatusTest resultOperations
devel_generate.963034_27.patch3.46 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch devel_generate.963034_27.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details | Re-test

#28

Status:needs work» needs review
AttachmentSizeStatusTest resultOperations
7.x-devel_generate.963034_27.patch4.39 KBIdlePASSED: [[SimpleTest]]: [MySQL] 2 pass(es).View details | Re-test
6.x-devel_generate.963034_27.patch3.46 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 6.x-devel_generate.963034_27.patch. This may be a -p0 (old style) patch, which is no longer supported by the testbots.View details | Re-test

#29

Status:needs review» needs work

The last submitted patch, 6.x-devel_generate.963034_27.patch, failed testing.

#30

Status:needs work» needs review

resubmitting the 7.x patch only to appease testbot.

AttachmentSizeStatusTest resultOperations
7.x-devel_generate.963034_27.patch4.39 KBIdlePASSED: [[SimpleTest]]: [MySQL] 2 pass(es).View details | Re-test

#31

Status:needs review» needs work

+++ 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:

  • removed the period at the end of the message,
  • removed the "(or less)",
  • changed 'success' to 'ok'.

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.

nobody click here