Problem/Motivation

I executed drush node-revision-delete resources 1(where resources could be any content type) and received:

WD php: ArgumentCountError: Too few arguments to function node_revision_delete_batch_process(), 3 passed in vendor/drush/drush/commands/core/drupal/batch.inc on line 163 and exactly 6 expected in node_revision_delete_batch_process() (line 11 of                                                                             
/var/www/html/sites/all/modules/node_revision_delete/node_revision_delete.batch.inc).
Drush command terminated abnormally due to an unrecoverable error.

Proposed resolution

Function drush_node_revision_delete() passes just $content_type and $revisions_to_keep arguments to node_revision_delete_batch_process()
instead of 6 arguments. Adding missing arguments drush_node_revision_delete() should fix the bug.

Remaining tasks

Add more examples (Will be do in #2913654: Add examples for the drush node-revision-delete command and maybe when the command will be functional in the 8.x module version).

User interface changes

None.

API changes

Added 3 params to the drush node-revision-delete command:

  • minimum_age_to_delete (integer)
  • when_to_delete (integer)
  • dry_run (boolean, optional)

This is the new command definition:

  $items['node-revision-delete'] = array(
    'description' => dt('Deletes old node revisions for a given content type.'),
    'arguments' => array(
      'type' => dt('Content type machine name.'),
      'minimum_revisions_to_keep' => dt('Minimum number of revisions to keep.'),
      'minimum_age_to_delete' => dt('Minimum age of revisions to be deleted.'),
      'when_to_delete' => dt('Minimum inactivity age to wait for delete a revision.'),
      'dry_run' => dt('Test run without deleting revisions but seeing the output results.'),
    ),
    'examples' => array(
      // @TODO: Add more examples.
      'drush nrd article 50' => dt('Keeps the latest 50 revisions of every article. Deletes the rest.'),
    ),
    'aliases' => array('nrd'),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
  );

Now the equivalent to keep one revision for each article content will be the command:

drush node-revision-delete article 1 0 0

Data model changes

None.

Comments

dmitryl created an issue. See original summary.

adriancid’s picture

Assigned: Unassigned » adriancid
Issue tags: +drush

Hi @dmitryl, thanks for reporting, would be great if the next time you use the Issue Summary Template to report an issue.

I see that in #2892807: Use the minimum_age_to_delete and when_to_delete variables to delete revisions we forget to update the drush command, I will work on this in the next days and will fix the problem.

adriancid’s picture

Title: Too few arguments for node-revision-delete » Too few arguments for node-revision-delete drush command
dmitryl’s picture

Issue summary: View changes

Thanks @adriancid, I'll do. I have updated the current report as well.

adriancid’s picture

Issue summary: View changes

  • adriancid committed 8511c47 on 7.x-3.x
    Issue #2911541 by dmitryl, adriancid: Too few arguments for node-...
adriancid’s picture

Issue summary: View changes
Status: Active » Fixed

Hi @dmitryl you made me work a lot :-)

Well I think that the problem is fixed, I will improve the command after the 8.x final release, but for the moment is functional, just let me know if now all works for you, see the issue description because now you need to use something like this:

drush node-revision-delete resources 1 0 0

to keep only one revision for each resource node.

adriancid’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

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