PDF not loading in OJS 3.0

Hello everybody!

Trying to update from 2.4.8.1 to 3.0.

Both files directory and database where duplicated to the test.

Setted the permissions as said in docs…

Everything works fine after the update, but the pdf viewing.

When one clicks the FULL TEXT PDF button, the pdf viwer opens, with no data, a red bar saing An error occurred and when clicked the More Information button, this message appears:

PDF.js v1.0.907 (build: e9072ac)
Mensagem: stream must have data

I tryed to acces the files in the back end, and the error shoewd is:

Stack Trace:

File: (unknown) line (unknown)
Function: FileApiHandler->downloadFile(Array(4), Object(Request))

File: //lib/pkp/classes/core/PKPRouter.inc.php line 372
Function: call_user_func(Array(2), Array(4), Object(Request))

File: //lib/pkp/classes/core/PKPComponentRouter.inc.php line 262
Function: PKPRouter->_authorizeInitializeAndCallRequest(Array(2), Object(Request), Array(4))

File: //lib/pkp/classes/core/Dispatcher.inc.php line 134
Function: PKPComponentRouter->route(Object(Request))

File: //lib/pkp/classes/core/PKPApplication.inc.php line 227
Function: Dispatcher->dispatch(Object(Request))

File: //index.php line 68
Function: PKPApplication->execute()

My guess is that OJS is not finding the file, but the file is in the correct file_dir, and config.inc is configured with the right path.

What can I do to fix this?

Hi @dalmasont,

Did you receive warnings about missing files during the upgrade process? Can you double-check the file permissions on your files directory? The upgrade process may have reset these.

Regards,
Alec Smecher
Public Knowledge Project Team

Hello @asmecher.

I tryed to upgrade several times, with no success in this problem.

The errors are:

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(plugins/oaiMetadataFormats/README/index.php) is not within the allowed path(s): (/home/abraterm/:/tmp:/usr/local/lib/php:./) in /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php on line 224

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(plugins/oaiMetadataFormats/README/READMEOaiMetadataFormatsPlugin.inc.php) is not within the allowed path(s): (/home/abraterm/:/tmp:/usr/local/lib/php:./) in /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php on line 233

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(plugins/oaiMetadataFormats/README/index.php) is not within the allowed path(s): (/home/abraterm/:/tmp:/usr/local/lib/php:./) in /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php on line 224

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(plugins/oaiMetadataFormats/README/READMEOaiMetadataFormatsPlugin.inc.php) is not within the allowed path(s): (/home/abraterm/:/tmp:/usr/local/lib/php:./) in /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php on line 233

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(plugins/oaiMetadataFormats/README/index.php) is not within the allowed path(s): (/home/abraterm/:/tmp:/usr/local/lib/php:./) in /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php on line 224

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(plugins/oaiMetadataFormats/README/READMEOaiMetadataFormatsPlugin.inc.php) is not within the allowed path(s): (/home/abraterm/:/tmp:/usr/local/lib/php:./) in /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php on line 233

Warning: Cannot modify header information - headers already sent by (output started at /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php:224) in /home/abraterm/www/revista_new/lib/pkp/classes/template/PKPTemplateManager.inc.php on line 781

Warning: Cannot modify header information - headers already sent by (output started at /home/abraterm/www/revista_new/lib/pkp/classes/plugins/PluginRegistry.inc.php:224) in /home/abraterm/www/revista_new/lib/pkp/classes/template/PKPTemplateManager.inc.php on line 784

Hi @dalmasont,

Those warnings are harmless. Did you double-check file permissions in the files directory?

Regards,
Alec Smecher
Public Knowledge Project Team

Yes. Checked the permissions: everything writeable.

If you want to compare, the 2 installs:

http://www.abraterm.com.br/revista (OJS 2.4.8.1 working fine)
http://www.abraterm.com.br/revista_new (OJS 3.0 with the problem. Both database and dir files where duplicated from 2.4.8.1 and upgraded by OJS)

Hi @dalmasont,

It seems as though the files simply aren’t available to OJS where it expects them to be – this could be an upgrade issue, or a filesystem issue, or something else.

If you’re able & willing, could you wrap up a SQL dump and copy of your files directory, both for the old and new versions? If you prefer, feel free to obscure the user.password, user.email, etc. before sending. I’d like to see if an upgrade run locally has the same issues.

Regards,
Alec Smecher
Public Knowledge Project Team

Right now I can’t do this because the acces to the cpanel is offline. For 2 days…

I contacted my provider and I am waiting their response.

Thaks for all the help!

@asmecher Sorry for the delay. I’ve just logged in in the control panel.

Could you provide an email that I can send you the files, via WeTransfer? The total size is 146MB

That way I can send you the files with some security, and do not need to change any information.

I am having the same problem after upgrading.

@dalmasont, I’ll send you my email address via PM. A web-based transfer URL would be fine.

Regards,
Alec Smecher
Public Knowledge Project Team

Me too … same problem

Hi @Everton_Borba,

Did you check any of the above suggestions? Can you summarize what you tried and what the result was? What version of OJS 3 are you using, and what version did you upgrade from?

Regards,
Alec Smecher
Public Knowledge Project Team

Hey @asmecher, just to update you.

Sended the files to you yesterday.
Upgraded from 2.x to 3.0.1 and the problem persists

As I can see, in my case, the files are not finded in the upgraded version.

What should the permissions be? Thanks

Hi all,

My ojs3.0.1 has the same issue as the screenshot attached in previous post:

PDF.js v1.0.907 (build: e9072ac)
Message: stream must have data

Has anyone found a solution yet?

My files_dir path and file permissions are correct.
I have also tried moving files directory outside of the web root and updated config file based on that which didn’t help.

This is the error I get in my browser’s console page:

Uncaught TypeError: Cannot read property 'firstElementChild' of null
    at PDFViewer (viewer.js:3918)
    at Object.pdfViewInitialize [as initialize] (viewer.js:4619)
    at HTMLDocument.webViewerLoad (viewer.js:6179)

When I disable PDF Viewer plugin, I only get a blank page when trying to open a pdf.
Please assist.

Regards
Ghazal

1 Like

Hi @salehig,

See also this cross posting. (It’s generally best not to post the same problem in two places – it makes the forum hard to keep organized.)

Regards,
Alec Smecher
Public Knowledge Project Team

Hi all,

@dalmasont, I tried your upgrade today as follows:

  • Unpacked the OJS 2.4.x files into the files directory

  • Loaded the OJS 2.4.x database dump into a new database

  • Checked the version information is as expected using…

      php tools/upgrade.php check 
    
  • Ran the upgrade using…

      php tools/upgrade.php upgrade
    

This gave me numerous warnings like…

PHP Notice:  unserialize(): Error at offset 55 of 753 bytes in /home/asmecher/git/ojs/lib/pkp/classes/db/DAO.inc.php on line 347

…but these are due to character encoding mismatches between my setup and yours (Latin1 vs. UTF-8) and can be ignored.

The upgrade appears to have worked fine and I’m able to download PDFs. Enabling the PDF.js plugin, I’m able to view them in a built-in viewer.

My suspicion is that the file permissions within your files directory are not sufficient to allow OJS to rearrange its contents. Note that numeric permissions (read/write/execute) are not enough – you’ll also have to consider the file’s ownership. This FAQ entry has details.

Note that the command-line upgrade tool will probably be running under your account, so its needs for file permissions may be different than those of your web server. It’ll pay off here to know what your system expects, rather than trying different permission levels to see what works.

Regards,
Alec Smecher
Public Knowledge Project Team

Thanks for the help.

I’ll talk to the server admin to try to work with the permissions.

Hello @asmecher

Talked to the system admin and he readed all we have in this tread. He also readed the FAQ entry and changed the permissions as informed.

Unfortunately, that did not resolved the issue…

As a last try, I copied the files dir, the database and installed in another server (a hostgator one…)

Tried to upgrade and the problem persists.

The debug message is as follows:

[24-Jan-2017 19:34:43 America/Chicago] PHP Warning:  Cannot use a scalar value as an array in /home/proje439/public_html/revista/lib/pkp/classes/core/DataObject.inc.php on line 133
[24-Jan-2017 23:34:43 America/Sao_Paulo] PHP Strict Standards:  Declaration of FileApiHandler::authorize() should be compatible with PKPHandler::authorize($request, &$args, $roleAssignments, $enforceRestrictedSite = true) in /home/proje439/public_html/revista/lib/pkp/controllers/api/file/FileApiHandler.inc.php on line 25
[24-Jan-2017 23:34:43 America/Sao_Paulo] PHP Strict Standards:  Declaration of SubmissionFileDAO::fromRow() should be compatible with PKPSubmissionFileDAO::fromRow($row, $fileImplementation) in /home/proje439/public_html/revista/classes/article/SubmissionFileDAO.inc.php on line 23
[24-Jan-2017 23:34:43 America/Sao_Paulo] FileApiHandler: File /home/proje439/public_html/revista/PAJMT//journals/1//articles/35/submission/35-1-92-1-2-20151216.docx does not exist or is not readable!
[24-Jan-2017 23:34:43 America/Sao_Paulo] ojs2: 500 Internal Server Error

I realy don´t know what to do now.

Planning to do a fresh install of the 3.0.1 version and mannually inserts all the papers already published.

Thanks for all the help!!!