kaschioudi / ojs3-markup

markup plugin for OJS3
8 stars 15 forks source link

Unable to convert a odt or docx file to XML #30

Closed pgdagenais closed 6 years ago

pgdagenais commented 7 years ago

OJS Version: 3.0.2.0 PHP Version: 5.4.16

Whenever I try to convert a docx or a odt file I get this error:

[Thu Jul 27 15:09:01.896004 2017] [:error] [pid 6124] [client ] ojs2: 404 Not Found
[Thu Jul 27 15:09:07.194613 2017] [:error] [pid 6123] [client ] PHP Fatal error:  Uncaught exception 'Exception' with message 'Job submission failed.' in /srv/www/ojs-3.0.2/plugins/generic/markup/classes/XMLPSWrapper.inc.php:195\nStack trace:\n#0 /srv/www/ojs-3.0.2/plugins/generic/markup/MarkupHandler.inc.php(268): XMLPSWrapper->getJobStatus(NULL)\n#1 [internal function]: MarkupHandler->fetchConversionJobStatus(Array, Object(Request))\n#2 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPRouter.inc.php(372): call_user_func(Array, Array, Object(Request))\n#3 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPPageRouter.inc.php(239): PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(Request), Array, false)\n#4 /srv/www/ojs-3.0.2/lib/pkp/classes/core/Dispatcher.inc.php(134): PKPPageRouter->route(Object(Request))\n#5 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPApplication.inc.php(227): Dispatcher->dispatch(Object(Request))\n#6 /srv/www/ojs-3.0.2/index.php(68): PKPApplication->execute()\n#7 {main}\n  thrown in /srv/www/ojs-3.0.2/plugins/generic/markup/classes/XMLPSWrapper.inc.php on line 195, referer: http://ojs3.erudit.org/ojs/index.php/journaltest/workflow/index/5/5

My jobs list (http://pkp-xml-demo.lib.sfu.ca/manager/list) is also empty.

XML conversion error: xmlconversion

axfelix commented 7 years ago

Try commenting out https://github.com/kaschioudi/ojs3-markup/blob/master/MarkupGatewayPlugin.inc.php#L278 -- I think I intended to remove this but it didn't make it into master, as I found it wasn't reliable available from the OJS DB.

axfelix commented 7 years ago

Yup, see my PR: https://github.com/kaschioudi/ojs3-markup/pull/23/commits/af9198ae8b509ff90f4f129c7f37a148c5bd1de7

axfelix commented 7 years ago

Just merged, you can pull.

pgdagenais commented 7 years ago

I am still getting the same error.

Is there a debug mode that I can activate ? The multiple debug option in the config.inc.php file doesn't seems to help

axfelix commented 7 years ago

I'll see if I can duplicate-- I'm not aware of any other issues with this plugin right now, and I've been testing pretty recently with my branch that had that PR. The server logging you're getting right now is probably all that the module supports currently...

pgdagenais commented 7 years ago

I could send you the odt file that I use to test OTS

I'm just wondering, all I need to do for the plugin to work is add my email address and my API key from http://pkp-xml-demo.lib.sfu.ca ?

axfelix commented 7 years ago

Should be, yes!

axfelix commented 7 years ago

And do feel free to send the file

pgdagenais commented 7 years ago

I can't upload a .odt file here but here is a filebin link https://filebin.ca/3UqkwQGU6jk9/14-99Z_ArticleText-29-1-2-20170726.odt

I will try to see if OJS tries to communicate with the OTS server

axfelix commented 7 years ago

I'm able to submit the job fine, through both my OJS instance and through OTS directly.

Are there any special characters you've entered as part of the document metadata that it might be choking on when it tries to submit the job?

pgdagenais commented 7 years ago

We do have some special character (french article)

Here is the document metadata: metadata1 metadata2

axfelix commented 7 years ago

OK, I'm concerned this might be the issue -- we can definitely figure out a way to sanitize it, but I don't think we've tested how robust the metadata submission to the API is for special characters.

Want to try removing non-ascii characters from the metadata to see if the submission works, and in the meantime, I'll make sure we can support proper utf-8 here? The document body should be totally utf-8 proofed, it's just the metadata I'm concerned may not be.

pgdagenais commented 7 years ago

Just stripped the metadata, didn't work.

Here it is: strmetadata1 strmetadata2 strmetadata3

axfelix commented 7 years ago

OK, good, hopefully we don't have encoding issues then and it's just something in your environment!

Sorry about this, I'll make sure I can't replicate on a fresh install...

pgdagenais commented 7 years ago

I will try to install it in a VM locally.

I just saw https://github.com/axfelix/ots-vagrant on your profile, does it work ? I could try to host my own OTS locally and see if I am able to make it work.

If it does I could help and contribute to it.

axfelix commented 7 years ago

Yup, by all means! I'm almost certain the problem is just with the plugin side rather than with the server side in your case though (I'm not seeing any submissions from you on the OTS server)

pgdagenais commented 7 years ago

Alright, thank you very much !

Could you just tell me where are located the uploaded article files ? I'm wondering if OJS can read them.

axfelix commented 7 years ago

I'm afraid I just confirmed I can't duplicate any issues -- job submission goes through just fine on a clean install of OJS 3.0.2 with a checkout of this plugin's master branch.

Are you sure your server has PHP CURL, PHP Zlib, PHP JSON per the plugin readme? I'm not sure all of those are OJS dependencies...

axfelix commented 7 years ago

In any case, thanks for finally getting me to get that PR merged, sorry it was outstanding for so long and you hit the issue.

pgdagenais commented 7 years ago

This is my environment:

OS: Centos 7 OJS Version: 3.0.2.0 php version: 5.4.16 php zlib version: 1.2.7 php curl version: 7.29.0 php json version: 1.2.1

All of the package required by the plugin are enabled

I can't seems to find any required php package for OJS itself.

pgdagenais commented 7 years ago

Also, where can I find the user-specific OTS confirguration? I'd like to see if the problem is the API Token even tho I tried with 2 account.

axfelix commented 7 years ago

If you toggle user-specific configuration on, it should appear in your user preferences. An authentication failure would actually return an authentication failure, though -- I'm still fairly certain from what you're telling me that it's failing to communicate with the stack at all.

That's a rather old version of PHP but it shouldn't matter...

pgdagenais commented 7 years ago

Going back to the error message:

PHP Fatal error:  Uncaught exception 'Exception' with message 'Job submission failed.' in /srv/www/ojs-3.0.2/plugins/generic/markup/classes/XMLPSWrapper.inc.php:195
Stack trace:
#0 /srv/www/ojs-3.0.2/plugins/generic/markup/MarkupHandler.inc.php(274): XMLPSWrapper->getJobStatus(NULL)
#1 [internal function]: MarkupHandler->fetchConversionJobStatus(Array, Object(Request))
#2 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPRouter.inc.php(372): call_user_func(Array, Array, Object(Request))
#3 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPPageRouter.inc.php(239): PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(Request), Array, false)
#4 /srv/www/ojs-3.0.2/lib/pkp/classes/core/Dispatcher.inc.php(134): PKPPageRouter->route(Object(Request))
#5 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPApplication.inc.php(227): Dispatcher->dispatch(Object(Request))
#6 /srv/www/ojs-3.0.2/index.php(68): PKPApplication->execute()
#7 {main}
  thrown in /srv/www/ojs-3.0.2/plugins/generic/markup/classes/XMLPSWrapper.inc.php on line 195, referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5

Anything here says server misconfiguration to you ?

pgdagenais commented 7 years ago

I think that I found the problem. The value of xmlJobId is NULL because it is never defined anywhere.

I printed the value of the variables in my error_log:

[Wed Aug 02 13:39:11.663773 2017] [:error] [pid 5060] [client ] jobId, referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5
[Wed Aug 02 13:39:11.663811 2017] [:error] [pid 5060] [client ] 59820e3a52f6f, referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5
[Wed Aug 02 13:39:11.664593 2017] [:error] [pid 5060] [client ] jobInfo, referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5
[Wed Aug 02 13:39:11.664641 2017] [:error] [pid 5060] [client ] MarkupJobInfo Object
(
    [_data] => Array
        (   
            [id] => 59820e3a52f6f
            [journalId] => 1
            [fileId] => 29
            [userId] => 1
        )   

    [_hasLoadableAdapters] =>  
    [_metadataExtractionAdapters] => Array
        (   
        )   

    [_extractionAdaptersLoaded] =>  
    [_metadataInjectionAdapters] => Array
        (   
        )   

    [_injectionAdaptersLoaded] =>  
)
, referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5                                                                                                                               
[Wed Aug 02 13:39:11.664651 2017] [:error] [pid 5060] [client ] xmlJobId, referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5
[Wed Aug 02 13:39:11.664656 2017] [:error] [pid 5060] [client ] , referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5
[Wed Aug 02 13:39:11.835757 2017] [:error] [pid 5060] [client ] PHP Fatal error:  Uncaught exception 'Exception' with message 'Job submission failed.' in /srv/www/ojs-3.0.2/plugins/generic/markup/classes/XMLPSWrapper.inc.php:195
Stack trace:
#0 /srv/www/ojs-3.0.2/plugins/generic/markup/MarkupHandler.inc.php(274): XMLPSWrapper->getJobStatus(NULL)
#1 [internal function]: MarkupHandler->fetchConversionJobStatus(Array, Object(Request))
#2 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPRouter.inc.php(372): call_user_func(Array, Array, Object(Request))
#3 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPPageRouter.inc.php(239): PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(Request), Array, false)
#4 /srv/www/ojs-3.0.2/lib/pkp/classes/core/Dispatcher.inc.php(134): PKPPageRouter->route(Object(Request))
#5 /srv/www/ojs-3.0.2/lib/pkp/classes/core/PKPApplication.inc.php(227): Dispatcher->dispatch(Object(Request))
#6 /srv/www/ojs-3.0.2/index.php(68): PKPApplication->execute()
#7 {main}
  thrown in /srv/www/ojs-3.0.2/plugins/generic/markup/classes/XMLPSWrapper.inc.php on line 195, referer: http://ojs3.test.erudit.org/ojs/index.php/journaltest/workflow/index/14/5

When the fetchConversionJobStatus is trying to define this variable

        $code = (int) $xmlpsWrapper->getJobStatus($xmlJobId);

getJobStatus(NULL) wont work so this is why I think that I get this error.

But I could be wrong, I don't really know PHP that much.

axfelix commented 7 years ago

OK -- I can't reproduce consistently, so I don't think that should be happening. I'll get @kaschioudi to look at this when he has time, he did a somewhat significant refactor before he was more urgently needed on another project for a while, and I thought we'd resolved all of the issues there, but I could be wrong.

pgdagenais commented 7 years ago

Perfect, thank you very much !

axfelix commented 6 years ago

@pgdagenais, can you still duplicate this?