Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
-
- Regular
- Posts: 5
- Joined: Wed Aug 22, 2018 12:01 am
Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
PHP is : 5.6.36-0+deb8u1
Serendipity Version 2.2.0-beta2
I've found a bug in the Clean-Blog template. When I click on 'preview' to preview a blog or comments I get this error:
Fatal error: Uncaught exception 'ErrorException' with message 'Warning: Parameter 2 to timeAgoInWords() expected to be a reference, value given' in /home/admin/web/mysite.tld/public_html/blog/templates_c/clean_blog/5d/24/34/5d2434559a2ba1c20fd8ba09cc03d18d799fdd6f_0.file.comments.tpl.php:91 Stack trace: #0 [internal function]: errorToExceptionHandler(2, 'Parameter 2 to ...', '/home/admin/web...', 91, Array) #1 /home/admin/web/mysite.tld/public_html/blog/templates_c/clean_blog/5d/24/34/5d2434559a2ba1c20fd8ba09cc03d18d799fdd6f_0.file.comments.tpl.php(91): call_user_func_array('timeAgoInWords', Array) #2 /home/admin/web/mysite.tld/public_html/blog/bundled-libs/Smarty/libs/sysplugins/smarty_template_resource_base.php(126): content_5b80a136768448_15781237(Object(Smarty_Internal_Template)) #3 /home/admin/web/mysite.tld/public_html/blog/bundled-libs/Smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #4 /hom in /home/admin/web/mysite.tld/public_html/blog/templates_c/clean_blog/5d/24/34/5d2434559a2ba1c20fd8ba09cc03d18d799fdd6f_0.file.comments.tpl.php on line 91
== ERROR-REPORT (BETA/ALPHA-BUILDS) ==
The solution is to edit 'templates/clean-blog/config.inc.php' and change the line:
function timeAgoInWords($params, &$smarty) {
to
function timeAgoInWords($params, $smarty) {
Any PHP version over 5.3 (I believe) does not allow this sort of reference. Strangely there are other references with the &$ and they don't seem to bother the app.
Hope this helps some other people. I'm not a PHP programmer so I kinda stumbled on this. It might not be the most elegant solution but it works well for me.
Roger
Serendipity Version 2.2.0-beta2
I've found a bug in the Clean-Blog template. When I click on 'preview' to preview a blog or comments I get this error:
Fatal error: Uncaught exception 'ErrorException' with message 'Warning: Parameter 2 to timeAgoInWords() expected to be a reference, value given' in /home/admin/web/mysite.tld/public_html/blog/templates_c/clean_blog/5d/24/34/5d2434559a2ba1c20fd8ba09cc03d18d799fdd6f_0.file.comments.tpl.php:91 Stack trace: #0 [internal function]: errorToExceptionHandler(2, 'Parameter 2 to ...', '/home/admin/web...', 91, Array) #1 /home/admin/web/mysite.tld/public_html/blog/templates_c/clean_blog/5d/24/34/5d2434559a2ba1c20fd8ba09cc03d18d799fdd6f_0.file.comments.tpl.php(91): call_user_func_array('timeAgoInWords', Array) #2 /home/admin/web/mysite.tld/public_html/blog/bundled-libs/Smarty/libs/sysplugins/smarty_template_resource_base.php(126): content_5b80a136768448_15781237(Object(Smarty_Internal_Template)) #3 /home/admin/web/mysite.tld/public_html/blog/bundled-libs/Smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #4 /hom in /home/admin/web/mysite.tld/public_html/blog/templates_c/clean_blog/5d/24/34/5d2434559a2ba1c20fd8ba09cc03d18d799fdd6f_0.file.comments.tpl.php on line 91
== ERROR-REPORT (BETA/ALPHA-BUILDS) ==
The solution is to edit 'templates/clean-blog/config.inc.php' and change the line:
function timeAgoInWords($params, &$smarty) {
to
function timeAgoInWords($params, $smarty) {
Any PHP version over 5.3 (I believe) does not allow this sort of reference. Strangely there are other references with the &$ and they don't seem to bother the app.
Hope this helps some other people. I'm not a PHP programmer so I kinda stumbled on this. It might not be the most elegant solution but it works well for me.
Roger
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
Happy to change this in the core if anyone else can confirm. I use this function in a few themes, so additional input will be greatly appreciated!
=Don=
-
- Regular
- Posts: 5
- Joined: Wed Aug 22, 2018 12:01 am
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
If this helps - from the php manual:
“There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);.”
“There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);.”
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
But that's not the issue here. It's the place where references are allowed: A function definition. The issue is that it is not being given a reference, but a value. By the way, that collides with wthat the documentation is claiming, that PHP would handle that automatically by just declaring the reference in the funktion parameter definition. That doesn't work at all, not in PHP 5.6, anto in PHP 7.
The bug is actually a consequence from the smarty upgrade I did in the github master, the version you seem to be running. $smarty is a value now, not a reference. Thanks for testing! :)
Don, it would be great if you could fix that in the core, just change the function definition.
I was actually uncertain whether working with a value and not a reference would not break things, so it would be good to continue to test out whether everything still works as expected with this change.
The bug is actually a consequence from the smarty upgrade I did in the github master, the version you seem to be running. $smarty is a value now, not a reference. Thanks for testing! :)
Don, it would be great if you could fix that in the core, just change the function definition.
I was actually uncertain whether working with a value and not a reference would not break things, so it would be good to continue to test out whether everything still works as expected with this change.
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
Can the fix be merely what Roger suggested, or does there need to be a conditional test on the php and/or smarty version?
=Don=
-
- Regular
- Posts: 5
- Joined: Wed Aug 22, 2018 12:01 am
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
Thanks. I guess I just got lucky.onli wrote: ↑Sat Aug 25, 2018 12:03 pm But that's not the issue here. It's the place where references are allowed: A function definition. The issue is that it is not being given a reference, but a value. By the way, that collides with wthat the documentation is claiming, that PHP would handle that automatically by just declaring the reference in the funktion parameter definition. That doesn't work at all, not in PHP 5.6, anto in PHP 7.
The bug is actually a consequence from the smarty upgrade I did in the github master, the version you seem to be running. $smarty is a value now, not a reference. Thanks for testing!
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
Since it is a design in the core this can just be changed.Don Chambers wrote: ↑Sat Aug 25, 2018 3:14 pm Can the fix be merely what Roger suggested, or does there need to be a conditional test on the php and/or smarty version?
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
The core will be changed and will not require a theme change? Am I interpreting your response correctly?
=Don=
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
No, it will be necessary to change that function in the theme. But the theme is in the core, so in this case it can just be changed, without needing bc compatibility with earlier s9y versions.
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
Thanks. I'll change it in Cleanblog. I think its in Timeline too, also a core theme.
=Don=
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
I'm about to make this change....
to this as recommended
I realize that changing this in the core means I don't need to worry about it working with older s9y versions, but it should still work in older versions of s9y... yes? no? I'm not a php coder, so not entirely sure about "reference" vs "value".
Code: Select all
function timeAgoInWords($params, &$smarty) {
Code: Select all
function timeAgoInWords($params, $smarty) {
=Don=
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
Yes, I think that it should still work regardless. But I would not be confident enough to deploy the change to old s9y versions without testing.
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
Re: Clean blog Warning: Parameter 2 to timeAgoInWords() expected to be a reference
Nor would I. Just more of a curiosity question.
=Don=
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact: