PHP Deprecated warnings in serendipity_event_textile

Found a bug? Tell us!!
User avatar
konus
Regular
Posts: 334
Joined: Mon Jun 16, 2008 1:57 pm
Location: Dresden, Germany
Contact:

PHP Deprecated warnings in serendipity_event_textile

Post by konus » Fri Nov 29, 2013 5:37 pm

Hello,

my error-log was flooding with

Code: Select all

[Fri Nov 29 14:33:03 2013] [warn] [client 176.57.141.xxx] mod_fcgid: stderr: PHP Deprecated:  preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /html/plugins/serendipity_event_textile/classTextile.php on line 953
Normally, it is possible to configure Apache not to show deprecated warings in php.ini with

Code: Select all

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
but in Serenditpity overwrites these values in

/html/include/serendipity_smarty_class.inc.php and in /html/serendipity_config.inc.php

I would like to kindly ask developers to
A) fix serendipity_event_textile/classTextile.php OR
B) include the possibility to switch off E_DEPRECATED in s9y own error handling.

Greetings

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by Timbalu » Fri Nov 29, 2013 6:40 pm

Could you please test to replace this
https://github.com/s9y/Serendipity/blob ... e.php#L949

Code: Select all

// -------------------------------------------------------------
    function footnoteRef($text)
    {
        return preg_replace('/\b\[([0-9]+)\](\s)?/Ue',
            '$this->footnoteID(\'\1\',\'\2\')', $text);
    }
with this

Code: Select all

    function footnoteRef_callback($matches) {
        return $matches[1];
    }

    function footnoteRef($text) {
        return preg_replace_callback('/\b\[([0-9]+)\](\s)?/U', array($this->footnoteID(\'\1\',\'\2\'), 'footnoteRef_callback'), $text);
    }
and see if that works?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
konus
Regular
Posts: 334
Joined: Mon Jun 16, 2008 1:57 pm
Location: Dresden, Germany
Contact:

Re: PHP Deprecated warnings in serendipity_event_textile

Post by konus » Fri Nov 29, 2013 11:10 pm

Thank you for the fast help. Unfortunately it is not quite finished. After changing the above lines, I get
PHP Parse error: syntax error, unexpected ''\\1\\',\\'\\2\\'), '' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) in /html/plugins/serendipity_event_textile/classTextile.php on line 955
For me it looks like that there are some () or ' ' missing. I tried to change the code to

Code: Select all

    function footnoteRef($text) {
        return preg_replace_callback('/\b\[([0-9]+)\](\s)?/U', array('$this->footnoteID(\'\1\',\'\2\')', 'footnoteRef_callback'), $text);
    }
but then got
PHP Warning: preg_replace_callback(): Requires argument 2, '$this->footnoteID('\\1','\\2')::footnoteRef_callback', to be a valid callback in /html/plugins/serendipity_event_textile/classTextile.php on line 955
Now I am lost...

BTW is there a reason you skipped the e from Ue in the first Term of preg_replace_callback?

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by Timbalu » Sat Nov 30, 2013 9:36 am

Yes the /e is that yelling deprecated modifier with PHP >= 5.5.x versions.

I am sorry my code wasn't right, beside the fact that I was missing a '.

It is much harder to solve, since we must now have two recursive preg_replace_callback functions.
I missed that in first.

It seems this isn't solvable without changing some more code and having to jump to a far more advanced major version, which breaks backwards compatibility. See
http://code.google.com/p/textpattern/is ... ail?id=398

What happens when you just try to silence the deprecated notice by @ ?

Code: Select all

// -------------------------------------------------------------
    function footnoteRef($text)
    {
        return @preg_replace('/\b\[([0-9]+)\](\s)?/Ue',
            '$this->footnoteID(\'\1\',\'\2\')', $text);
    }

(deprecated just means: "will be purged in future", but is still working.)


If that does not work, you could add 'E_DEPRECATED' to serendipity_config.inc.php file at line 57:

Code: Select all

error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));
like

Code: Select all

error_reporting(E_ALL & ~(E_STRICT|E_DEPRECATED|E_NOTICE));
[To have this set up for all, would mean to not know about future "errors" in our codebase like this, but in this case we should think about ist. Or any is able to update textile to a compat version. @Garvin?]
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
konus
Regular
Posts: 334
Joined: Mon Jun 16, 2008 1:57 pm
Location: Dresden, Germany
Contact:

Re: PHP Deprecated warnings in serendipity_event_textile

Post by konus » Sun Dec 01, 2013 12:07 am

Thank you for looking deeper into this issue. In my case I solved the problem by changing the above mentioned files, so at the moment i am fine.

I reported this problem in the hope that some changes could be made to future versions and I am not forced to hack every new version of s9y (because I tend to forget such issues over the time :-) )

Greetings, Konus

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by Timbalu » Sun Dec 01, 2013 9:22 am

Well, the easiest way would be to check, if the @ silences the warning. Could you check this?
In this case we could do that for upcoming Serendipity 1.7.4, since it is as core delivered plugin.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

ICE
Regular
Posts: 239
Joined: Tue Jun 28, 2005 11:15 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by ICE » Wed Dec 04, 2013 11:26 am

I have a similar deprecated message in serendipity_event_nl2br plugin with php 5.5:

Code: Select all

Error redirect:
== SERENDIPITY ERROR ==

Please correct:

preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\xampp\htdocs\xxx\plugins\serendipity_event_nl2br\serendipity_event_nl2br.php on line 156
But this:

Code: Select all

error_reporting(E_ALL & ~(E_STRICT|E_DEPRECATED|E_NOTICE));
does not work, the error message is still visible

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by Timbalu » Wed Dec 04, 2013 11:41 am

This is already fixed for 1.7.4.
http://board.s9y.org/viewtopic.php?f=3& ... #p10437215
If you need to fix that now, follow the advise or download this file to replace your current nl2br: https://raw.github.com/s9y/Serendipity/ ... _nl2br.php
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

ICE
Regular
Posts: 239
Joined: Tue Jun 28, 2005 11:15 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by ICE » Wed Dec 04, 2013 12:39 pm

Thanks for the answer!
No, i can wait ... its only my development server ...

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by Timbalu » Wed Dec 04, 2013 12:41 pm

It is strange the E_DEPRECATED does not work (this may be a matter of order). Could you also give it a try with silencing by @, please?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

bernd_d
Regular
Posts: 468
Joined: Thu Jun 03, 2010 9:28 am
Contact:

Re: PHP Deprecated warnings in serendipity_event_textile

Post by bernd_d » Wed Dec 04, 2013 12:45 pm

konus wrote:A) fix serendipity_event_textile/classTextile.php
Have you tried to replace classTextile.php with newer release from http://txstyle.org/article/36/php-textile

Textile 2.0 in s9y is really old and there has been a lot of fixes in meantime.

bugrep
Regular
Posts: 74
Joined: Tue Feb 24, 2009 8:19 am
Contact:

Re: PHP Deprecated warnings in serendipity_event_textile

Post by bugrep » Tue Dec 10, 2013 2:09 pm

Timbalu wrote:It is strange the E_DEPRECATED does not work (this may be a matter of order). Could you also give it a try with silencing by @, please?
http://www.php.net/manual/en/errorfunc.constants.php

this worked for me
error_reporting(8192);

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by Timbalu » Tue Dec 10, 2013 2:21 pm

Yes, also error_reporting(E_DEPRECATED) should do, but this was not the question, since we need the others in error_reporting(E_ALL & ~(E_STRICT|E_NOTICE)); to stick as set for our custom errorHandler function.

So how did you do this?
Set an additional error_reporting(8192); underneath or added that to the textile class?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: PHP Deprecated warnings in serendipity_event_textile

Post by Timbalu » Fri Jan 10, 2014 3:08 pm

Please note:
Serendipity 1.7.4 (announced tomorrow) will ship with updated textile (plugin) libraries, to prevent failing on deprecated functions and even more.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: PHP Deprecated warnings in serendipity_event_textile

Post by garvinhicking » Fri Jan 10, 2014 3:51 pm

Hi Timbalu!

Just a very minor korrinthen-thing:
upper PHP versions
This should be either "newer PHP version" or "higher PHP versions", otherwise it would translate to "obere PHP versionen", not "höhere PHP versionen" ;-)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

Post Reply