Hello

I have updated to domain views 7.x-1.5 today and have a problem with the "Time-based Per Domain" cache in Views:
My views have several exposed filters, that are in an external block (views setting "Exposed form in block"). Once I activate the "Time-based Per Domain"-cache, my views do not filter their content by these exposed filters any more. The views always show the same content, independent of the filters that are used.

If I deactivate the "Time-based Per Domain"-cache, my views work normally again and filter the content by the exposed filters.
I used domain views 7.x-1.4 until yesterday, and with that version, the "Time-based Per Domain"-cache worked correctly.

Any idea what is causing that problem?

I am using Drupal 7.18, Views 7.x-3.5, Domain Access 7.x-3.7, Domain Views 7.x-1.5. I cleared the drupal cache several times after updating the module.

Comments

agentrickard’s picture

It is likely related to #1705168: The cache class is always nonsense by using view->build_info to create a cache key.

Please export and attach the View here.

Phoenix2020’s picture

All the views of my website have this problem. Here is one example view:

$view = new view();
$view->name = 'Camping';
$view->description = '';
$view->tag = '';
$view->base_table = 'node';
$view->human_name = '';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['title'] = 'Camping- und Zeltplätze in Hamburg';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'Weiter';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'time_per_domain';
$handler->display->display_options['cache']['results_lifespan'] = '21600';
$handler->display->display_options['cache']['output_lifespan'] = '21600';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Anwenden';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Zurücksetzen';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Sortieren nach';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '25';
$handler->display->display_options['pager']['options']['tags']['first'] = '« erste Seite';
$handler->display->display_options['pager']['options']['tags']['previous'] = '‹ vorherige Seite';
$handler->display->display_options['pager']['options']['tags']['next'] = 'nächste Seite ›';
$handler->display->display_options['pager']['options']['tags']['last'] = 'letzte Seite »';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['override'] = FALSE;
$handler->display->display_options['exposed_block'] = TRUE;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['text']['id'] = 'area';
$handler->display->display_options['empty']['text']['table'] = 'views';
$handler->display->display_options['empty']['text']['field'] = 'area';
$handler->display->display_options['empty']['text']['content'] = '<strong><em>Leider wurde kein passender Camping- oder Zeltplatz gefunden.</em></strong>';
$handler->display->display_options['empty']['text']['format'] = '1';
/* Feld: Inhalt: Titel */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = 'Name';
/* Feld: Ort: Stadt */
$handler->display->display_options['fields']['city']['id'] = 'city';
$handler->display->display_options['fields']['city']['table'] = 'location';
$handler->display->display_options['fields']['city']['field'] = 'city';
$handler->display->display_options['fields']['city']['label'] = 'Ort';
/* Sort criterion: Inhalt: Titel */
$handler->display->display_options['sorts']['title']['id'] = 'title';
$handler->display->display_options['sorts']['title']['table'] = 'node';
$handler->display->display_options['sorts']['title']['field'] = 'title';
/* Contextual filter: Global: Null */
$handler->display->display_options['arguments']['null']['id'] = 'null';
$handler->display->display_options['arguments']['null']['table'] = 'views';
$handler->display->display_options['arguments']['null']['field'] = 'null';
$handler->display->display_options['arguments']['null']['default_action'] = 'default';
$handler->display->display_options['arguments']['null']['exception']['title_enable'] = TRUE;
$handler->display->display_options['arguments']['null']['title_enable'] = TRUE;
$handler->display->display_options['arguments']['null']['title'] = '%1';
$handler->display->display_options['arguments']['null']['breadcrumb_enable'] = TRUE;
$handler->display->display_options['arguments']['null']['breadcrumb'] = '%1';
$handler->display->display_options['arguments']['null']['default_argument_type'] = 'php';
$handler->display->display_options['arguments']['null']['default_argument_options']['code'] = '$titel = "Camping- und Zeltplätze in Hamburg";

if ($_SERVER[HTTP_HOST] == "www.domain2.de") {$titel = "Camping- und Zeltplätze in Berlin";}
if ($_SERVER[HTTP_HOST] == "www.domain3.de") {$titel = "Camping- und Zeltplätze in Sylt";}

return $titel;';
$handler->display->display_options['arguments']['null']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['null']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['null']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['null']['specify_validation'] = TRUE;
$handler->display->display_options['arguments']['null']['validate']['type'] = 'php';
$handler->display->display_options['arguments']['null']['validate']['fail'] = 'ignore';
/* Filter criterion: Inhalt: Veröffentlicht */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = '1';
/* Filter criterion: Inhalt: Typ */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  0 => 'camping',
);
/* Filter criterion: Domain Access: Available on current domain */
$handler->display->display_options['filters']['current_all']['id'] = 'current_all';
$handler->display->display_options['filters']['current_all']['table'] = 'domain_access';
$handler->display->display_options['filters']['current_all']['field'] = 'current_all';
$handler->display->display_options['filters']['current_all']['value'] = '1';
$handler->display->display_options['filters']['current_all']['group'] = '0';
$handler->display->display_options['filters']['current_all']['expose']['operator'] = FALSE;
/* Filter criterion: Inhalt: Titel */
$handler->display->display_options['filters']['title']['id'] = 'title';
$handler->display->display_options['filters']['title']['table'] = 'node';
$handler->display->display_options['filters']['title']['field'] = 'title';
$handler->display->display_options['filters']['title']['operator'] = 'allwords';
$handler->display->display_options['filters']['title']['group'] = '0';
$handler->display->display_options['filters']['title']['exposed'] = TRUE;
$handler->display->display_options['filters']['title']['expose']['operator_id'] = 'title_op';
$handler->display->display_options['filters']['title']['expose']['label'] = 'Name';
$handler->display->display_options['filters']['title']['expose']['operator'] = 'title_op';
$handler->display->display_options['filters']['title']['expose']['identifier'] = 'name';
/* Filter criterion: Ort: Stadt */
$handler->display->display_options['filters']['city']['id'] = 'city';
$handler->display->display_options['filters']['city']['table'] = 'location';
$handler->display->display_options['filters']['city']['field'] = 'city';
$handler->display->display_options['filters']['city']['operator'] = 'allwords';
$handler->display->display_options['filters']['city']['group'] = '0';
$handler->display->display_options['filters']['city']['exposed'] = TRUE;
$handler->display->display_options['filters']['city']['expose']['operator_id'] = 'city_op';
$handler->display->display_options['filters']['city']['expose']['label'] = 'Stadt';
$handler->display->display_options['filters']['city']['expose']['operator'] = 'city_op';
$handler->display->display_options['filters']['city']['expose']['identifier'] = 'city';
/* Filter criterion: Ort: Distance / Proximity */
$handler->display->display_options['filters']['distance']['id'] = 'distance';
$handler->display->display_options['filters']['distance']['table'] = 'location';
$handler->display->display_options['filters']['distance']['field'] = 'distance';
$handler->display->display_options['filters']['distance']['operator'] = 'dist';
$handler->display->display_options['filters']['distance']['value'] = array(
  'latitude' => '',
  'longitude' => '',
  'postal_code' => '',
  'country' => '',
  'php_code' => '',
  'nid_arg' => 'null',
  'nid_loc_field' => 'node',
  'uid_arg' => 'null',
  'search_distance' => '100',
  'search_units' => 'km',
);
$handler->display->display_options['filters']['distance']['exposed'] = TRUE;
$handler->display->display_options['filters']['distance']['expose']['operator_id'] = 'distance_op';
$handler->display->display_options['filters']['distance']['expose']['label'] = 'Distance / Proximity';
$handler->display->display_options['filters']['distance']['expose']['operator'] = 'distance_op';
$handler->display->display_options['filters']['distance']['expose']['identifier'] = 'umkreis';
$handler->display->display_options['filters']['distance']['expose']['gmap_macro'] = array(
  'default' => '[gmap ]',
);
$handler->display->display_options['filters']['distance']['expose']['user_location_choose'] = array(
  'default' => FALSE,
);
$handler->display->display_options['filters']['distance']['origin'] = 'postal_default';

/* Display: Seite */
$handler = $view->new_display('page', 'Seite', 'page_1');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['exposed_block'] = TRUE;
$handler->display->display_options['path'] = 'camping_und_zelten';
$translatables['Camping'] = array(
  t('Defaults'),
  t('Camping- und Zeltplätze in Hamburg'),
  t('Weiter'),
  t('Anwenden'),
  t('Zurücksetzen'),
  t('Sortieren nach'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« erste Seite'),
  t('‹ vorherige Seite'),
  t('nächste Seite ›'),
  t('letzte Seite »'),
  t('<strong><em>Leider wurde kein passender Camping- oder Zeltplatz gefunden.</em></strong>'),
  t('Name'),
  t('Ort'),
  t('All'),
  t('%1'),
  t('Stadt'),
  t('Distance / Proximity'),
  t('[gmap ]'),
  t('Seite'),
);

agentrickard’s picture

Category:support» bug

Confirmed.

agentrickard’s picture

Title:"Time-based Per Domain"-cache and views filter» Views cache will cache exposed filter settings
Project:Domain Views» Views
Version:7.x-1.5» 7.x-3.x-dev

As far as I can tell, this fails for the default Views: Cache by Time plugin as well.

It may be that Views caching is incompatible with exposed filters. Moving to the Views queue for an opinion.

agentrickard’s picture

To work as intended, it would appear that we have to add the exposed filter data to the cache key.

johnv’s picture

Status:Active» Closed (duplicate)

This problem (Views caching incompatible with exposed filters) is for all views caches, see #1055616: Query arguments should be replaced before generating cache ID

agentrickard’s picture

Project:Views» Domain Views
Version:7.x-3.x-dev» 7.x-1.x-dev
Status:Closed (duplicate)» Postponed

Great. Thanks @johnv.

I'm going to move this back to my queue because I'll have to change some methods once that patch lands.

zerolab’s picture

Issue summary:View changes

I can confirm that that while #1055616 solves the issue with Views and arguments, caching per Domain is still broken.

Will try to see if I can come up with a patch.

Best,
Dan

zerolab’s picture

Status:Postponed» Needs review
StatusFileSize
new5.57 KB

As https://drupal.org/files/issues/views-1055616-152.patch is already in Views 7.x-3.8, here is the first attempt at a patch based on it.

Feedback is very much welcome.

agentrickard’s picture

It's been a long time since I looked at this code, but I wonder why we touch AlterMetaData and Views does not.

Compare https://drupal.org/files/issues/views-1055616-152.patch

zerolab’s picture

Good question. It comes from #1705168: The cache class is always nonsense by using view->build_info to create a cache key and the reason for it was that ***CURRENT_TIME*** is unique.
The login in the patch from #1055616: Query arguments should be replaced before generating cache ID works well, even with query subsitutions. I take it was a Views issue, rather than Domain Views.

I have done a few tests without AlterMetaData and the results are encouraging. Here's the simplified patch.

Cheers,
Dan

agentrickard’s picture

Given that this works better than the current code, I'm tempted to commit it. I'd like someone else to review the functionality, though.