Add drush command to rebuild index

Created on 28 August 2024, 8 months ago

Problem/Motivation

When installing this module on an existing site with several menu items we wanted to process the rebuild index job via drush instead of through the admin interface.

Proposed resolution

Add drush command so that the index can be built via cli.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand ericgsmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ericgsmith
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    I have tested this with Drush 13 / PHP 8.3

    Help command:

    drush help menu-entity-index:rebuild-index
    
    Rebuild index.
    
    Examples:
     menu-entity-index:rebuild-tracker      Rebuild the index for all tracked menus.      
     menu-entity-index:rebuild-tracker main Rebuild the index for a menu with ID of main. 
    
    Arguments:
     [menu] Menu id 
    

    Indexing without argument:

    drush menu-entity-index:rebuild-index     
    >  [notice] Scanning 131 menu links for referenced entities.
    >  [notice] Completed scanning of menu links.
    

    Indexing with argument:

    drush menu-entity-index:rebuild-index main
    >  [notice] Scanning 131 menu links for referenced entities.
    >  [notice] Completed scanning of menu links.
    

    Attempting to index menu that does not exist:

    drush menu-entity-index:rebuild-index foobar   
                                                                                                                            
     [ERROR] Menu foobar is not a valid tracked menu.        
    
  • πŸ‡«πŸ‡·France JΓ©rΓ΄me Dehorter Lille

    Hi,
    The patch works with Drupal 10.3 and MIE 8.x-1.6
    Thanks

  • πŸ‡«πŸ‡·France JΓ©rΓ΄me Dehorter Lille

    Hi,
    I use menu-entity-index:rebuild-index main to index my main menu but I need to index moderation statefor unpublished content. Index with the form works well but command menu-entity-index:rebuild-tracker not working.

    Command "menu-entity-index:rebuild-tracker" is not defined.

    Can you tell me how to do that ?

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    Looks like there is a mistake in the annotations, the example usage and actual command name do not match, I'll fix work on that

  • πŸ‡³πŸ‡ΏNew Zealand ericgsmith

    I don't know how this module integrates with content moderation (that would be outside the scope of this issue if anything is not working with it) but I've fixed the annotation which had the wrong command name in it

Production build 0.71.5 2024