Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] CacheItem must be compatible #978

Open
c-o-m-m-a-n-d-e-r opened this issue Jan 8, 2025 · 8 comments
Open

[bug] CacheItem must be compatible #978

c-o-m-m-a-n-d-e-r opened this issue Jan 8, 2025 · 8 comments
Assignees

Comments

@c-o-m-m-a-n-d-e-r
Copy link

c-o-m-m-a-n-d-e-r commented Jan 8, 2025

Hi,
i'm getting the same Error like here:
https://community.humhub.com/comment/perma?id=51033

The Error is :
Declaration of Detection\Cache\Cache::get(string $key, mixed $default = null): ?Detection\Cache\CacheItem must be compatible with PsrExt\SimpleCache\CacheInterface::get($key, $default = <default>)

Already tried reinstalling via composer without luck.

Usage is only:
use Detection\MobileDetect; $detect = new MobileDetect(); $isMobile = $detect->isMobile();

Bildschirmfoto 2025-01-08 um 09 16 20

@ArchBlood
Copy link

@c-o-m-m-a-n-d-e-r thanks for mentioning this issue as well as the community message with my comments about the issue;

@serbanghita currently for a number of my clients that are using @humhub as of v1.17.0-beta.4 which introduces this package can not be updated correctly due to the Cache class not being compatible with the interface, and I've had to use the following complete code and manually do this with a number of instances already;

Complete Code

Replace https://github.com/serbanghita/Mobile-Detect/blob/4.8.x/src/Cache/Cache.php to be compatible with CacheInterface class. I leave this code to be either adapted or modified by the maintainer.

<?php

namespace Detection\Cache;

use Psr\SimpleCache\CacheInterface;
use Psr\SimpleCache\InvalidArgumentException;

class Cache implements CacheInterface
{
    protected array $cache_db = [];

    public function count(): int
    {
        return count($this->cache_db);
    }

    /**
     * @return array{string}
     */
    public function getKeys(): array
    {
        return array_keys($this->cache_db);
    }

    public function get($key, $default = null)
    {
        if (!is_string($key) || $key === '') {
            throw new InvalidArgumentException('Invalid cache key');
        }

        return $this->cache_db[$key] ?? $default;
    }

    public function set($key, $value, $ttl = null): bool
    {
        if (!is_string($key) || $key === '') {
            throw new InvalidArgumentException('Invalid cache key');
        }

        $this->cache_db[$key] = ['value' => $value, 'ttl' => $ttl];
        return true;
    }

    public function delete($key): bool
    {
        unset($this->cache_db[$key]);
        return true;
    }

    public function clear(): bool
    {
        $this->cache_db = [];
        return true;
    }

    public function getMultiple($keys, $default = null): iterable
    {
        $results = [];
        foreach ($keys as $key) {
            $results[$key] = $this->get($key, $default);
        }
        return $results;
    }

    public function setMultiple($values, $ttl = null): bool
    {
        foreach ($values as $key => $value) {
            $this->set($key, $value, $ttl);
        }
        return true;
    }

    public function deleteMultiple($keys): bool
    {
        foreach ($keys as $key) {
            $this->delete($key);
        }
        return true;
    }

    public function has($key): bool
    {
        return isset($this->cache_db[$key]);
    }
}

@marc-farre
Copy link

@c-o-m-m-a-n-d-e-r how do you install and update HumHub?

From the zip? https://docs.humhub.org/docs/admin/installation#download-and-extract
From git? https://docs.humhub.org/docs/develop/environment#gitcomposer-installation
A mix of both (e.g. also using the Updater module)?

It seems that you install it from git if you use composer.

  • When you do a composer update, have you any warning?
  • What is your PHP version (in command line, when updating composer)?
  • Could you copy/paste here the result of composer show -i? (@ArchBlood that could be interesting too, to have your list)

What cache are you using? Have you got specific configuration in your common.php file, such as some similar to:

        'cache' => [
            'class' => \yii\caching\DummyCache::class,
        ],

Thank you for your help.

@c-o-m-m-a-n-d-e-r
Copy link
Author

@marc-farre sorry i don't use HumHub ... i had the same error in another project so i do some research and found the solution from @ArchBlood

@marc-farre
Copy link

@c-o-m-m-a-n-d-e-r Sorry, by receiving a notification about this topic, I thought I was writing in the HumHub Git repository...

However, if both of you could send me the result of composer show -i, it could interesting to see what library versions you are using.

@ArchBlood
Copy link

composer show -i

From my end I see no issues;

async-aws/core                          1.23.0             Core package to integrate with AWS. This is a lightweight AWS SDK provider by As...
async-aws/ses                           1.9.0              SES client, part of the AWS SDK provided by AsyncAws.
behat/gherkin                           v4.11.0            Gherkin DSL parser for PHP
bower-asset/bootstrap                   v3.4.1
bower-asset/inputmask                   5.0.9
bower-asset/jquery                      3.7.1
bower-asset/jquery-ui                   1.12.1
bower-asset/punycode                    v1.4.1
bower-asset/yii2-pjax                   2.0.8
brick/math                              0.9.3              Arbitrary-precision arithmetic library
brick/varexporter                       0.5.0              A powerful alternative to var_export(), which can export closures and objects wi...
cebe/markdown                           1.2.1              A super fast, highly extensible markdown parser for PHP
clue/ndjson-react                       v1.3.0             Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.
codeception/codeception                 4.2.2              BDD-style testing framework
codeception/lib-asserts                 1.13.2             Assertion methods used by Codeception core and Asserts module
codeception/lib-innerbrowser            1.5.1              Parent library for all Codeception framework modules and PhpBrowser
codeception/module-asserts              1.3.1              Codeception module containing various assertions
codeception/module-filesystem           1.0.3              Codeception module for testing local filesystem
codeception/module-rest                 1.4.2              REST module for Codeception
codeception/module-webdriver            1.4.1              WebDriver module for Codeception
codeception/module-yii2                 1.1.5              Codeception module for Yii2 framework
codeception/phpunit-wrapper             9.0.9              PHPUnit classes used by Codeception
codeception/specify                     1.4.0              BDD code blocks for PHPUnit and Codeception
codeception/stub                        3.7.0              Flexible Stub wrapper for PHPUnit's Mock Builder
codeception/verify                      1.5.0              BDD assertion library for PHPUnit
composer/pcre                           3.3.2              PCRE wrapping library that offers type-safe preg_* replacements.
composer/semver                         3.4.3              Semver library that offers utilities, version constraint parsing and validation.
composer/xdebug-handler                 3.0.5              Restarts a process without Xdebug.
doctrine/instantiator                   2.0.0              A small, lightweight utility to instantiate objects in PHP without invoking thei...
doctrine/lexer                          3.0.1              PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descen...
egulias/email-validator                 4.0.2              A library for validating emails against several RFCs
evenement/evenement                     v3.0.2             Événement is a very simple event dispatching library for PHP
ezyang/htmlpurifier                     v4.18.0            Standards compliant HTML filter written in PHP
fakerphp/faker                          v1.24.1            Faker is a PHP library that generates fake data for you.
fgrosse/phpasn1                         v2.5.0             A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures ...
fidry/cpu-core-counter                  1.2.0              Tiny utility to get the number of CPU cores.
firebase/php-jwt                        v6.10.2            A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should confo...
friendsofphp/php-cs-fixer               v3.65.0            A tool to automatically fix PHP code style
graham-campbell/result-type             v1.1.3             An Implementation Of The Result Type
guzzlehttp/psr7                         2.7.0              PSR-7 message implementation that also provides common utility methods
imagine/imagine                         1.5.0              Image processing for PHP
jbroadway/urlify                        1.2.4-stable       A fast PHP slug generator and transliteration library that converts non-ascii ch...
justinrainbow/json-schema               v5.2.13            A library to validate a json schema.
kartik-v/bootstrap-fileinput            v5.5.4             An enhanced HTML 5 file input for Bootstrap 5.x, 4.x, and 3.x with features for ...
kartik-v/bootstrap-star-rating          v4.1.2             A simple yet powerful JQuery star rating plugin for Bootstrap.
kartik-v/dependent-dropdown             v1.4.9             A multi level dependent dropdown JQuery plugin that allows nested dependencies.
kartik-v/yii2-krajee-base               v3.0.5             Base library and foundation components for all Yii2 Krajee extensions.
kartik-v/yii2-widget-activeform         v1.6.4             Enhanced Yii2 active-form and active-field with full bootstrap styling support (...
kartik-v/yii2-widget-affix              v1.0.0             A scrollspy and affixed enhanced navigation to highlight page sections (sub repo...
kartik-v/yii2-widget-alert              v1.1.5             A widget to generate alert based notifications using bootstrap-alert plugin (sub...
kartik-v/yii2-widget-colorinput         v1.0.6             An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split fr...
kartik-v/yii2-widget-datepicker         v1.4.8             Enhanced Yii2 wrapper for the bootstrap datepicker plugin (sub repo split from y...
kartik-v/yii2-widget-datetimepicker     v1.5.1             Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split fr...
kartik-v/yii2-widget-depdrop            v1.0.6             Widget that enables setting up dependent dropdowns with nested dependencies (sub...
kartik-v/yii2-widget-fileinput          v1.1.1             An enhanced FileInput widget for Bootstrap 3.x, 4.x & 5.x with file preview, mul...
kartik-v/yii2-widget-growl              v1.1.2             A widget to generate growl based notifications using bootstrap-growl plugin (sub...
kartik-v/yii2-widget-rangeinput         v1.0.2             An enhanced Yii 2 widget encapsulating the HTML 5 range input (sub repo split fr...
kartik-v/yii2-widget-rating             v1.0.5             A Yii2 widget for the simple yet powerful bootstrap-star-rating plugin with frac...
kartik-v/yii2-widget-select2            v2.2.5             Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-wi...
kartik-v/yii2-widget-sidenav            v1.0.1             An enhanced side navigation menu styled for bootstrap (sub repo split from yii2-...
kartik-v/yii2-widget-spinner            v1.0.1             A widget to render animated CSS3 loading spinners with VML fallback for IE (sub ...
kartik-v/yii2-widget-switchinput        v1.3.1             A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios...
kartik-v/yii2-widget-timepicker         v1.0.5             Enhanced Yii2 wrapper for the bootstrap timepicker plugin (sub repo split from y...
kartik-v/yii2-widget-touchspin          v1.2.4             A Yii2 wrapper widget for the Bootstrap Switch plugin to use checkboxes & radios...
kartik-v/yii2-widget-typeahead          v1.0.4             Enhanced Yii2 wrapper for the Twitter Typeahead plugin (sub repo split from yii2...
kartik-v/yii2-widgets                   v3.4.1             Collection of useful widgets for Yii Framework 2.0 extending functionalities for...
laminas/laminas-escaper                 2.15.0             Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs
laminas/laminas-http                    2.21.0             Provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) re...
laminas/laminas-ldap                    2.18.1             Provides support for LDAP operations including but not limited to binding, searc...
laminas/laminas-loader                  2.11.1             Autoloading and plugin loading strategies
laminas/laminas-servicemanager          4.3.0              Factory-Driven Dependency Injection Container
laminas/laminas-stdlib                  3.20.0             SPL extensions, array utilities, error handlers, and more
laminas/laminas-translator              1.1.0              Interfaces for the Translator component of laminas-i18n
laminas/laminas-uri                     2.13.0             A component that aids in manipulating and validating » Uniform Resource Identif...
laminas/laminas-validator               3.0.1              Validation classes for a wide range of domains, and the ability to chain validat...
laminas/laminas-zendframework-bridge    1.8.0              Alias legacy ZF class names to Laminas Project equivalents.
maennchen/zipstream-php                 3.1.1              ZipStream is a library for dynamically streaming dynamic zip files from PHP with...
markbaker/complex                       3.0.2              PHP Class for working with complex numbers
markbaker/matrix                        3.0.1              PHP Class for working with matrices
matthewbdaly/zendsearch                 0.0.3              A fork of zendframework/zendsearch, with some tweaks to make it work in PHP 7
mistic100/randomcolor                   1.1.0              Generate attractive random colors
mobiledetect/mobiledetectlib            4.8.09             Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses t...
myclabs/deep-copy                       1.12.1             Create deep copies (clones) of your objects
nikic/php-parser                        v5.3.1             A PHP parser written in PHP
npm-asset/after                         0.8.2
npm-asset/animate.css                   4.1.1
npm-asset/arraybuffer.slice             0.0.7
npm-asset/backo2                        1.0.2
npm-asset/base64-arraybuffer            0.1.4
npm-asset/blob                          0.0.5
npm-asset/bluebird                      3.7.2
npm-asset/blueimp-canvas-to-blob        3.5.0
npm-asset/blueimp-file-upload           9.34.0
npm-asset/blueimp-gallery               2.44.0
npm-asset/blueimp-load-image            2.12.2
npm-asset/blueimp-tmpl                  3.6.0
npm-asset/bootstrap                     3.4.1
npm-asset/bootstrap-tour                0.11.0
npm-asset/clipboard-polyfill            3.0.3
npm-asset/codemirror                    5.65.18
npm-asset/component-bind                1.0.0
npm-asset/component-emitter             1.3.1
npm-asset/component-inherit             0.0.3
npm-asset/debug                         3.1.0
npm-asset/engine.io-client              3.5.4
npm-asset/engine.io-parser              2.2.1
npm-asset/ev-emitter                    2.1.2
npm-asset/font-awesome                  4.7.0
npm-asset/fontsource--open-sans         5.1.0
npm-asset/has-binary2                   1.0.3
npm-asset/has-cors                      1.1.0
npm-asset/humhub-prosemirror-richtext   2.1.5
npm-asset/imagesloaded                  5.0.0
npm-asset/indexof                       0.0.1
npm-asset/intersection-observer         0.7.0
npm-asset/isarray                       2.0.1
npm-asset/jplayer                       2.9.2
npm-asset/jquery                        3.6.4
npm-asset/jquery-autosize               1.18.18
npm-asset/jquery-highlight              3.5.0
npm-asset/jquery-knob                   1.2.13
npm-asset/jquery-ui                     1.14.1
npm-asset/jquery.cookie                 1.4.1
npm-asset/kbw.timeentry                 2.0.2
npm-asset/ms                            2.0.0
npm-asset/nprogress                     0.2.0
npm-asset/parseqs                       0.0.6
npm-asset/parseuri                      0.0.6
npm-asset/select2                       4.0.13
npm-asset/select2-bootstrap-theme       0.1.0-beta.10
npm-asset/socket.io-client              2.5.0
npm-asset/socket.io-parser              3.3.2
npm-asset/swiped-events                 1.2.0
npm-asset/timeago                       1.6.7
npm-asset/to-array                      0.1.4
npm-asset/unicode-emoji-json            0.5.0
npm-asset/ws                            7.5.10
npm-asset/xmlhttprequest-ssl            1.6.3
npm-asset/yeast                         0.1.2
paragonie/random_compat                 v9.99.100          PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest                        2.0.4              Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                         3.2.1              Library for handling version information and constraints
php-webdriver/webdriver                 1.15.2             A PHP client for Selenium WebDriver. Previously facebook/webdriver.
phpcompatibility/php-compatibility      9.3.5              A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibil...
phpoffice/phpspreadsheet                2.3.4              PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadshe...
phpoption/phpoption                     1.9.3              Option Type for PHP
phpspec/php-diff                        v1.1.3             A comprehensive library for generating differences between two hashable objects ...
phpunit/php-code-coverage               9.2.32             Library that provides collection, processing, and rendering functionality for PH...
phpunit/php-file-iterator               3.0.6              FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                     3.1.1              Invoke callables with a timeout
phpunit/php-text-template               2.0.4              Simple template engine.
phpunit/php-timer                       5.0.3              Utility class for timing
phpunit/phpunit                         9.6.22             The PHP Unit Testing framework.
psr/cache                               3.0.0              Common interface for caching libraries
psr/container                           2.0.2              Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                    1.0.0              Standard interfaces for event handling.
psr/http-client                         1.0.3              Common interface for HTTP clients
psr/http-factory                        1.1.0              PSR-17: Common interfaces for PSR-7 HTTP message factories
psr/http-message                        2.0                Common interface for HTTP messages
psr/log                                 2.0.0              Common interface for logging libraries
psr/simple-cache                        3.0.0              Common interfaces for simple caching
ralouphie/getallheaders                 3.0.3              A polyfill for getallheaders.
raoul2000/yii2-jcrop-widget             1.0.0              This extension is a wrapper for the jQuery Image Cropping Plugin (jcrop)
react/cache                             v1.2.0             Async, Promise-based cache interface for ReactPHP
react/child-process                     v0.6.5             Event-driven library for executing child processes with ReactPHP.
react/dns                               v1.13.0            Async DNS resolver for ReactPHP
react/event-loop                        v1.5.0             ReactPHP's core reactor event loop that libraries can use for evented I/O.
react/promise                           v3.2.0             A lightweight implementation of CommonJS Promises/A for PHP
react/socket                            v1.16.0            Async, streaming plaintext TCP/IP and secure TLS socket server and client connec...
react/stream                            v1.4.0             Event-driven readable and writable streams for non-blocking I/O in ReactPHP
roave/security-advisories               dev-latest 5a88337 Prevents installation of composer packages with known security vulnerabilities: ...
sebastian/cli-parser                    1.0.2              Library for parsing CLI options
sebastian/code-unit                     1.0.8              Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup      2.0.3              Looks up which function or method a line of code belongs to
sebastian/comparator                    4.0.8              Provides the functionality to compare PHP values for equality
sebastian/complexity                    2.0.3              Library for calculating the complexity of PHP code units
sebastian/diff                          4.0.6              Diff implementation
sebastian/environment                   5.1.5              Provides functionality to handle HHVM/PHP environments
sebastian/exporter                      4.0.6              Provides the functionality to export PHP variables for visualization
sebastian/global-state                  5.0.7              Snapshotting of global state
sebastian/lines-of-code                 1.0.4              Library for counting the lines of code in PHP source code
sebastian/object-enumerator             4.0.4              Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector              2.0.4              Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context             4.0.5              Provides functionality to recursively process PHP variables
sebastian/resource-operations           3.0.4              Provides a list of PHP built-in functions that operate on resources
sebastian/type                          3.2.1              Collection of value objects that represent the types of the PHP type system
sebastian/version                       3.0.2              Library that helps with managing the version number of Git-hosted PHP projects
select2/select2                         4.0.13             Select2 is a jQuery based replacement for select boxes.
softcreatr/jsonpath                     0.7.5              JSONPath implementation for parsing, searching and flattening arrays
spomky-labs/base64url                   v2.0.4             Base 64 URL Safe Encoding/Decoding PHP Library
squizlabs/php_codesniffer               3.11.2             PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations o...
symfony/amazon-mailer                   v5.4.45            Symfony Amazon Mailer Bridge
symfony/browser-kit                     v3.4.47            Symfony BrowserKit Component
symfony/console                         v5.4.47            Eases the creation of beautiful and testable command line interfaces
symfony/css-selector                    v5.4.45            Converts CSS selectors to XPath expressions
symfony/deprecation-contracts           v3.5.1             A generic function and convention to trigger deprecation notices
symfony/dom-crawler                     v4.4.45            Eases DOM navigation for HTML and XML documents
symfony/event-dispatcher                v5.4.45            Provides tools that allow your application components to communicate with each o...
symfony/event-dispatcher-contracts      v3.5.1             Generic abstractions related to dispatching event
symfony/filesystem                      v6.4.13            Provides basic utilities for the filesystem
symfony/finder                          v5.4.45            Finds files and directories via an intuitive fluent interface
symfony/google-mailer                   v5.4.45            Symfony Google Mailer Bridge
symfony/http-client                     v6.4.16            Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/http-client-contracts           v3.5.2             Generic abstractions related to HTTP clients
symfony/mailchimp-mailer                v5.4.45            Symfony Mailchimp Mailer Bridge
symfony/mailer                          v5.4.45            Helps sending emails
symfony/mailgun-mailer                  v5.4.45            Symfony Mailgun Mailer Bridge
symfony/mailjet-mailer                  v5.4.45            Symfony Mailjet Mailer Bridge
symfony/mime                            v6.4.13            Allows manipulating MIME messages
symfony/oh-my-smtp-mailer               v5.4.45            Symfony OhMySMTP Mailer Bridge
symfony/options-resolver                v6.4.16            Provides an improved replacement for the array_replace PHP function
symfony/polyfill-ctype                  v1.31.0            Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme          v1.31.0            Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-idn               v1.31.0            Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer        v1.31.0            Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring               v1.31.0            Symfony polyfill for the Mbstring extension
symfony/polyfill-php73                  v1.31.0            Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80                  v1.31.0            Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81                  v1.31.0            Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/postmark-mailer                 v5.4.45            Symfony Postmark Mailer Bridge
symfony/process                         v6.4.15            Executes commands in sub-processes
symfony/sendgrid-mailer                 v5.4.45            Symfony Sendgrid Mailer Bridge
symfony/sendinblue-mailer               v5.4.45            Symfony Sendinblue Mailer Bridge
symfony/service-contracts               v3.5.1             Generic abstractions related to writing services
symfony/stopwatch                       v6.4.13            Provides a way to profile code
symfony/string                          v6.4.15            Provides an object-oriented API to strings and deals with bytes, UTF-8 code poin...
symfony/translation-contracts           v3.5.1             Generic abstractions related to translation
symfony/yaml                            v5.4.45            Loads and dumps YAML files
theseer/tokenizer                       1.2.3              A small library for converting tokenized PHP source code into XML and potentiall...
twig/string-extra                       v3.17.0            A Twig extension for Symfony String
twig/twig                               v3.17.1            Twig, the flexible, fast, and secure template language for PHP
vlucas/phpdotenv                        v5.6.1             Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` au...
voku/portable-ascii                     2.0.3              Portable ASCII library - performance optimized (ascii) string functions for php.
voku/stop-words                         2.0.1              Stop-Words via PHP
web-token/jwt-checker                   v2.2.11            Checker component of the JWT Framework.
web-token/jwt-core                      v2.2.11            Core component of the JWT Framework.
web-token/jwt-signature                 v2.2.11            Signature component of the JWT Framework.
web-token/jwt-signature-algorithm-ecdsa v2.2.11            ECDSA Based Signature Algorithms the JWT Framework.
web-token/jwt-signature-algorithm-hmac  v2.2.11            HMAC Based Signature Algorithms the JWT Framework.
web-token/jwt-signature-algorithm-rsa   v2.2.11            RSA Based Signature Algorithms the JWT Framework.
xj/yii2-jplayer-widget                  2.7.0.3            yii2-jplayer-widget
yiisoft/yii2                            dev-master f5b2635 Yii PHP Framework Version 2
yiisoft/yii2-authclient                 2.2.16             External authentication via OAuth and OpenID for the Yii framework
yiisoft/yii2-bootstrap                  2.0.11             The Twitter Bootstrap extension for the Yii framework
yiisoft/yii2-composer                   2.0.10             The composer plugin for Yii extension installer
yiisoft/yii2-debug                      2.1.25             The debugger extension for the Yii framework
yiisoft/yii2-faker                      2.0.5              Fixture generator. The Faker integration for the Yii framework.
yiisoft/yii2-gii                        2.2.6              The Gii extension for the Yii framework
yiisoft/yii2-httpclient                 2.0.15             HTTP client extension for the Yii framework
yiisoft/yii2-imagine                    2.3.1              The Imagine integration for the Yii framework
yiisoft/yii2-jui                        2.0.7              The Jquery UI extension for the Yii framework
yiisoft/yii2-queue                      2.3.7              Yii2 Queue Extension which supported DB, Redis, RabbitMQ, Beanstalk, SQS and Gea...
yiisoft/yii2-redis                      2.0.18             Redis Cache, Session and ActiveRecord for the Yii framework
yiisoft/yii2-symfonymailer              2.0.4              The SymfonyMailer integration for the Yii framework

@marc-farre
Copy link

@ArchBlood Thanks. I compared with a diff tool, and I have the same list (some versions could be updated, but I doubt it will fix this issue).

@ArchBlood
Copy link

@marc-farre here is my final judgement about this issue, the Cache class doesn't fully comply with PSR-16 due to the following;

1. Return Type of get Method

  • Issue: PSR-16's get method must return mixed. This get method returns CacheItem|null, which is incompatible.
  • Fix: Update the get method's return type to mixed.

2. get and set Exceptions

  • Issue: The PSR-16 specification states that get and set should only throw Psr\SimpleCache\InvalidArgumentException if the key is invalid. The code throws a custom CacheException, which is not part of PSR-16.
  • Fix: Ensure CacheException implements Psr\SimpleCache\InvalidArgumentException or replace it with the appropriate exception type.

3. getMultiple Return Type

  • Issue: PSR-16 requires getMultiple to return an iterable where the keys map to their corresponding values or $default. This implementation does not respect the $default parameter for keys that are missing.
  • Fix: Update getMultiple to properly handle missing keys by returning $default for them.

4. setMultiple Parameter Type

  • Issue: According to PSR-16, the $values parameter in setMultiple must be an iterable of key-value pairs. The PHPDoc specifies array<array{key:string, value:string}>, which is incompatible.
  • Fix: Adjust the PHPDoc and ensure that $values is processed as key-value pairs.

5. set TTL Handling

  • Issue: PSR-16 mandates that the $ttl parameter should accept null (for no expiration), an int (time in seconds), or a DateInterval. This implementation appears correct here, but needs to ensure that these cases are handled appropriately.

6. Custom CacheItem Class

  • Issue: PSR-16 does not use or require a CacheItem class. The CacheItem in the code is not defined here, and its compatibility with the interface is unclear.
  • Fix: Avoid using a custom CacheItem unless necessary and ensure compliance with PSR-16.

7. count and getKeys Methods

  • Issue: These methods are not part of PSR-16 and add unnecessary API surface area. While they are harmless in a broader sense, they deviate from the interface.
  • Fix: Remove methods not defined in the PSR-16 interface or document them clearly as extensions.

@ArchBlood
Copy link

#978 (comment) will fix the issue, but it can always be improved for backwards compatibility which is what I think was the intent of the current implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants