pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
297 stars 442 forks source link

[OMP] Fatal error at the About > Submissions #8786

Closed jonasraoni closed 1 year ago

jonasraoni commented 1 year ago

Describe the bug When acessing the About > Submissions a fatal error is generated, even though the page is displayed.

PHP Fatal error:  Uncaught Error: Call to undefined method APP\\section\\Section::getLocalizedPolicy() in /var/www/html/cache/t_compile/9730ad821b3a9350a2a8f76a57c0d7b52ebc9b02^f59ba25f4aae6a7b19033686947ff5a7d2a098e0_0.app.frontendpagessubmissions..php:98
Stack trace:
#0 /var/www/html/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_640307ef83b514_68176269(Object(Smarty_Internal_Template))
#1 /var/www/html/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template))
#2 /var/www/html/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template))
#3 /var/www/html/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render(false, 1)
#4 /var/www/html/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, '9730ad821b3a935...', NULL, 1)
#5 /var/www/html/lib/pkp/classes/template/PKPTemplateManager.php(1307): Smarty_Internal_TemplateBase->display('frontend/pages/...', NULL, '9730ad821b3a935...', NULL)
#6 /var/www/html/lib/pkp/pages/about/AboutContextHandler.php(97): PKP\\template\\PKPTemplateManager->display('frontend/pages/...')
#7 [internal function]: PKP\\pages\\about\\AboutContextHandler->submissions(Array, Object(APP\\core\\Request))
#8 /var/www/html/lib/pkp/classes/core/PKPRouter.php(465): call_user_func(Array, Array, Object(APP\\core\\Request))
#9 /var/www/html/lib/pkp/classes/core/PKPPageRouter.php(308): PKP\\core\\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\\core\\Request), Array, false)
#10 /var/www/html/lib/pkp/classes/core/Dispatcher.php(163): PKP\\core\\PKPPageRouter->route(Object(APP\\core\\Request))
#11 /var/www/html/lib/pkp/classes/core/PKPApplication.php(372): PKP\\core\\Dispatcher->dispatch(Object(APP\\core\\Request))
#12 /var/www/html/index.php(21): PKP\\core\\PKPApplication->execute()
#13 {main}
  thrown in /var/www/html/cache/t_compile/9730ad821b3a9350a2a8f76a57c0d7b52ebc9b02^f59ba25f4aae6a7b19033686947ff5a7d2a098e0_0.app.frontendpagessubmissions..php on line 98

To Reproduce Steps to reproduce the behavior:

  1. Access the About > Submissions at the frontend

What application are you using? OMP 3.4.0rc1

PRs

jonasraoni commented 1 year ago

@asmecher Before I proceed...

The Section::getLocalizedPolicy() does exist at OJS and OPS. So perhaps it makes sense to rename the field from 'descriptiontopolicyand create a migration for OMP (then I'll just undo an update which removed thegetLocalizedPolicy()from thePKPSection`).

The other solution would be to use a workaround (e.g. method_exists()/check if it's OMP).

p.s.: It works in OMP 3.3, because the method getLocalizedPolicy() used to be declared at the PKPSection.

asmecher commented 1 year ago

@jonasraoni, I'd be cautious about assuming the section description (OMP) and policy (OJS and OPS) serve the same purpose; can you double-check where the section policy is used in OMP?

jonasraoni commented 1 year ago

I just found it here, so it's a description :) https://github.com/pkp/omp/blob/4a2e0b6fa92c755624b57b38466e2c38c60bea7a/templates/frontend/pages/catalogSeries.tpl#L35

Ok, so I'll just isolate the policy at the template level, which also needs to be fixed (it's listing disabled sections).

asmecher commented 1 year ago

That sounds fine, thanks!

jonasraoni commented 1 year ago

@asmecher PRs

asmecher commented 1 year ago

Merged, thanks! You could also use Smarty template inheritance in cases like this: https://www.smarty.net/inheritance

jonasraoni commented 1 year ago

Yeah, this thought came to my mind (I remember Nate talked about it a long time ago), but then I saw another place using a similar construction, and ended up forgetting to research the syntax, whatever, now it's too late 😅