Wedge

Public area => The Pub => Off-topic => Topic started by: MultiformeIngegno on January 24th, 2014, 01:31 AM

Title: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 24th, 2014, 01:31 AM
Code: [Select]
$input = preg_replace('`(#[^"<]*)`e', 'str_replace("~", "-", "$1")', $input);
(Aeva-Embed.php:387)

What should I replace this line with to avoid being flooded with errors on PHP 5.5.x ? :angel: :eheh:
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: Pandos on January 24th, 2014, 10:27 AM
Quote from MultiformeIngegno on January 24th, 2014, 01:31 AM
Code: [Select]
$input = preg_replace('`(#[^"<]*)`e', 'str_replace("~", "-", "$1")', $input);
(Aeva-Embed.php:387)

What should I replace this line with to avoid being flooded with errors on PHP 5.5.x ? :angel: :eheh:
Are you on the latest version?
Can't find the mentioned code in Aeva-Embed.php....

Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 24th, 2014, 11:12 AM
Mine is 2.10
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: Nao on January 24th, 2014, 04:01 PM
I don't do support on Aeva Media for SMF.
Well, because it only takes a second, I'll do it, but still :P

Code: [Select]
$input = preg_replace_callback('`(#[^"<]*)`', function ($match) { return str_replace('~', '-', $match[0]); }, $input);

I *think* this should work. Please confirm.
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 24th, 2014, 04:04 PM
I know but I asked pretty pretty please with sugar on top :P :P
Will try tonight! Thanks !! ;)
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: Nao on January 24th, 2014, 04:07 PM
Now you're confusing me... Like, "should I upload this PHP 5.5 fix to the SMF site..?"
And yet, just this morning I was considering removing it from over there, like, entirely... :-/
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 24th, 2014, 04:47 PM
Eheh it's a choice
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 24th, 2014, 07:10 PM
Quote from MultiformeIngegno on January 24th, 2014, 04:04 PM
Will try tonight! Thanks !! ;)
Works! :cool:
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 25th, 2014, 06:15 PM
Ehm... this should be the only one left (preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead)
Code: [Select]
$message = preg_replace('~\[' . $tag . ']((?>[^[]|\[(?!/?' . $tag . '])|(?R))+?)\[/' . $tag . ']~ie',
"'[" . $tag . "]' . str_ireplace('[smg', '&#91;smg', '$1') . '[/" . $tag . "]'", $message);
Aeva-Subs.php:2546
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: Nao on January 25th, 2014, 07:16 PM
On first sight, I'd say...
- Add _callback in the function call,
- remove the 'e' modifier,
- and replace the replacement string with...

Code: [Select]
function ($match) use ($tag) { return '[' . $tag . ']' . str_ireplace('[smg', '&#91;smg', $match[1]) . '[/' . $tag . ']'; }

It's not a complicated task to rewrite these, really. My versions are PHP 5.3-only though, as usual.
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 26th, 2014, 02:28 AM
Will try tomorrow :)
Posted: January 25th, 2014, 08:03 PM

Nao what's the goal of the regex? Is it to replace all [ before smg inside all nested levels inside [$tag] tags with &#91; ..?
Posted: January 26th, 2014, 02:03 AM

What about..

Code: [Select]
$pattern = '~(\[' . $tag . '])((?>[^[]++|\[(?!/?+' . $tag . '])|(?R))*+)(\[/'
         . $tag . '])~i';
$message = preg_replace_callback($pattern,
                                 function ($m) {
                                     return $m[1]
                                          . str_ireplace('[smg', '&#91;smg', $m[2])
                                          . $m[3];
                                 }, $message);
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 26th, 2014, 10:15 PM
Quote from MultiformeIngegno on January 26th, 2014, 02:28 AM
What about..

Code: [Select]
$pattern = '~(\[' . $tag . '])((?>[^[]++|\[(?!/?+' . $tag . '])|(?R))*+)(\[/'
         . $tag . '])~i';
$message = preg_replace_callback($pattern,
                                 function ($m) {
                                     return $m[1]
                                          . str_ireplace('[smg', '&#91;smg', $m[2])
                                          . $m[3];
                                 }, $message);
Seems to work (I don't get any error). How can I test it didn't break anything?
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: Nao on January 26th, 2014, 10:30 PM
It'll probably work, as it's close in spirit to the Wedge version.
Why didn't you simply use the one I gave you, though..? :P
Title: Re: Aeva: preg_replace(): The /e modifier is deprecated, use preg_replace_callback
Post by: MultiformeIngegno on January 26th, 2014, 10:45 PM
Quote from Nao on January 26th, 2014, 10:30 PM
It'll probably work, as it's close in spirit to the Wedge version.
Why didn't you simply use the one I gave you, though..? :P
'cause I don't know what you said ahahah