Submissions error (ojs, restful_urls = On, PHP Version 7.2.16 )

We have recently upgraded our OJS install from 2.4.8 to All seemed ok, but we overlooked the popups that appeared at the submission tabs: ##api.submissions.unknownError## error. Tried to solve this in the htaccess / config, but until now nothing works and tried a things suggested in the forum. I hope someone can help us.

I get Javacript errors in the Google Chrome console. When I do a request on one of the urls:

I get this error in the Apache errorlog:
[Tue Mar 19 09:29:33.860283 2019] [proxy_fcgi:error] [pid 23948] [client] AH01071: Got error ‘PHP message: PHP Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /nfs/www/test-ojs3/lib/pkp/lib/adodb/ on line 1003\nPHP message: PHP Warning: Declaration of PKPUsageEventPlugin::getEnabled() should be compatible with LazyLoadPlugin::getEnabled($contextId = NULL) in /nfs/www/test-ojs3/lib/pkp/plugins/generic/usageEvent/ on line 0\nPHP message: PHP Warning: Declaration of SubmissionFileDAO::fromRow($row) should be compatible with PKPSubmissionFileDAO::fromRow($row, $fileImplementation) in /nfs/www/test-ojs3/classes/article/ on line 23\nPHP message: PHP Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening <?php tag? in /nfs/www/test-ojs3/lib/pkp/lib/vendor/slim/slim/Slim/App.php:622\nStack trace:\n#0 /nfs/www/test-ojs3/lib/pkp/lib/vendor/slim/slim/Slim/App.php(334): Slim\App->finalize(Object(APIResponse))\n#1 /nfs/www/test-ojs3/lib/pkp/classes/core/ Slim\App->run()\n#2 /nfs/www/test-ojs3/lib/pkp/classes/core/ APIRouter->route(Object(Request))\n#3 /nfs/www/test-ojs3/lib/pkp/classes/core/ Dispatcher->dispatch(Object(Request))\n#4 /nfs/www/test-ojs3/index.php(68): PKPApplication->execute()\n#5 {main}\n thrown in /nfs/www/test-ojs3/lib/pkp/lib/vendor/slim/slim/Slim/App.php on line 622\n’

This seems like an old issue, but we can’t find a solution for our problem.

Hi @UGP,

Was the upgrade process successful? If you performed it through command line tool you should see a notice about that or an error.

Following StackOverflow, one of the reasons might be closing PHP tag somewhere. Also, it can be output_buffering setting inside php.ini (it should be on) But I never got such a problem on my OJS instances with that particular error. Probably @NateWr knows more.

There are some other similar errors reported in the forum. In most cases it seems that the reason remained a bit unclear?

From the sounds of it, something is printing to the buffer too early. The most common cause of this is when PHP prints notices and warnings to the buffer. You can try turning off error reporting just as a test to see if that helps.

Otherwise, I’d recommend looking at the actual response you get in the browser when hitting the API. You can inspect this in your browser’s dev tools, under the Network tab, when looking at XHR requests. (Look for the Response area.) That will show you the actual response you received and that might give you clues as to what is in the output buffer that is causing problems.

Thank you. The upgrade was succesful and performed through the command line.

PHP Fatal error: Uncaught RuntimeException: Unexpected data in output buffer. Maybe you have characters before an opening

This was the case. Probably a character after closing the PHP.(?>). We found a workaround.

It looks like there are spaces before <?php tags or after ?> tags somewhere in the codebase. I added the following to line 621 in /lib/pkp/lib/vendor/slim/slim/Slim/App.php as a work-around

// HACK Clean output buffering if it contains only spaces
if (ob_get_length() > 0 && (strlen(trim(ob_get_contents())) === 0)) {
1 Like

Thank you! This fix solves our problem for now.

Thank you Antti-Jussi! The solution was in that direction. Only the solution is more a fix. This sort of problem shouldn’t occur.

Sadly, removing all (1600+) redundant ?> tags (also in compliance with the PSR-2 Coding Style Guide ), did not fix it.

Hi @ericimthorn,

The ?> closing tags have been removed starting with OJS 3.1.2.

I would suggest watching for space before the starting <?php tags, and ensuring that file permissions aren’t e.g. allowing another errant app on the server to modify files in your cache and cache/t_compile directories.

Alec Smecher
Public Knowledge Project Team