Native XML Plugin: Uncaught PHP error

Hi everyone,

while getting some practice for an upcoming journal migration, I toyed around with the native XML import/export plugin in OJS 3.3.0-4 and ran into the following error.

As an excercise I wanted to move an issue from JournalA to JournalB on the same OJS instance. So I successfully exported a random issue of JournalA and then I tried to import the resulting XML into JournalB:

php ./tools/importExport.php NativeImportExportPlugin import ~/journala-issue-17.xml journalb UsernameOfSiteAdmin
PHP Notice:  Only variables should be passed by reference in /var/www/html/plugins/importexport/native/filter/NativeXmlIssueGalleyFilter.inc.php on line 103
PHP Fatal error:  Uncaught Error: Call to a member function getUsername() on null in /var/www/html/lib/pkp/classes/services/PKPSubmissionFileService.inc.php:321
Stack trace:
#0 /var/www/html/lib/pkp/plugins/importexport/native/filter/NativeXmlSubmissionFileFilter.inc.php(207): PKP\Services\PKPSubmissionFileService->add(Object(SubmissionFile), Object(Request))
#1 /var/www/html/lib/pkp/plugins/importexport/native/filter/NativeImportFilter.inc.php(60): NativeXmlSubmissionFileFilter->handleElement(Object(DOMElement))
#2 /var/www/html/lib/pkp/classes/filter/Filter.inc.php(449): NativeImportFilter->process(Object(DOMDocument))
#3 /var/www/html/lib/pkp/plugins/importexport/native/filter/NativeXmlSubmissionFilter.inc.php(169): Filter->execute(Object(DOMDocument))
#4 /var/www/html/lib/pkp/plugins/importexport/native/filter/NativeXmlSubmissionFilter.inc.php(127): NativeXmlSubmissionFilter->parseSubmissionFile(Object(DOMElement), Object(Submission))
#5 /var/www/html/lib/pkp/plugins/importexport/native/filter/NativeXmlSubmissionFilter.inc in /var/www/html/lib/pkp/classes/services/PKPSubmissionFileService.inc.php on line 321

I suspected some error with the XML, but it seems to validate:

xmllint journala-issue-17.xml --schema /var/www/html/plugins/importexport/native/native.xsd --noout
journala-issue-17.xml validates

For the sake of it, I tried another issue without any articles and this succeeded. I then tried exporting and importing two issues from and to JournalB. Again, the empty one succeeded, the other failed.

So I suppose the problem lies within the article metadata somehow. Can anyone give me a hint about what to look for? Or do I simply have a misunderstanding of what is supposed to happen?

Many thanks and best regards
Dennis

Hi all,

weā€™re still facing this problem with export from and import to OJS 3.3.0-7. Still the XML validates according to xmllint. Does anyone know what to look for?

Best regards
Dennis

EDIT: Removed unrelated error output (userid of uploader was not existant in journal, didnā€™t check that before posting - sorry!).

Okay, so to me the problem seems to be, that there are UserSessions involved in the import process, but those are not possible on the CLI, hence the user is NULL and stuff breaksā€¦ I guess? Iā€™m sure Iā€™m missing something and ought to feel very stupid once somebody explains it to me. :slight_smile:

Anyway, I worked around it by temporarily increasing upload_max_filesize and post_max_size in the webserverā€™s php.ini and importing the xml via the webfrontend.

Hi @dennmuel

Got the same error here, although my import files validate fine.
Because I have to import more than 300 issue files, I did a ā€œnasty trickā€ and just temporarily replaced in lib/pkp/classes/services/PKPSubmissionFileService.inc.php all occurences of ā€˜usernameā€™ => (some function call) with ā€˜usernameā€™ => ā€˜name_of_my_import_userā€™

Now the import works from the CLI.

@asmecher - Could this not be solved this way?
Catch $request->getUser() or do a check on $request being null.
If $request is not defined, use the username that was specified as an argument for importExport.php . The username needs to be specified anyway for import, otherwise the script returns with a usage error.

2 Likes

Hi, @mpbraendle @asmecher

I found a Pull Request on github that may fix this problem with the CLI import. Itā€™s been open for some time.

2 Likes

There are 2 related issues opened: Add ability to include user/context with CLI request Ā· Issue #7604 Ā· pkp/pkp-lib Ā· GitHub and NativeImportExportPlugin CLI import crashes without user on request [OJS 3.3] Ā· Issue #7603 Ā· pkp/pkp-lib Ā· GitHub. It still looks like a work in progress.

1 Like