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/ on line 103
PHP Fatal error:  Uncaught Error: Call to a member function getUsername() on null in /var/www/html/lib/pkp/classes/services/
Stack trace:
#0 /var/www/html/lib/pkp/plugins/importexport/native/filter/ PKP\Services\PKPSubmissionFileService->add(Object(SubmissionFile), Object(Request))
#1 /var/www/html/lib/pkp/plugins/importexport/native/filter/ NativeXmlSubmissionFileFilter->handleElement(Object(DOMElement))
#2 /var/www/html/lib/pkp/classes/filter/ NativeImportFilter->process(Object(DOMDocument))
#3 /var/www/html/lib/pkp/plugins/importexport/native/filter/ Filter->execute(Object(DOMDocument))
#4 /var/www/html/lib/pkp/plugins/importexport/native/filter/ NativeXmlSubmissionFilter->parseSubmissionFile(Object(DOMElement), Object(Submission))
#5 /var/www/html/lib/pkp/plugins/importexport/native/filter/ in /var/www/html/lib/pkp/classes/services/ 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

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

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/ 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.


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.


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