croxton / Stash

Stash allows you to stash text and snippets of code for reuse throughout your templates.
GNU General Public License v3.0
197 stars 20 forks source link

PHP 8.1 deprecation issues #172

Closed tyssen closed 1 year ago

tyssen commented 2 years ago

Hi Mark,

On PHP 8.1, there are a few deprecation issues. I've fixed some of them, the ones relating to having optional parameters defined before required ones. I just changed the order of the params in mod.stash.php and stash_model.php.

But also getting this one which I don't know how to fix:

preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated user/addons/stash/mod.stash.php, line 236

croxton commented 2 years ago

Could you please download the code from this branch and see if that solves the deprecation notices? https://github.com/croxton/Stash/tree/patch/php-8.1-compatibility

roberthallatt commented 2 years ago

I also ran into this issue today and tested the code but I still get the errors. The lines of code affected are 236, 1075 and 3959 in mod.stash.php.

croxton commented 2 years ago

@roberthallatt I'm running the latest EE 7 and PHP 8.1.10, but can't reproduce any errors. Can you isolate the template code that throws an error?

ttmwebdesign commented 2 years ago

FYI I got deprecation errors too, but I hadn't seen there was a patch until just now. The other thing I noticed when I encountered them, is that these only appeared the first reload of the page after changing to PHP8.0 from 7.4, then they went away and I couldn't make them appear again. Fortunately I copied them but I will try the patch and see if I can get any to reappear, even if it means swapping back down to PHP7.4 and up to 8 again.

croxton commented 1 year ago

These should be fixed now, please start a new issue if you find any more. https://github.com/croxton/Stash/archive/refs/heads/master.zip