diff --git a/backend/templates/wordpress-external-db.yaml b/backend/templates/wordpress-external-db.yaml index d8cbb2b1..ed14da6f 100644 --- a/backend/templates/wordpress-external-db.yaml +++ b/backend/templates/wordpress-external-db.yaml @@ -92,6 +92,10 @@ files: FROM wordpress:${VERSION} RUN php -r '$v=PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION; $min=["8.2"=>"8.2.35","8.3"=>"8.3.36"]; exit(isset($min[$v]) && version_compare(PHP_VERSION,$min[$v],">=") ? 0 : 1);' \ && docker-php-ext-install pdo_mysql + RUN pecl install redis \ + && docker-php-ext-enable redis \ + && rm -rf /tmp/pear \ + && php -r 'exit(extension_loaded("redis") ? 0 : 1);' RUN printf 'session.upload_progress.enabled=0\n' > /usr/local/etc/php/conf.d/zz-serverkit-security.ini \ && printf 'php_admin_flag session.upload_progress.enabled Off\n' > /etc/apache2/conf-available/serverkit-php-security.conf \ && a2enconf serverkit-php-security diff --git a/backend/templates/wordpress.yaml b/backend/templates/wordpress.yaml index b749f598..a887a08e 100644 --- a/backend/templates/wordpress.yaml +++ b/backend/templates/wordpress.yaml @@ -77,7 +77,7 @@ compose: restart: unless-stopped db: - image: mysql:8.0 + image: mysql:8.4 container_name: ${APP_NAME}-db restart: unless-stopped environment: @@ -98,6 +98,10 @@ files: FROM wordpress:${VERSION} RUN php -r '$v=PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION; $min=["8.2"=>"8.2.35","8.3"=>"8.3.36"]; exit(isset($min[$v]) && version_compare(PHP_VERSION,$min[$v],">=") ? 0 : 1);' \ && docker-php-ext-install pdo_mysql + RUN pecl install redis \ + && docker-php-ext-enable redis \ + && rm -rf /tmp/pear \ + && php -r 'exit(extension_loaded("redis") ? 0 : 1);' RUN printf 'session.upload_progress.enabled=0\n' > /usr/local/etc/php/conf.d/zz-serverkit-security.ini \ && printf 'php_admin_flag session.upload_progress.enabled Off\n' > /etc/apache2/conf-available/serverkit-php-security.conf \ && a2enconf serverkit-php-security diff --git a/backend/tests/test_php_security_templates.py b/backend/tests/test_php_security_templates.py index 09b93456..767062d1 100644 --- a/backend/tests/test_php_security_templates.py +++ b/backend/tests/test_php_security_templates.py @@ -21,3 +21,17 @@ def test_wordpress_build_files_do_not_become_container_mounts(tmp_path, name): assert 'FROM wordpress:7.1.3-php8.3-apache' in dockerfile assert '8.3.36' in dockerfile and 'pdo_mysql' in dockerfile assert 'php_admin_flag session.upload_progress.enabled Off' in dockerfile + # Issue #252: Object Cache Pro refuses to start without PhpRedis, and the + # upstream image does not ship it. Verified in the build, like pdo_mysql. + assert 'pecl install redis' in dockerfile and 'docker-php-ext-enable redis' in dockerfile + assert 'extension_loaded("redis")' in dockerfile + # A collapsed line continuation would still be one valid-looking string. + assert all(line.endswith('\\') or line.startswith((' && php', ' && docker-php-ext-install', + ' && a2enconf')) + for line in dockerfile.splitlines() if line.startswith(('RUN', ' &&'))) + + +def test_new_wordpress_sites_get_the_mysql_wordpress_recommends(): + # Issue #253: Site Health flags MySQL 8.0 as outdated; WordPress asks for 8.4+. + template = yaml.safe_load((Path(__file__).parents[1] / 'templates' / 'wordpress.yaml').read_text()) + assert template['compose']['services']['db']['image'] == 'mysql:8.4'