Projet

Général

Profil

Révision 6eb8d15f

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/plugins/views_plugin_cache.inc
200 200
      $this->storage['head'] = '';
201 201
    }
202 202

  
203
    // Check if the advanced mapping function of D 7.23 is available.
204
    $array_mapping_func = function_exists('drupal_array_diff_assoc_recursive') ? 'drupal_array_diff_assoc_recursive' : 'array_diff_assoc';
205

  
203 206
    // Slightly less simple for CSS:
204 207
    $css = drupal_add_css();
205 208
    $css_start = isset($this->storage['css']) ? $this->storage['css'] : array();
206
    $this->storage['css'] = array_diff_assoc($css, $css_start);
209
    $this->storage['css'] = $array_mapping_func($css, $css_start);
207 210

  
208 211
    // Get javascript after/before views renders.
209 212
    $js = drupal_add_js();
210 213
    $js_start = isset($this->storage['js']) ? $this->storage['js'] : array();
211 214
    // If there are any differences between the old and the new javascript then
212 215
    // store them to be added later.
213
    $this->storage['js'] = array_diff_assoc($js, $js_start);
216
    $this->storage['js'] = $array_mapping_func($js, $js_start);
214 217

  
215 218
    // Special case the settings key and get the difference of the data.
216 219
    $settings = isset($js['settings']['data']) ? $js['settings']['data'] : array();
217 220
    $settings_start = isset($js_start['settings']['data']) ? $js_start['settings']['data'] : array();
218
    $this->storage['js']['settings'] = array_diff_assoc($settings, $settings_start);
221
    $this->storage['js']['settings'] = $array_mapping_func($settings, $settings_start);
219 222

  
220 223
    // Get difference of HTTP headers.
221
    $this->storage['headers'] = array_diff_assoc(drupal_get_http_header(), $this->storage['headers']);
224
    $this->storage['headers'] = $array_mapping_func(drupal_get_http_header(), $this->storage['headers']);
222 225
  }
223 226

  
224 227
  /**
......
253 256
  }
254 257

  
255 258
  function get_results_key() {
256
    global $user;
257

  
258 259
    if (!isset($this->_results_key)) {
259

  
260
      $build_info = $this->view->build_info;
261

  
262
      $query_plugin = $this->view->display_handler->get_plugin('query');
263

  
264
      foreach (array('query','count_query') as $index) {
265
        // If the default query back-end is used generate SQL query strings from
266
        // the query objects.
267
        if ($build_info[$index] instanceof SelectQueryInterface) {
268
          $query = clone $build_info[$index];
269
          $query->preExecute();
270
          $build_info[$index] = (string) $query;
271
        }
272
      }
273
      $key_data = array(
274
        'build_info' => $build_info,
275
        'roles' => array_keys($user->roles),
276
        'super-user' => $user->uid == 1, // special caching for super user.
277
        'language' => $GLOBALS['language']->language,
278
        'base_url' => $GLOBALS['base_url'],
279
      );
280
      foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) {
281
        if (isset($_GET[$key])) {
282
          $key_data[$key] = $_GET[$key];
283
        }
284
      }
285

  
286
      $this->_results_key = $this->view->name . ':' . $this->display->id . ':results:' . md5(serialize($key_data));
260
      $this->_results_key = $this->view->name . ':' . $this->display->id . ':results:' . $this->get_cache_key();
287 261
    }
288 262

  
289 263
    return $this->_results_key;
290 264
  }
291 265

  
292 266
  function get_output_key() {
293
    global $user;
294 267
    if (!isset($this->_output_key)) {
295 268
      $key_data = array(
296
        'result' => $this->view->result,
297
        'roles' => array_keys($user->roles),
298
        'super-user' => $user->uid == 1, // special caching for super user.
299 269
        'theme' => $GLOBALS['theme'],
300
        'language' => $GLOBALS['language']->language,
301
        'base_url' => $GLOBALS['base_url'],
302 270
      );
303

  
304
      $this->_output_key = $this->view->name . ':' . $this->display->id . ':output:' . md5(serialize($key_data));
271
      $this->_output_key = $this->view->name . ':' . $this->display->id . ':output:' . $this->get_cache_key($key_data);
305 272
    }
306 273

  
307 274
    return $this->_output_key;
308 275
  }
276

  
277
  /**
278
   * Returns cache key.
279
   *
280
   * @param array $key_data
281
   *   Additional data for cache segmentation and/or overrides for default
282
   *   segmentation.
283
   *
284
   * @return string
285
   */
286
  function get_cache_key($key_data = array()) {
287
    global $user;
288

  
289
    $key_data += array(
290
      'roles' => array_keys($user->roles),
291
      'super-user' => $user->uid == 1, // special caching for super user.
292
      'language' => $GLOBALS['language']->language,
293
      'base_url' => $GLOBALS['base_url'],
294
    );
295

  
296
    if (empty($key_data['build_info'])) {
297
      $build_info = $this->view->build_info;
298
      foreach (array('query','count_query') as $index) {
299
        // If the default query back-end is used generate SQL query strings from
300
        // the query objects.
301
        if ($build_info[$index] instanceof SelectQueryInterface) {
302
          $query = clone $build_info[$index];
303
          $query->preExecute();
304
          $key_data['build_info'][$index] = array(
305
            'sql' => (string) $query,
306
            'arguments' => $query->getArguments(),
307
          );
308
        }
309
      }
310
    }
311
    $key = md5(serialize($key_data));
312
    return $key;
313
  }
309 314
}
310 315

  
311 316
/**

Formats disponibles : Unified diff