Populate the use_strict field in the advagg_files table.

Fichier

./advagg.install, line 680

Code

function advagg_update_7213(&$sandbox) {
    drupal_load('module', 'advagg');
    module_load_include('inc', 'advagg', 'advagg');
    // If first run of this update function then set progress variables.
    if (!isset($sandbox['progress'])) {
        $count = db_select('advagg_files', 'af')->fields('af')
            ->condition('filetype', 'js')
            ->countQuery()
            ->execute()
            ->fetchField();
        $sandbox['progress'] = 0;
        $sandbox['max'] = $count;
    }
    // How many items should be processed per pass.
    $limit = 10;
    $query = db_select('advagg_files', 'af')->fields('af')
        ->condition('filetype', 'js')
        ->range($sandbox['progress'], $limit)
        ->execute();
    foreach ($query as $row) {
        $row->use_strict = (int) advagg_does_js_start_with_use_strict($row->filename);
        if (!empty($row->use_strict)) {
            $write = (array) $row;
            db_merge('advagg_files')->key(array(
                'filename_hash' => $write['filename_hash'],
            ))
                ->fields($write)
                ->execute();
        }
    }
    // Update our progress information.
    $sandbox['progress'] += $limit;
    // Set the value for finished.
    $sandbox['#finished'] = $sandbox['progress'] >= $sandbox['max'] ? TRUE : $sandbox['progress'] / $sandbox['max'];
    if ($sandbox['#finished']) {
        return t('The use_strict field has been populated inside the advagg_files table.');
    }
}