What would cause the following error, I've tried to figure this out but can't!

1) Define endpoint
2) Define resource type and some properties
3) Create new SPARQL View
4) Add contextual filter, select property, then click 'Add and configure....'

I then get this error in an alert box -

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/views/ajax/config-item/hcpeople/page/argument/hcpeople_type
StatusText: OK
ResponseText: Notice: Undefined index: sparql_options in options_form() (line 62 of /var/www/drupal.local/htdocs/sites/all/modules/sparql_views/plugins/sparql_views_plugin_argument_default_field.inc). =>

I've tried to isolate the problem to find out if it really is a bug or not, but I can't. Adding filters works fine in one of my Drupal installs but not the other (all with the most recent dev versions), so I'm guessing the error is due to something in the database.

Cheers,
Stuart.

CommentFileSizeAuthor
#11 1249768_rdftype-coontextual-filter.patch511 byteslinclark

Comments

Anonymous’s picture

Hmm, can you try exporting the view for both the working on and the broken one and posting them here (probably best as two separate comments since Views exports are very long).

stuartraetaylor’s picture

After a bit more investigation, the 'working' site doesn't generate the query properly, but does let me add the filter. Here's the generated query, error and export from that site -

The filter should be generating a ?hc_people rdf:type <http://example.org/test>; triple, but the predicate is missing.

PREFIX hc: <http://www.example.org/hc#>
SELECT DISTINCT ?hc_people ?hc_people_field_name
WHERE {
?hc_people  <http://example.org/test>; hc:Englishname ?hc_people_field_name.
  } 
LIMIT 10
Notice: Undefined index: rdf_mapping in sparql_views_handler_argument->query() (line 75 of /var/www/drupaltest.local/htdocs/sites/all/modules/sparql_views/handlers/sparql_views_handler_argument.inc).
User error: Incomplete or invalid Group Graph pattern. Could not handle " ?hc_people in _sparql_request() (line 92 of /var/www/drupaltest.local/htdocs/sites/all/modules/sparql/sparql.module).
$view = new view;
$view->name = 'hc_people';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'sparql_views_3605289727';
$view->human_name = 'HC People';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'HC People';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: HC People: URI */
$handler->display->display_options['fields']['hc_people']['id'] = 'hc_people';
$handler->display->display_options['fields']['hc_people']['table'] = 'sparql_views_3605289727';
$handler->display->display_options['fields']['hc_people']['field'] = 'hc_people';
/* Field: HC People: EnglishName */
$handler->display->display_options['fields']['hc_people_field_name']['id'] = 'hc_people_field_name';
$handler->display->display_options['fields']['hc_people_field_name']['table'] = 'sparql_views_3605289727';
$handler->display->display_options['fields']['hc_people_field_name']['field'] = 'hc_people_field_name';
$handler->display->display_options['fields']['hc_people_field_name']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['external'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['trim'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['html'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['element_label_colon'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['element_default_classes'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['hide_empty'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['empty_zero'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['required'] = 1;
/* Contextual filter: HC People: RDF type */
$handler->display->display_options['arguments']['hc_people_type']['id'] = 'hc_people_type';
$handler->display->display_options['arguments']['hc_people_type']['table'] = 'sparql_views_3605289727';
$handler->display->display_options['arguments']['hc_people_type']['field'] = 'hc_people_type';
$handler->display->display_options['arguments']['hc_people_type']['default_action'] = 'default';
$handler->display->display_options['arguments']['hc_people_type']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['hc_people_type']['default_argument_options']['argument'] = 'http://example.org/test';
$handler->display->display_options['arguments']['hc_people_type']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['hc_people_type']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['hc_people_type']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['hc_people_type']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['hc_people_type']['sparql_options'] = array(
  'value_type' => 'uri',
  'language' => '0',
  'code' => '',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'hc-people';
stuartraetaylor’s picture

And here's the view that generates that original error message from my first post.


$view = new view;
$view->name = 'hc_people';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'sparql_views_3605289727';
$view->human_name = 'HC People';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'HC People';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: HC People: URI */
$handler->display->display_options['fields']['hc_people']['id'] = 'hc_people';
$handler->display->display_options['fields']['hc_people']['table'] = 'sparql_views_3605289727';
$handler->display->display_options['fields']['hc_people']['field'] = 'hc_people';
/* Field: HC People: EnglishName */
$handler->display->display_options['fields']['hc_people_field_name']['id'] = 'hc_people_field_name';
$handler->display->display_options['fields']['hc_people_field_name']['table'] = 'sparql_views_3605289727';
$handler->display->display_options['fields']['hc_people_field_name']['field'] = 'hc_people_field_name';
$handler->display->display_options['fields']['hc_people_field_name']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['external'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['trim'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['alter']['html'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['element_label_colon'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['element_default_classes'] = 1;
$handler->display->display_options['fields']['hc_people_field_name']['hide_empty'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['empty_zero'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['hide_alter_empty'] = 0;
$handler->display->display_options['fields']['hc_people_field_name']['required'] = 1;
/* Contextual filter: HC People: RDF type */
$handler->display->display_options['arguments']['hc_people_type']['id'] = 'hc_people_type';
$handler->display->display_options['arguments']['hc_people_type']['table'] = 'sparql_views_3605289727';
$handler->display->display_options['arguments']['hc_people_type']['field'] = 'hc_people_type';
$handler->display->display_options['arguments']['hc_people_type']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['hc_people_type']['summary']['format'] = 'default_summary';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'hc-people';

Cheers!

Anonymous’s picture

I may have broken the RDF type filter then, let me look into that.

Anonymous’s picture

Ok, the RDF type filter still works for me. Can you try removing the RDF type filter that you have and creating it again to see if that works? The expected filter options probably changed in the codebase since you created the view.

stuartraetaylor’s picture

I've tried removing and recreating the views on both sites but I still get the same results.

Anonymous’s picture

Oh, did you also try:

1. Making sure that you have an RDF type set on the SPARQL Views resource
2. Clearing the cache?

stuartraetaylor’s picture

I've pointed the first site (which generated the original error) at a fresh database and have ran the install.php script. So now I have this site behaving the same as the other one.

1. I've tried to set a value for rdf:type in the RDF Mapping for the SPARQL View Resource. However I get this error -

*Warning: Illegal offset type in rdf_mapping_load() (line 136 of /var/www/drupal.local/htdocs/modules/rdf/rdf.module).
*Recoverable fatal error: Object of class SparqlViewsResourceType could not be converted to string in DatabaseStatementBase->execute() (line 2137 of /var/www/drupal.local/htdocs/includes/database/database.inc).

I found that as a work around, I can define a new field, (e.g., rdftype) and map it to the rdf:type predicate. If I use the filter on that field, the query is generated successfully. However if I use the built in RDF Type field, the predicate is missing from the query.

2. Cache cleared (twice of course :)).

Thanks again.

Anonymous’s picture

Title: Error when adding filter - Undefined index: sparql_options in options_form() » RDF type filter not working if RDF type mapping is not provided
Category: support » bug

Thanks for working through this. The reason I didn't catch the issue was because I'm testing with module defined mappings, not through the UI.

Marking this as a bug. I should be able to fix this pretty easily.

Anonymous’s picture

Someone just posted what may be a related issue, #1250192: subject URI contextual filter fails

Anonymous’s picture

Title: RDF type filter not working if RDF type mapping is not provided » RDF type contextual filter not working
Status: Active » Needs review
StatusFileSize
new511 bytes

Ok, so I think that I figured this one out. Simple fix.

ST, would you mind testing to see if this patch works for you? You should just need to clear the cache and try adding the RDF type contextual filter.

stuartraetaylor’s picture

Status: Needs review » Reviewed & tested by the community

I've applied the patch and the RDF type filters are working again. Thanks!

Anonymous’s picture

Status: Reviewed & tested by the community » Fixed

No, thank YOU for catching the bug ;)

Fixed with http://drupalcode.org/project/sparql_views.git/commit/fc42e65

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.