Vitaliy-1 / JATSParserPlugin

OJS3 Plugin for parsing JATS XML and displaying it on article detail page
GNU General Public License v3.0
27 stars 24 forks source link

Some article causing fatal error. #61

Closed rahmanramsi closed 3 years ago

rahmanramsi commented 3 years ago

PHP Fatal error: Uncaught Error: Call to a member function getCategory() on null in /var/www/html/gas/plugins/generic/jatsParser/JatsParserPlugin.inc.php:778

Full stack trace : PHP Fatal error: Uncaught Error: Call to a member function getCategory() on null in /var/www/html/gas/plugins/generic/jatsParser/JatsParserPlugin.inc.php:778\nStack trace:\n#0 /var/www/html/gas/plugins/generic/jatsParser/JatsParserPlugin.inc.php(745): JatsParserPlugin->_setSupplImgPath()\n#1 /var/www/html/gas/lib/pkp/classes/plugins/HookRegistry.inc.php(107): JatsParserPlugin->displayFullText()\n#2 /var/www/html/gas/lib/pkp/classes/template/PKPTemplateManager.inc.php(1518): HookRegistry::call()\n#3 /var/www/html/gas/cache/t_compile/20ced12b90181983811d6a2d3549ed558a082564^336dc0f1b5d798bf1eac48afc5cf61399e302932_0.app.frontendobjectsarticledet.php(197): PKPTemplateManager->smartyCallHook()\n#4 /var/www/html/gas/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_60f92c1ca7da66_11928898()\n#5 /var/www/html/gas/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode()\n#6 /var/www/html/gas/lib/pkp/lib/vendor/s in /var/www/html/gas/plugins/generic/jatsParser/JatsParserPlugin.inc.php on line 778

Vitaliy-1 commented 3 years ago

Hi @rahmanramsi,

Please indicate the version of OJS and JATS Parser Plugin you are using.

rahmanramsi commented 3 years ago

OJS Version : 3.3.0-7 JATS Parser Plugin Version : 2.1.9-3

Vitaliy-1 commented 3 years ago

Looks like one of the dependent files of the submission file doesn't have genre. I don't think that this can happen under normal circumstances. You can find the list of genres in the genres table. I'm retrieving it here to identify if the dependent file is an image: https://github.com/Vitaliy-1/JATSParserPlugin/blob/33945ec9503bb4c45ef2a6e07a0d563c3ba71451/JatsParserPlugin.inc.php#L744. In your case it returns null on one of the files. I'd check those dependent files first, I mean why they don't have genre assigned but for the plugin it's relatively easy do bypass by changing the line https://github.com/Vitaliy-1/JATSParserPlugin/blob/33945ec9503bb4c45ef2a6e07a0d563c3ba71451/JatsParserPlugin.inc.php#L745 to

if ($genre && $genre->getCategory() !== GENRE_CATEGORY_ARTWORK) continue; // only art works are supported. 

If this works, I'd be appreciate for the PR.

rahmanramsi commented 3 years ago

yes it works. I will make PR for this issue

Vitaliy-1 commented 3 years ago

Thanks for confirming