Editor 2.0.7 with PHP 7.3.27 versus PHP 8.1.7
Editor 2.0.7 with PHP 7.3.27 versus PHP 8.1.7
I am currently migrating my server to the latest version of PHP. I use Editor 2.0.7 in both environments.
With PHP 7.3.27 Editor returns all values as strings. Like in here:
With PHP 8.1.7 numeric values are returned as numbers. Like in here:
This new behavior is not what I want. In fact it makes my Javascript crash. "replace" doesn't work on a number for example etc..
How can I turn this new behavior off?
This question has an accepted answers - jump to answer
Answers
After searching the web I found out that this is something that PHP 8.1 is doing unfortunately. The solution is obviously to tell PDO not to do this.
I don't understand how I can provide an array of PDO attributes. I read how to set a single attribute, but not how to set an array. The attribute and its value are separated by a comma. How do you push this into an array?
Basically I need to do this:
... but that doesn't provide an array?!
ok, this does the trick. And of course you need to provide an associative array for the attributes... Problem solved.
Hi Roland,
I wasn't aware of that change in PHP8 either. I can see upsides and downsides!
Thanks for posting your findings
Allan
Hi Allan,
yes, it was harder than usual to find the solution. I found it here:
https://github.com/doctrine/dbal/issues/5228
This doesn't apply to PHP 8.0, only 8.1 and higher.
Roland
P.S.: Maybe one other thing to share. I also migrated from MySQL 5.7.33 to MariaDB 10.6.8 which is pretty much the latest stable release compatible with the latest version of Plesk Obsidian. My new virtual linux server might be a little stronger than the old one but not much. One query loading all my users took 18 seconds previously; this is now down to 1.3 seconds without any further changes. This is pretty awesome I think. (I also updated from Ubuntu 16.04 to Ubuntu 20.04 - not sure whether that does something, too.).