OAI-PMH repo showing "invalid character"


#1

Was working fine, now it isn’t. Not sure where to start with this.

When you force it to output HTML anyway:
XML parsing failed
XML parsing failed: syntax error (Line: 1, Character 0)
Error: invalid character

Stack Trace:

  1. {main}() /home/omeka/index.php:0
  2. Omeka_Application->run() /home/omeka/index.php:23
  3. Zend_Application->run() /home/omeka/application/libraries/Omeka/Application.php:79
  4. Zend_Application_Bootstrap_Bootstrap->run() /home/omeka/application/libraries/Zend/Application.php:384
  5. Zend_Controller_Front->dispatch() /home/omeka/application/libraries/Zend/Application/Bootstrap/Bootstrap.php:105
  6. Zend_Controller_Dispatcher_Standard->dispatch() /home/omeka/application/libraries/Zend/Controller/Front.php:954
  7. Zend_Controller_Action->dispatch() /home/omeka/application/libraries/Zend/Controller/Dispatcher/Standard.php:308
  8. Zend_Controller_Action_HelperBroker->notifyPostDispatch() /home/omeka/application/libraries/Zend/Controller/Action.php:527
  9. Zend_Controller_Action_Helper_ViewRenderer->postDispatch() /home/omeka/application/libraries/Zend/Controller/Action/HelperBroker.php:277
  10. Zend_Controller_Action_Helper_ViewRenderer->render() /home/omeka/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php:972
  11. Zend_Controller_Action_Helper_ViewRenderer->renderScript() /home/omeka/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php:933
  12. Zend_View_Abstract->render() /home/omeka/application/libraries/Zend/Controller/Action/Helper/ViewRenderer.php:912
  13. Omeka_View->_run() /home/omeka/application/libraries/Zend/View/Abstract.php:888
  14. include() /home/omeka/application/libraries/Omeka/View.php:117
  15. Output_OmekaJson::toJson() /home/omeka/application/views/scripts/items/browse.omeka-json.php:2
  16. XSLTProcessor->transformToXml() /home/omeka/application/models/Output/OmekaJson.php:38

#2

The stack trace you posted doesn’t appear to be related to the OAI-PMH repository plugin.

This kind of thing can happen if you have a plugin or theme introducing extra whitespace on every page (you’d see a blank like at the top of View Source for any page, that kind of thing). It’s easy to accidentally do this by having whitespace outside <?php ?> tags in any file.


#3

Cool. This is all that was given to me in the logs, though.
At what point do the plugins get “called” by the Omeka application?

The only issue I get is from the one URL that is related to the OAI-PMH repo URL.

The plugin files haven’t been modified whatsoever, so I’m wondering where I should look for any excess white spaces.


#4

I switched the theme over from the custom theme, and deactivated all plugins. It’s still giving me the same error.
Where do I try next?


#5

Do you have a link to the repository?


#6

I’ll get you one. I have a lot of instances of Omeka that I inherited with a lot of undocumented custom code. Some repos are private, but I’ll clone it and upload it then post a link.


#7

#8

Sorry, I meant a link to the OAI-PMH repository, the site itself in other words.


#9

https://omeka.library.appstate.edu/oai-pmh-repository/request


#10

There’s a few issues here…

  • First, there’s some problem with your SSL certificate which makes it difficult to view this site from some browsers (I encountered errors from Firefox and curl)
  • Second, I then get a “content decoding” error when trying to view the repository XML output. This is about gzip/compress encoding and seems to affect other XML outputs as well… I get the same error from https://omeka.library.appstate.edu/items/browse?output=omeka-xml which is the omeka-xml output format and unrelated to the OAI plugin. Perhaps you have an Apache or other server setting, or a proxy if there’s one involved, that’s doing or trying to do something related to compression of XML?
  • Third, there is an extra newline in your code, it’s visible if you “view source” on any of the normal pages: there’s a blank line on top. I’m thinking the likely location is your theme. Something like the custom.php file which is loaded on every request would be a probable place to find the issue. Generally, for files containing just PHP code, you want to start the file with an opening <?php tag and then never have a closing tag anywhere (the end of the file will “close” for you).

#11

I disabled all plugins and set the Theme to Thanks Roy and still got the same issue with just the raw XML output from https://omeka.library.appstate.edu/items/browse?output=omeka-xml .
Which files should I start looking for the malformatted PHP?


#12

I mentioned your theme’s custom.php file in my previous post, did you check there?

The extra newline is appearing only on your public pages so it’s quite likely to be in your theme where the problem lies.

The “content decoding” problem, if that’s what you mentioned still seeing, is probably actually unrelated to this “extra newline” issue, but I can’t be 100% sure that’s the case. I’m not totally sure what the problem you’re having actually is since that log entry really isn’t about the OAI plugin at all.


#13

I checked there. I also reverted the theme to Roy’s and it gave me the same result.


#14

Is this an accurate copy of your theme’s custom.php? The highlighted line is exactly the kind of close-tag-open-tag-whitespace combination that would cause the extra newline you’re getting. You almost always want just one open tag at the top of the file and no close tags anywhere.

As for the problem persisting with Thanks, Roy, it’s entirely possible, and even fairly likely that the “content decoding failed” problem isn’t actually related to the whitespace issue. Extra whitespace does cause problems for XML generally, and is the likely cause of the error you posted from your log, but that’s an error generated by the omeka-json output. This “content decoding” error I’m seeing when trying to view your OAI repository is more likely a problem of server or proxy settings somewhere. This is the second bullet from my previous post.


#15

That is a copy of the current theme.

I will work to make sure that isnt an issue with the custom.php files in the future.

What do you mean server or proxy settings? There is no proxy.


#16

What settings usually affect this with Apache?

Also- I did remove/re-enable gzip. That didn’t change anything when gzip was installed vs uninstalled.


#17

You might be looking for something like AddOutputFilterByType DEFLATE or other references to DEFLATE. Just as a guess. It kind of looks like things may be getting double-compressed which is causing the error.