You are here:  » Upgrading to PHP 7


Upgrading to PHP 7

Submitted by NiceGuyEddie on Mon, 2019-02-25 11:22 in

Hi David,

One of my heavily modified older PT installations has stopped working since upgrading to php 7.

The specific error message I get is as follows:

PHP message: PHP Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead

I have tried replacing the code for the function tapestry_normalise from a working later version of PT but no luck?

Is there a quick fix available?

Thanks

Submitted by support on Mon, 2019-02-25 11:28

Hi Eddie,

Yes, it's just the deprecated modifier that you need to remove from the expression in both calls to preg_replace() in includes/tapestry.php. Look for the following code around line 27:

    $text = preg_replace('/[^A-Za-z0-9'.$allow.' ]/e','',$text);

...and REPLACE with:

    $text = preg_replace('/[^A-Za-z0-9'.$allow.' ]/','',$text);

And also the following code around line 38:

    $price = preg_replace('/[^0-9\.]/e','',$price);

...and REPLACE with:

    $price = preg_replace('/[^0-9\.]/','',$price);

Cheers,
David.
--
PriceTapestry.com

Submitted by NiceGuyEddie on Mon, 2019-02-25 11:57

Thanks David,

Unfortunatey no joy. I now get the following error:

PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mysql_escape_string()

Submitted by support on Mon, 2019-02-25 12:07

Hi Eddie,

Extract and use database.php from the appropriate Forward Compatibility Patch for the distribution you are running.

There shouldn't need to be any further changes to includes/tapestry.php and as you mentioned that your site is heavily modified it is likely that there are other changes in that file you don't want to lose...

Cheers,
David.
--
PriceTapestry.com

Submitted by NiceGuyEddie on Mon, 2019-02-25 12:14

Thanks David