Created
November 12, 2012 12:15
-
-
Save kalabro/4059050 to your computer and use it in GitHub Desktop.
Drupal 7: download missing modules with Drush
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env drush | |
<?php | |
/** | |
* Download modules which are not found on disk but exist in system table. | |
* Tested on Drupal 7. | |
*/ | |
$result = db_query('SELECT * FROM system ORDER BY name'); | |
foreach ($result as $record) { | |
if (!file_exists($record->filename)) { | |
$path = drupal_get_filename($record->type, $record->name); | |
if (empty($path)) { | |
// Project not found in Drupal installation. | |
// Trying to download. | |
if (drush_invoke_process('@self', 'dl', array($record->name))) { | |
$downloaded_projects[] = $record->name; | |
} | |
} | |
} | |
} | |
registry_rebuild(); | |
if (!empty($downloaded_projects)) { | |
drush_log(dt('Downloaded @projects', array('@projects' => implode(', ', $downloaded_projects))), 'ok'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment