picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

[Yaml] PHP-8: Uncaught TypeError: abs() expects parameter 1 to be int or float, string #575

Closed UnderscoreDesign closed 3 years ago

UnderscoreDesign commented 3 years ago

Yaml multiline strings in PHP8 throw a TypeError and was resolved in later versions of Yaml (https://github.com/symfony/symfony/pull/32862/files). The required Yaml version in Pico needs upgrading.

PhrozenByte commented 3 years ago

Can you please provide an example Markdown file with YAML header causing the error?

UnderscoreDesign commented 3 years ago

2-specials.txt

UnderscoreDesign commented 3 years ago

BTW, this works fine in 7.4. I was able to fix on my local dev (PHP 8.0) install by amending line 532 in Yaml/Parser.php:

return $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs((int) $modifiers));

PhrozenByte commented 3 years ago

Can you please try whether a Composer-based installation of v3.0.0-alpha.1 fixes the issue, too? I guess so. I'll release a second alpha for v3.0 including the latest Symfony YAML v3.4 patch release and all changes of the later Pico v2.1 releases then.

The problem is that we can't just upgrade Symfony YAML in a Pico patch release (we follow semantic versioning). Symfony YAML v2.8 is no longer supported (i.e. it won't receive this patch) and upgrading to a newer Symfony YAML branch breaks backwards compatibility. We'll definitely do this sooner or later (ref #535), but in the meantime a new Pico v3.0 alpha (that won't be any lesser stable than Pico v2.1) is a quick solution for PHP 8 users.

UnderscoreDesign commented 3 years ago

Thank you. Pico v3.0.0-alpha did the trick. And, thanks for all your work. Pico is simply fantastic.

PhrozenByte commented 3 years ago

Pico v3.0.0-alpha.2 is out now! :tada:

Can you please try whether the pre-bundled package fixes the issue for you? Thank you! :+1:

You can safely update to this version, it includes all changes from Pico v2.1.2 to v2.1.4 (v3.0.0-alpha.1 was based on v2.1.1). The only difference to Pico v2.1 is that all dependencies were updated to mostly backwards compatible, still officially supported alternatives (to be more precise: Twig 2.12, Symfony YAML 3.4, Parsedown 1.7.4 and Parsedown Extra 0.8.1). However, be aware that "mostly" backwards compatible doesn't mean "fully" backwards compatible, so there might be some issues.

Pico v3.0.0-alpha releases are considered as stable as Pico v2.1, even though they are alpha releases - i.e. you can use them in production. The Pico v3.0.0-alpha release branch solely exists for users that have issues with Pico v2.1 we can't fix without upgrading our dependencies. Pico v3.0.0-alpha releases will stick to Pico v2.1, so you can safely upgrade to any upcoming v3.0.0-alpha release.

However, please be careful when upgrading to a v3.0.0-beta, v3.0.0-rc or the stable v3.0.0 release. These will include all changes from the "real" Pico v3.0 branch (see #535) and will break backwards compatibility. Upgrading from v3.0.0-alpha is the same as upgrading from v2.1 to v3.0.

UnderscoreDesign commented 3 years ago

Pico v3.0.0-alpha.2 works flawlessly! Thank you!!