Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datastream validation in handlers #3

Open
t4k opened this issue Oct 11, 2014 · 1 comment
Open

datastream validation in handlers #3

t4k opened this issue Oct 11, 2014 · 1 comment

Comments

@t4k
Copy link
Contributor

t4k commented Oct 11, 2014

As an example, see: https://github.com/btmash/islandora_entity_bridge/blob/7.x-1.x/handlers/views_islandora_entity_bridge_handler_field_datastream_xml.inc#L47

My use case was the following:

  1. Create a block display of an IEB view with a contextual filter of the PID.
  2. Place that block everywhere, expecting it to only show results when they were available.
  3. Lots of errors when on a collection page, such as /islandora/object/islandora:root because there is no MODS datastream.

I think it may have crashed Fedora. I had to restart Fedora afterwards.

Hopefully there is a way to validate that the datastream supplied in the Views option exists before continuing with the code that renders it. This would be useful for all existing handlers: Image, Link, XML, and XPath.

I'm going to commit a variation on this soon for the different handlers:

  $url = "{$GLOBALS['base_url']}/islandora/object/{$entity->pid}/datastream/{$this->options['datastream']}/view";
  $handle = @fopen($url, 'r');
  if ($handle !== FALSE) {
    $xml = file_get_contents($url);
    $doc = new DOMDocument('1.0');
    $doc->preserveWhiteSpace = FALSE;
    $doc->formatOutput = TRUE;
    $doc->loadXML($xml);
    $content = htmlentities($doc->saveXML());
  }
@btmash
Copy link
Owner

btmash commented Oct 11, 2014

The one other option I would suggest is instead load the islandora datastream with islandora_datastream_load ($dsid, $fedora_object_id) and check if the datastream exists that way. It would be cleaner than using the baseurl file_get_contents and fopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants