When generating 50 or more content nodes (and thus running in batch mode) the nodes types selected in the form are ignored and all node types are used. This does not happen when generating 49 or fewer, and only the selected node types are used.

For under 50 nodes the function generateContent has the following:

  /**
   * Method responsible for creating content when
   * the number of elements is less than 50.
   */
  private function generateContent($values) {
    $values['node_types'] = array_filter($values['node_types']);
    ...

However, in the equivalent batch function generateBatchContent there is no array_filter call.

  /**
   * Method responsible for creating content when
   * the number of elements is greater than 50.
   */
  private function generateBatchContent($values) {

It is easy to replicate: Use a site with two or more content types defined. Delete all content, then on the generate form select only 1 content type but generate 100 nodes. View the full contents list and you'll see some of each node type.

I can provide a patch for the missing array_filter. But maybe this needs test coverage too?

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

The new test (which I have written) will require the fix in #3076613: Undefined index: users in $result array to be committed first. Currently it is not possible to run any tests which create 50+ nodes via the batch system.

jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new768 bytes

Here's the fix to generateBatchContent() for those who want to do manual testing.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. Shall I wait for that test or commit as is?

jonathan1055’s picture

StatusFileSize
new1.28 KB

Here's the addtional part of the batch test, without the code fix, so this should fail.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 3081503-5.batch_filter_node_types.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jonathan1055’s picture

Status: Needs work » Needs review
StatusFileSize
new2.03 KB

The test failed as required:

1) Drupal\Tests\devel_generate\Functional\DevelGenerateBrowserTest::testDevelGenerateBatch
The expected number of article is 60, found 31
Failed asserting that '31' matches expected 60.

This patch #7 has the fix from #3 plus the test from #5 which should be green.

moshe weitzman’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.