Closed sebastian-lenz closed 5 years ago
Thanks for pointing that out! We should definitely swap out string libraries for 3.3 or 4.0.
3.3 is officially out where we swapped to https://github.com/voku/Stringy.
https://github.com/craftcms/cms/blob/master/CHANGELOG-v3.md#330---2019-08-27
Since the above mentioned change I'm getting the following error when I deploy the latest update:
Fatal error: Default value for parameters with a class type hint can only be NULL in /home/user/sites/client/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 24
Plus some warnings that may be related?
Warning: Ambiguous class resolution, "Stringy\Stringy" was found in both "/home/user/sites/client/vendor/voku/stringy/src/Stringy.php" and "/home/user/sites/client/vendor/danielstjules/stringy/src/Stringy.php", the first will be used.
Warning: Ambiguous class resolution, "Stringy\StaticStringy" was found in both "/home/user/sites/client/vendor/voku/stringy/src/StaticStringy.php" and "/home/user/sites/client/vendor/danielstjules/stringy/src/StaticStringy.php", the first will be used.
Warning: Unsupported declare 'strict_types' in /home/user/sites/client/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
Would you have any idea what could be causing this? ¯\_(ツ)_/¯
@RyanRoberts what version of PHP are you using?
Also, how did you deploy? Looks like there are some old files causing conflicts that should have been removed during the update.
@RyanRoberts what version of PHP are you using?
Also, how did you deploy? Looks like there are some old files causing conflicts that should have been removed during the update.
In this case PHP 7.2.21 and I removed the vendor directory to get rid of any old stuff.
I'm deploying via Beanstalk App (so sftp) with a deploy script that runs composer install afterwards.
Thanks
@RyanRoberts Search for "stringy/stringy"
in your composer.json
file; maybe you are manually requiring it. Older Craft 3 releases had a bug where a bunch of additional packages could end up in there after a failed update.
@RyanRoberts Search for
"stringy/stringy"
in yourcomposer.json
file; maybe you are manually requiring it.
There's no sign of that in composer.json. Hmm.
I believe "stringy/stringy" is not correct, so check your composer.json
for "danielstjules/stringy". Even better, try running this command, it should tell you which other package requires the old stringy package:
composer depends danielstjules/stringy
Did that and got this: Could not find package "danielstjules/stringy" in your project
😂
I've deleted the vendor directory and composer.lock file to reinstall and redeploy everything, now I'm getting something a little more specific…
Warning: Unsupported declare 'strict_types' in /home/user/sites/clients/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
Fatal error: Default value for parameters with a class type hint can only be NULL in /home/user/sites/clients/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 24
I'm guessing I'm now looking at something different, PHP related rather than Stringy?
Got to the bottom of it, server is defaulting to the php cli version of 5.6.
Thanks guys.
Regarding stringy, I'm seeing an error using the |snake
twig filter https://docs.craftcms.com/v3/dev/filters.html#snake
Call to undefined method Stringy\Stringy::snakeize()
In the referenced issue above on Craft 3.3.0.1.
@mjatharvest That filter still works on my end. Can you try nuking your vendor/
folder and running composer update
?
@brandonkelly that fixed it, thank you!
Terminal output this, but it still works:
Warning: Ambiguous class resolution, "Stringy\Stringy" was found in both ".../Sites/sanwascreenusa/site/vendor/voku/stringy/src/Stringy.php" and ".../Sites/sanwascreenusa/site/vendor/danielstjules/stringy/src/Stringy.php", the first will be used.
Warning: Ambiguous class resolution, "Stringy\StaticStringy" was found in both ".../Sites/sanwascreenusa/site/vendor/voku/stringy/src/StaticStringy.php" and ".../Sites/sanwascreenusa/site/vendor/danielstjules/stringy/src/StaticStringy.php", the first will be used.
@mjatharvest Search for danielstjules/stringy
in composer.json
and composer.lock
- any occurrences?
I'm getting this error as well after porting my site over to another computer.
Call to undefined method craft\helpers\Stringy::langSpecificCharsArray()
IN vendor/craftcms/cms/src/helpers/Stringy.php
I nuked the composer directory and I ran composer update
. My version of Craft is 3.3.01. I'm running NGINX -- not Apache.
When I run composer depends danielstjules/stringy
I get the following message:
tcb13/substringy 1.0.0 requires danielstjules/stringy (^3.1)
topshelfcraft/wordsmith 3.0.5 requires danielstjules/stringy (~3.1.0)
voku/stringy 5.2.0 replaces danielstjules/stringy (~3.0)
@vaughn-taylor This is a known issue, upgrade to Craft 3.3.1.1 (which locks voku/stringy
to 5.1). Also report this to topshelfcraft/wordsmith
as they have a dependency on danielstjules/stringy
.
@sebastian-lenz, thanks. Updating to 3.3.1.1 worked (I can get into the CP now), but still produces an error Warning: Ambiguous class resolution
which @mjatharvest mentioned above. I will report the error to topshelfcraft/wordsmith
.
In my case danielstjules/stringy
was in composer.lock
. Removing this file and invoking composer install
rectified any obsolete package references. Alternatively, composer update
resolves the issue 9/10 times.
Looks like there was a bug where CP-based updates would leave the danielstjules/stringy
package behind, which led to that Ambiguous class resolution
warning. I’ve fixed this from our end so it shouldn’t happen anymore as people update going forward.
@sebastian-lenz
I'm still having this issue
I've been migrating a site to a development server but when I run composer install
to install dependencies I get this on the 'Generating optimized autoload files' step:
Generating optimized autoload files
Deprecation Notice: Class yii\queue\amqp_interop\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp_interop/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\amqp_interop\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp_interop/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\db\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/db/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\db\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/db/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\db\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/db/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\db\migrations\M161119140200Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M161119140200Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\db\migrations\M170601155600Priority located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M170601155600Priority.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\db\migrations\M170509001400Retry located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M170509001400Retry.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\db\migrations\M170307170300Later located in ./vendor/yiisoft/yii2-queue/src/drivers/db/migrations/M170307170300Later.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\sync\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/sync/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\sqs\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/sqs/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\sqs\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/sqs/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\file\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/file/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\file\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/file/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\file\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/file/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\amqp\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\amqp\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/amqp/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\redis\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/redis/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\redis\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/redis/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\redis\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/redis/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\gearman\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/gearman/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\gearman\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/gearman/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\beanstalk\Command located in ./vendor/yiisoft/yii2-queue/src/drivers/beanstalk/Command.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\beanstalk\InfoAction located in ./vendor/yiisoft/yii2-queue/src/drivers/beanstalk/InfoAction.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class yii\queue\beanstalk\Queue located in ./vendor/yiisoft/yii2-queue/src/drivers/beanstalk/Queue.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class dolphiq\sitemap\assetbundles\Sitemap\SitemapAsset located in ./vendor/dolphiq/sitemap/src/assetbundles/sitemap/SitemapAsset.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class adigital\cookieconsentbanner\assetbundles\CookieConsentBanner\CookieConsentBannerAsset located in ./vendor/adigital/cookie-consent-banner/src/assetbundles/cookieconsentbanner/CookieConsentBannerAsset.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class Solspace\Freeform\Library\Codepack\Exceptions\CodepackException located in ./vendor/solspace/craft-freeform/src/Library/Codepack/Exceptions/CodePackException.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class Solspace\ExpressForms\utilities\CodePack\Exceptions\CodepackException located in ./vendor/solspace/craft-express-forms/src/utilities/CodePack/Exceptions/CodePackException.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class Solspace\ExpressForms\Services\Widgets located in ./vendor/solspace/craft-express-forms/src/services/Widgets.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
Deprecation Notice: Class HTMLPurifier_Language_en_x_test located in ./vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language/classes/en-x-test.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v1.11+. in phar:///usr/lib/plesk-9.0/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:186
PHP Warning: Unsupported declare 'strict_types' in /var/www/vhosts/example.co.uk/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
Warning: Unsupported declare 'strict_types' in /var/www/vhosts/example.co.uk/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /var/www/vhosts/example/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 27
Fatal error: Default value for parameters with a class type hint can only be NULL in /var/www/vhosts/example.co.uk/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 27
The important line is ovviously the fatal error at the end, but this seems to be to do with voku's version of Stringy and not danielstjules' version.
What I've tried
The one thing I tried which seemed to work is running composer install --no-plugins --no-scripts
(the command they recommend you run when running as root). However, this didn't produce the security key for the installation, and then running ./craft setup/security-key
produces the same error:
PHP Warning: Unsupported declare 'strict_types' in /var/www/vhosts/example.co.uk/dev.example.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 3
PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /var/www/vhosts/example.co.uk/dev.exmaple.co.uk/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on line 27
Help please!
@jcush My guess would be that you are actually using an old PHP version, in your error log there is a line which complains about Unsupported declare 'strict_types'
, a directive that was added in PHP7. The final fatal error also sounds like an error you typically get when trying to run PHP7 code on an old interpreter. So this seems more a local issue on your side than an error in Craft?
@sebastian-lenz Thanks for this tip - I'll do some more digging. The php -v
of the console reports PHP 7 but maybe this isn't entirely accurate for some reason...
@RyanRoberts thanks for posting your solution. My PHP version had also reverted and I was seeing the same error. You saved me a lot of time and hassle. I owe you a pint ;)
Right -this problem is in the Craft setup/install files from the Craft web site. But I don't yet have a fix... and need a touch of help.
PHP Warning: Unsupported declare 'strict_types' in /var/craft/vendor/voku/portable-utf8/src/voku/helper/Bootup.php on li PHP Fatal error: Default value for parameters with a class type hint can only be NULL in /var/craft/vendor/voku/portablec/voku/helper/Bootup.php on line 27 Script @php craft setup/welcome handling the post-create-project-cmd event returned with error code 255
The following scenario yields this error:
# composer depends danielstjules/stringy
voku/stringy 6.4.0 replaces danielstjules/stringy (~3.0)
SO for a fix, I edited composer.json which specified php 7.0 and changed to 7.4
Then you can just run php craft setup/welcome
at the command line and it works.
In fact I suspect the change to 7.4 was immaterial, the difference was running php craft setup/welcome
at the command line instead of within its script. So something about running it within the script, changes the php version running it.
Should the json php versions be changed to 7.4 to set the environment? And is this installation now complete, or did the install script have more to do?
Right, I can now add a little more to this... Bootup.php still gives the error. You can insert an echo phpverison into Bootup.php and then # php Bootup.php
and Bootup.php runs without error, and returns pvp 7.4.10. But run craft and Bootup.php gives the error. SO it's an issue with the way Bootup.php is called or the variables passed to it.
Right, homing in on this issue: Put echo phpver into Bootup.php, run it from Bash and it returns 7.4 But comment everything out, put echo phpver into it and run craft, and when it calls Bootup.php, it returns 5.4.16. Why is this?
Ok I worked out the fix to this issue - here it is:
Description
The dependency
danielstjules/stringy
of Craft CMS seems to be abandoned (see discussion here, it has not received updates since mid 2017). Unfortunately the library has issues with PHP 7.3 and we should look for alternatives. The linked issue contains two possible forks that are more actively maintained. This issue is related to #3541.I've tested Craft with PHP 7.3 and the functions of Stringy that have issues on PHP 7.3 don't seem to be used by the CMS. However, in one of my projects I've found code that uses other parts of Stringy which fail on PHP 7.3.
Steps to reproduce
Add a twig extension that defines a function that calls
Stringy::slugify
Use it somewhere in a template
Visit the site on a server running PHP 7.3, an exception will be thrown due to an invalid regular expression. The same code works on lower versions of PHP.
Additional info