BoltTranslate / Translate

Provides translation for contenttypes.
Other
43 stars 38 forks source link

[BUG] Error when updating php7.2 -> php7.4 (but I found a trick) #211

Open evertalbers opened 3 years ago

evertalbers commented 3 years ago

I ran into an error when updating from php7.2 to php7.4 (which I performed first via the hoster's dashboard) which also caused me to upgrade from Bolt <3.6 to Bolt 3.7.2 (Bolt 3.6 frontend worked fine on php 7.4, but the backend not so much.

Bob saw the screenshot (attached) and asked me to post it here, sine it looks translate-related.

But: there seems to be a trick when I use 2 steps:

Details

image

clem commented 3 years ago

Hi Evert 👋 ,

I had the same problem but I think I figured out how to fix it 😃

Quick answer

Update the version of Translate, this bug has been fixed in 4.2.2 👌

Long answer

As I had the same issue, I was using the 4.2.1 version. I tried to bypass the bug by switching PHP versions. It worked from 7.2 to 7.3, but not from 7.3 to 7.4.

After some research, I found the culprit was this $contentType['fields'], because of an incompatible change in PHP 7.4 (see https://www.php.net/manual/en/migration74.incompatible.php - "Array-style access of non-arrays"). Before PHP 7.4, when you used $contentType['fields'] on a null $contentType, PHP returned null. With PHP ^7.4, it will generates a notice and Bolt throws a ContextErrorException.

After I discovered this, I wanted to create a pull request to fix the bug... But I found it was already merged in #205 🎉

So, you just need to update your version of Translate to the latest (4.2.4 at the time of this comment) and it will fix your issue.

Have a nice day!