Page 1 of 2

PHP Deprecated warnings in serendipity_event_textile

Posted: Fri Nov 29, 2013 5:37 pm
by konus
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

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Fri Nov 29, 2013 6:40 pm
by Timbalu
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?

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Fri Nov 29, 2013 11:10 pm
by konus
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?

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Sat Nov 30, 2013 9:36 am
by Timbalu
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?]

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Sun Dec 01, 2013 12:07 am
by konus
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

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Sun Dec 01, 2013 9:22 am
by Timbalu
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.

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Wed Dec 04, 2013 11:26 am
by ICE
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

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Wed Dec 04, 2013 11:41 am
by Timbalu
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

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Wed Dec 04, 2013 12:39 pm
by ICE
Thanks for the answer!
No, i can wait ... its only my development server ...

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Wed Dec 04, 2013 12:41 pm
by Timbalu
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?

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Wed Dec 04, 2013 12:45 pm
by bernd_d
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.

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Tue Dec 10, 2013 2:09 pm
by bugrep
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);

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Tue Dec 10, 2013 2:21 pm
by Timbalu
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?

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Fri Jan 10, 2014 3:08 pm
by Timbalu
Please note:
Serendipity 1.7.4 (announced tomorrow) will ship with updated textile (plugin) libraries, to prevent failing on deprecated functions and even more.

Re: PHP Deprecated warnings in serendipity_event_textile

Posted: Fri Jan 10, 2014 3:51 pm
by garvinhicking
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" ;-)