Last active
December 29, 2015 02:48
-
-
Save delphian/7602731 to your computer and use it in GitHub Desktop.
When working on a drupal site on localhost instead of production often there are no files in the localhost files directory. This script will create (touch) empty filenames that match all files managed by the drupal database.
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
<?php | |
/** | |
* @file | |
* When working on a drupal site on localhost instead of production often | |
* there are no files in the localhost files directory. This script will | |
* create (touch) empty filenames that match all files managed by the | |
* drupal database. In a multi-site environment this script should be | |
* located in the drupal root. | |
* | |
* [email protected] | |
*/ | |
// Needed for multisite bootstrap. | |
$_SERVER['HTTP_HOST'] = 'my-site-name.com'; | |
$_SERVER['SCRIPT_NAME'] = '/' . 'touch-all-fids.php'; | |
// Bootstrap drupal. | |
$_SERVER['REMOTE_ADDR'] = ''; | |
define('DRUPAL_ROOT', '/absolute/path/to/drupal/root'); | |
require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; | |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); | |
function drupal_touch_all_fids() { | |
$fids = array(); | |
$result = db_query('SELECT * FROM file_managed'); | |
foreach($result as $row) { | |
print($row->fid . "\r"); | |
touch(drupal_realpath($row->uri)); | |
} | |
} | |
drupal_touch_all_fids(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment