OneupFlysystemBundle icon indicating copy to clipboard operation
OneupFlysystemBundle copied to clipboard

Symfony 4 Cache key must be string, "NULL" given

Open pbowyer opened this issue 6 years ago • 6 comments

I have followed https://github.com/1up-lab/OneupFlysystemBundle/blob/master/Resources/doc/filesystem_cache.md to give the configuration:

# Read the documentation: https://github.com/1up-lab/OneupFlysystemBundle/tree/master/Resources/doc/index.md
oneup_flysystem:
    cache:
        s3_local_cache:
            psr6:
                service: cache.s3_local_cache
                key: ~
                expires: ~
    adapters:
        default_adapter:
            local:
                directory: '%kernel.cache_dir%/flysystem'
        private_uploads_adapter:
            awss3v3:
                client: digicore.s3_client
                bucket: '%env(AWS_S3_BUCKET)%'
                prefix: ~
    filesystems:
        default_filesystem:
            adapter: default_adapter
            alias: League\Flysystem\Filesystem
        private_uploads_filesystem:
            adapter: private_uploads_adapter
            cache: s3_local_cache

This gives the error: Uncaught PHP Exception Symfony\Component\Cache\Exception\InvalidArgumentException: "Cache key must be string, "NULL" given" at /var/www/vendor/symfony/cache/CacheItem.php line 169

Commenting out key: ~ fixed it - a documentation issue?

pbowyer avatar Mar 30 '19 12:03 pbowyer

Could you give some more information about your used versions of symfony components?

bytehead avatar Apr 03 '19 06:04 bytehead

Certainly. From composer.json:

    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "knplabs/dictionary-bundle": "^2.2",
        "league/flysystem": "^1.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "league/flysystem-cached-adapter": "^1.0",
        "lexik/form-filter-bundle": "dev-natural-keys",
        "liip/imagine-bundle": "^2.1",
        "nesbot/carbon": "^2.11",
        "oneup/flysystem-bundle": "^3.0",
        "ramsey/uuid": "^3.8",
        "sensio/framework-extra-bundle": "^5.1",
        "symfony/asset": "4.2.*",
        "symfony/console": "4.2.*",
        "symfony/dotenv": "4.2.*",
        "symfony/expression-language": "4.2.*",
        "symfony/flex": "^1.1",
        "symfony/form": "4.2.*",
        "symfony/framework-bundle": "4.2.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/orm-pack": "*",
        "symfony/process": "4.2.*",
        "symfony/security-bundle": "4.2.*",
        "symfony/serializer": "4.2.*",
        "symfony/serializer-pack": "*",
        "symfony/swiftmailer-bundle": "^3.1",
        "symfony/translation": "4.2.*",
        "symfony/twig-bundle": "4.2.*",
        "symfony/validator": "4.2.*",
        "symfony/web-link": "4.2.*",
        "symfony/webpack-encore-bundle": "^1.1",
        "symfony/workflow": "4.2.*",
        "symfony/yaml": "4.2.*",
        "twig/extensions": "^1.5",
        "white-october/pagerfanta-bundle": "^1.2"
    },

pbowyer avatar Apr 03 '19 06:04 pbowyer

I can't reproduce this error.

bytehead avatar Apr 03 '19 07:04 bytehead

I am having the same issue

oneup_flysystem:
    cache:
        psr6_app_cache:
            psr6:
                service: cache.flysystem.psr6
                key: ~
                expires: ~
    adapters:
        uploads_adapter:
            #local:
            #   directory: '%kernel.project_dir%/public/uploads'
            awss3v3:
                client: Aws\S3\S3Client
                bucket: '%env(AWS_S3_BUCKET_NAME)%'
    filesystems:
        uploads_filesystem:
            adapter: uploads_adapter
        cached_uploads_filesystem:
            adapter: uploads_adapter
            cache: psr6_app_cache

This configuration triggers a fatal error Cache key must be string, "NULL" given. It no longer gives a fatal error if I comment out key: ~. However, with this line commented out, things are working but I am getting a warning: WARNING [cache] Failed to save key "flysystem" of type string. ["key" => "flysystem","exception" => null] every time the application is using OneupFlysystemBundle.

apphancer avatar Feb 25 '20 16:02 apphancer

I had the same error installing composer require oneup/flysystem-bundle and setting up s3 adapter with prefix: ~ and then run composer require league/flysystem-aws-s3-v3:^3.0 you get the following error: League\Flysystem\AwsS3V3\AwsS3V3Adapter::__construct(): Argument #3 ($prefix) must be of type string, null given, called in /var/cache/testing/ContainerI3HSw i7/getFilesystem2Service.php on line 38

Removing prefix or setting empty string fixes it

johanadivare avatar Mar 15 '23 14:03 johanadivare

Documentation should be updated for cache key (according to #279).

bytehead avatar Mar 22 '23 08:03 bytehead

This can be closed as completed. https://github.com/1up-lab/OneupFlysystemBundle/blob/main/doc/adapter_awss3.md It Looks to me that it was fixed the same day.

Chris53897 avatar Mar 07 '24 09:03 Chris53897