0

I have an issue in my site which is not allowing me to visit the /en/admin/content/media page.

I'm looking for an approach to list and delete media entities on the command line.

When I run drupal debug:entity media I get an error:

[ERROR] <em class="placeholder">Notice</em>: Undefined index: media in <em                                     
         class="placeholder">Drupal\Console\Command\Debug\EntityCommand-&gt;execute()</em> (line <em            
         class="placeholder">79</em> of <em                                                                     
         class="placeholder">/home/ubuntu/site/vendor/drupal/console/src/Command/Debug/EntityCommand.php</em> 
         ). <pre class="backtrace">Drupal\Console\Command\Debug\EntityCommand-&gt;execute(Object, Object)       
         (Line: 255)                                                                                            
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 971)                          
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 248)             
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)                            
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)                                   
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)                                       
         Symfony\Component\Console\Application-&gt;run() (Line: 89)                                             
         require(&#039;/home/ubuntu/site/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)                
         </pre>

The docs of this command is also really uninformative.

What's the best approach to list and delete media entities on the command line?

1
  • 1
    If you want to do it with code try this $media_ids = \Drupal::entityQuery('media') ->execute(); foreach ($media_ids as $id => $media_id){ $media = Media::load($media_id); $media->delete(); } – berramou Jan 29 '19 at 14:00
-1

If you use Drush, you can try drush sql-query like this :
drush sql-query "Delete from name_table weher condition"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.