From b3af5f1b86e1f9e950a1a1b55529bcfb8cedde1c Mon Sep 17 00:00:00 2001 From: Kamil Wylegala Date: Thu, 19 Oct 2023 22:14:57 +0200 Subject: [PATCH 1/2] Removed usage of deprecated getKeys in favor of keys() from phpredis --- README.md | 9 +++++++-- lib/Cake/Cache/Engine/RedisEngine.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8648d64d38..968dedf096 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ Here are steps I took to migrate my project through all versions to PHP 8.1, may ## Before using this fork ⚠️ -- Tests of CakePHP framework aren't refactored yet to support PHP 8. Main issue is old version of PHPUnit that is tightly coupled to framework's tests. Issue for fixing this situation is here: https://github.com/kamilwylegala/cakephp2-php8/issues/7 -- Due to lack of tests ☝️ - **you need to rely** on tests in your application after integrating with this fork. +- ~~Tests of CakePHP framework aren't refactored yet to support PHP 8. Main issue is old version of PHPUnit that is tightly coupled to framework's tests. Issue for fixing this situation is here: https://github.com/kamilwylegala/cakephp2-php8/issues/7~~ Framework tests are migrated to PHPUnit 9.*. Github actions are running tests on PHP 8.0, 8.1. +- ~~Due to lack of tests ☝️~~ - **you also need to rely** on tests in your application after integrating with this fork. - If after integration you spot any issues related to framework please let me know by creating an issue or pull request with fix. ## Installation @@ -55,6 +55,11 @@ It means that composer will look at `master` branch of repository configured und ## Changelog + +### 2023-10-19 + +- Removed usage of deprecated `redis->getKeys()` in favor of `redis->keys()`. + ### 2023-09-18 - Fix for `ShellDispatcher` where `null` was passed to `strpos` function. diff --git a/lib/Cake/Cache/Engine/RedisEngine.php b/lib/Cake/Cache/Engine/RedisEngine.php index 6dd6599442..405729227f 100644 --- a/lib/Cake/Cache/Engine/RedisEngine.php +++ b/lib/Cake/Cache/Engine/RedisEngine.php @@ -187,7 +187,7 @@ public function clear($check) { if ($check) { return true; } - $keys = $this->_Redis->getKeys($this->settings['prefix'] . '*'); + $keys = $this->_Redis->keys($this->settings['prefix'] . '*'); $this->_Redis->del($keys); return true; From faead93b330651af3ae76641c4d07098a7a48f49 Mon Sep 17 00:00:00 2001 From: Kamil Wylegala Date: Thu, 19 Oct 2023 23:20:21 +0200 Subject: [PATCH 2/2] Docker compose setup to run tests locally. --- README.md | 1 + docker-compose.yml | 54 ++++++++++++++++++++++++++ docker/mysql/1_initialize_database.sql | 7 ++++ docker/pgsql/1_initialize_database.sql | 4 ++ docker/web/Dockerfile | 25 ++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/mysql/1_initialize_database.sql create mode 100644 docker/pgsql/1_initialize_database.sql create mode 100644 docker/web/Dockerfile diff --git a/README.md b/README.md index 968dedf096..a18e455001 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ It means that composer will look at `master` branch of repository configured und ### 2023-10-19 - Removed usage of deprecated `redis->getKeys()` in favor of `redis->keys()`. +- Added docker-compose setup to run tests locally. ### 2023-09-18 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..dcfce7b276 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,54 @@ +services: + web: + build: ./docker/web + environment: + PHP_IDE_CONFIG: "serverName=localhost" + volumes: + - ./:/var/www/html:cached + working_dir: /var/www/html + ports: + - "8000:80" + depends_on: + - mysql + - pgsql + - memcached + - redis + mysql: + image: mysql:5.6 + platform: linux/amd64 + command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: cakephp_test + MYSQL_USER: cakephp_test + MYSQL_PASSWORD: secret + volumes: + - ./docker/mysql:/docker-entrypoint-initdb.d:cached + - mysql-data:/var/lib/mysql + ports: + - "3306:3306" + pgsql: + image: postgres:9.4 + platform: linux/amd64 + environment: + POSTGRES_DB: cakephp_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + volumes: + - ./docker/pgsql:/docker-entrypoint-initdb.d:cached + - pgsql-data:/var/lib/postgresql/data + ports: + - "5432:5432" + memcached: + image: memcached:latest + hostname: memcached + ports: + - "11211:11211" + redis: + image: "redis:latest" + hostname: redis + ports: + - "6379:6379" +volumes: + mysql-data: + pgsql-data: diff --git a/docker/mysql/1_initialize_database.sql b/docker/mysql/1_initialize_database.sql new file mode 100644 index 0000000000..7dc8de16aa --- /dev/null +++ b/docker/mysql/1_initialize_database.sql @@ -0,0 +1,7 @@ +CREATE DATABASE IF NOT EXISTS cakephp_test ; +GRANT ALL ON cakephp_test.* TO 'cakephp_test'@'%' ; +CREATE DATABASE IF NOT EXISTS cakephp_test2 ; +GRANT ALL ON cakephp_test2.* TO 'cakephp_test'@'%' ; +CREATE DATABASE IF NOT EXISTS cakephp_test3 ; +GRANT ALL ON cakephp_test3.* TO 'cakephp_test'@'%' ; +FLUSH PRIVILEGES ; diff --git a/docker/pgsql/1_initialize_database.sql b/docker/pgsql/1_initialize_database.sql new file mode 100644 index 0000000000..c415743707 --- /dev/null +++ b/docker/pgsql/1_initialize_database.sql @@ -0,0 +1,4 @@ +\c cakephp_test + +CREATE SCHEMA test2; +CREATE SCHEMA test3; diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile new file mode 100644 index 0000000000..d9c90b56e1 --- /dev/null +++ b/docker/web/Dockerfile @@ -0,0 +1,25 @@ +FROM php:8.2-apache + +RUN apt-get update && apt-get install -y --no-install-recommends \ + && apt-get install -y libpq-dev libzip-dev unzip openssl libmcrypt-dev libmemcached-dev locales \ + && rm -rf /var/lib/apt/lists/* + +RUN docker-php-ext-install pdo_mysql pdo_pgsql zip \ + && pecl install apcu redis memcached mcrypt xdebug \ + && docker-php-ext-enable redis memcached mcrypt \ + && docker-php-ext-enable xdebug \ + && echo "extension=apcu.so" >> /usr/local/etc/php/php.ini \ + && echo "apc.enable_cli = 1" >> /usr/local/etc/php/php.ini + +COPY --from=composer /usr/bin/composer /usr/local/bin/composer + +RUN sed -i '/de_DE /s/^# //g' /etc/locale.gen \ + && sed -i '/es_ES /s/^# //g' /etc/locale.gen \ + && locale-gen + +ENV APACHE_DOCUMENT_ROOT /var/www/html/app/webroot + +RUN a2enmod rewrite + +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf