Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation warnings in footer template #258

Closed
OyvindLGjesdal opened this issue Dec 3, 2024 · 5 comments
Closed

deprecation warnings in footer template #258

OyvindLGjesdal opened this issue Dec 3, 2024 · 5 comments

Comments

@OyvindLGjesdal
Copy link

OyvindLGjesdal commented Dec 3, 2024

Describe the bug

After upgrading to php 8.2, I see deprecation warning and smarty warning:

PHP Deprecated:  trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/ojs/cache/t_compile/..._0.app.frontendcomponentsfooter.tpl.php on line 57

refers to

https://github.com/pkp/healthSciences/blob/main/templates/frontend/components/footer.tpl#L36

{* Load author biography modals if they exist *}
{if !empty($smarty.capture.authorBiographyModals|trim)}
	{$smarty.capture.authorBiographyModals}
{/if}

Would skipping the trim filter make sense (if it exists as whitespace, it will only input whitespace).

I don't know if this is fixed upstream in smarty, but the smarty version used is the same as the in 3.3 stable branch of pkp-lib, which is 0.2 versions behind main. (v4.3.1).

@OyvindLGjesdal OyvindLGjesdal changed the title deprecation warnings in footer deprecation warnings in footer template Dec 3, 2024
@asmecher
Copy link
Member

asmecher commented Dec 4, 2024

@OyvindLGjesdal, what version of OJS are you using, and what version of the health sciences theme?

@OyvindLGjesdal
Copy link
Author

OyvindLGjesdal commented Dec 5, 2024

3.3.0.17 and a bit behind on the the healthSciences theme 722d2ba

I did a fast check in the stable-3.3 branch for both ojs and the theme to see if the section had changed, or the library version for smarty, and it looked likely to me that the bug was also present there. Haven't confirmed.

@asmecher
Copy link
Member

asmecher commented Dec 5, 2024

@OyvindLGjesdal, can you quickly verify if this change resolves the issue?

diff --git a/templates/frontend/components/footer.tpl b/templates/frontend/components/footer.tpl
index 3b3e6f2..126ea2c 100644
--- a/templates/frontend/components/footer.tpl
+++ b/templates/frontend/components/footer.tpl
@@ -33,7 +33,7 @@
 </footer><!-- pkp_structure_footer_wrapper -->
 
 {* Load author biography modals if they exist *}
-{if !empty($smarty.capture.authorBiographyModals|trim)}
+{if !empty($smarty.capture.authorBiographyModals|default:""|trim)}
        {$smarty.capture.authorBiographyModals}
 {/if}

@OyvindLGjesdal
Copy link
Author

OyvindLGjesdal commented Dec 5, 2024

It removes the previous message and returns a different deprecation message:

PHP Deprecated:  Using php-function "trim" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /var/www/ojs/lib/pkp/lib/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 112

Looking at previous issues on the forum and fixes, I guess trim can also be added to https://github.com/pkp/pkp-lib/blob/stable-3_3_0/classes/template/PKPTemplateManager.inc.php#L259

asmecher added a commit to pkp/pkp-lib that referenced this issue Dec 6, 2024
asmecher added a commit to pkp/pkp-lib that referenced this issue Dec 6, 2024
asmecher added a commit to pkp/pkp-lib that referenced this issue Dec 6, 2024
@asmecher
Copy link
Member

asmecher commented Dec 6, 2024

asmecher added a commit that referenced this issue Dec 6, 2024
asmecher added a commit that referenced this issue Dec 6, 2024
asmecher added a commit that referenced this issue Dec 6, 2024
@asmecher asmecher closed this as completed Dec 6, 2024
Hafsa-Naeem pushed a commit to Hafsa-Naeem/pkp-lib that referenced this issue Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants