Skip to content

Instantly share code, notes, and snippets.

@delphian
Last active December 29, 2015 02:48
Show Gist options
  • Select an option

  • Save delphian/7602731 to your computer and use it in GitHub Desktop.

Select an option

Save delphian/7602731 to your computer and use it in GitHub Desktop.

Revisions

  1. delphian revised this gist Nov 22, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion touch-all-fids.php
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    */

    // Needed for multisite bootstrap.
    $_SERVER['HTTP_HOST'] = 'localhost';
    $_SERVER['HTTP_HOST'] = 'my-site-name.com';
    $_SERVER['SCRIPT_NAME'] = '/' . 'touch-all-fids.php';

    // Bootstrap drupal.
  2. delphian revised this gist Nov 22, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion touch-all-fids.php
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,8 @@
    * 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.
    * drupal database. In a multi-site environment this script should be
    * located in the drupal root.
    *
    * bryan.hazelbaker@gmail.com
    */
  3. delphian revised this gist Nov 22, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions touch-all-fids.php
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

    function touch_all_fids() {
    function drupal_touch_all_fids() {
    $fids = array();
    $result = db_query('SELECT * FROM file_managed');
    foreach($result as $row) {
    @@ -29,4 +29,4 @@ function touch_all_fids() {
    }
    }

    touch_all_fids();
    drupal_touch_all_fids();
  4. delphian created this gist Nov 22, 2013.
    32 changes: 32 additions & 0 deletions touch-all-fids.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    <?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.
    *
    * bryan.hazelbaker@gmail.com
    */

    // Needed for multisite bootstrap.
    $_SERVER['HTTP_HOST'] = 'localhost';
    $_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 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));
    }
    }

    touch_all_fids();