Skip to content

Commit

Permalink
Merge branch 'master' into fix/remove-depreciation-messages
Browse files Browse the repository at this point in the history
  • Loading branch information
krytenuk authored Aug 10, 2023
2 parents 50c425e + de90587 commit e5a1915
Show file tree
Hide file tree
Showing 1,301 changed files with 4,648 additions and 3,907 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/lint.yml

This file was deleted.

105 changes: 94 additions & 11 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHPUnit-9
name: PHPUnit

on: [push, pull_request]

Expand All @@ -9,7 +9,6 @@ jobs:
runs-on: ubuntu-22.04

env:
PHP_EXTENSIONS: none, posix, curl, dom, json, libxml, mbstring, openssl, tokenizer, xml, xmlwriter, ctype, iconv, simplexml, pdo_sqlite, pdo_mysql, fileinfo, json, zip, sqlite, soap, bcmath, mcrypt, igbinary, gd, bz2, lzf, rar, memcached, memcache
PHP_INI_VALUES: memory_limit=-1, assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On

TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED: true
Expand All @@ -33,7 +32,20 @@ jobs:
TESTS_ZEND_CACHE_LIBMEMCACHED_ENABLED: true
TESTS_ZEND_CACHE_LIBMEMCACHED_HOST: 127.0.0.1
TESTS_ZEND_CACHE_LIBMEMCACHED_PORT: 11211

# https://hub.docker.com/r/bitnami/openldap
LDAP_ROOT: "dc=example,dc=com"
LDAP_ALLOW_ANON_BINDING: false
LDAP_SKIP_DEFAULT_TREE: "yes"
LDAP_ADMIN_USERNAME: "admin"
LDAP_ADMIN_PASSWORD: "insecure"
LDAP_CONFIG_ADMIN_USERNAME: "admin"
LDAP_CONFIG_ADMIN_PASSWORD: "configpassword"
TESTS_ZEND_LDAP_ONLINE_ENABLED: true
TESTS_ZEND_AUTH_ADAPTER_LDAP_ONLINE_ENABLED: true

LOCALES: "fr_FR@euro fr_FR fr_BE.UTF-8 de en_US"
OPENSSL_CONF: "./tests/openssl.conf"
services:
memcache:
image: memcached:1.6.17-alpine
Expand All @@ -48,7 +60,7 @@ jobs:
MYSQL_DATABASE: ${{ env.TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE }}
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
ports:
- 3306:3306
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
Expand All @@ -69,17 +81,46 @@ jobs:
--health-timeout 5s
--health-retries 5
openldap:
image: bitnami/openldap:2.5
ports:
- 1389:1389
env:
LDAP_ROOT: ${{ env.LDAP_ROOT }}
LDAP_ALLOW_ANON_BINDING: ${{ env.LDAP_ALLOW_ANON_BINDING }}
LDAP_SKIP_DEFAULT_TREE: ${{ env.LDAP_SKIP_DEFAULT_TREE }}
LDAP_ADMIN_USERNAME: ${{ env.LDAP_ADMIN_USERNAME }}
LDAP_ADMIN_PASSWORD: ${{ env.LDAP_ADMIN_PASSWORD }}
LDAP_CONFIG_ADMIN_ENABLED: "yes"
LDAP_CONFIG_ADMIN_USERNAME: ${{ env.LDAP_CONFIG_ADMIN_USERNAME }}
LDAP_CONFIG_ADMIN_PASSWORD: ${{ env.LDAP_CONFIG_ADMIN_PASSWORD }}

strategy:
fail-fast: false
matrix:
php-version:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
experimental:
- false
include:
#bare for PHP >=7.2
- php-extensions-bare: "none, iconv, json, libxml, xml, dom, simplexml, xmlwriter, tokenizer, mbstring"
#full for PHP <= 8.0
- php-extensions-full: "none, iconv, json, libxml, xml, dom, simplexml, xmlwriter, tokenizer, mbstring, ctype, openssl, curl, gd, posix, pdo_sqlite, pdo_mysql, fileinfo, zip, sqlite, soap, bcmath, igbinary, bz2, lzf, memcached, memcache, ldap, sqlite, mcrypt, rar"
- php-version: "7.1"
php-extensions-bare: "none, iconv, json, libxml, xml, dom, simplexml, xmlwriter, tokenizer"
- php-version: "8.1"
php-extensions-full: "none, iconv, json, libxml, xml, dom, simplexml, xmlwriter, tokenizer, mbstring, ctype, openssl, curl, gd, posix, pdo_sqlite, pdo_mysql, fileinfo, zip, sqlite, soap, bcmath, igbinary, bz2, lzf, memcached, memcache, ldap, sqlite, mcrypt"
- php-version: "8.2"
php-extensions-full: "none, iconv, json, libxml, xml, dom, simplexml, xmlwriter, tokenizer, mbstring, ctype, openssl, curl, gd, posix, pdo_sqlite, pdo_mysql, fileinfo, zip, sqlite, soap, bcmath, igbinary, bz2, lzf, memcached, memcache, ldap, sqlite, mcrypt"
- php-version: "8.3"
php-extensions-full: "none, iconv, json, libxml, xml, dom, simplexml, xmlwriter, tokenizer, mbstring, ctype, openssl, curl, gd, posix, pdo_sqlite, pdo_mysql, fileinfo, zip, sqlite, soap, bcmath, igbinary, bz2, lzf, memcached, memcache, ldap, sqlite"
experimental: true

steps:
Expand All @@ -92,18 +133,60 @@ jobs:
echo "All languages..."
locale -a
- name: Provider config base on env for intergrate test
- name: Provider config base on env for integrate test
run: cp tests/TestConfiguration.env.php tests/TestConfiguration.php



- name: Install PHP with minimal extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: cs2pr
extensions: ${{ matrix.php-extensions-bare }}
ini-values: ${{ env.PHP_INI_VALUES }}
env:
# https://github.com/shivammathur/setup-php/issues/407#issuecomment-773675741
fail-fast: true

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Lint PHP source files
run: |
bin/parallel-lint --exclude vendor --exclude tests/Zend/Loader/_files/ParseError.php . --checkstyle | cs2pr
- name: "Run tests on PHP ${{ matrix.php-version }} (Experimental: ${{ matrix.experimental }}) with minimal extensions"
run: |
bin/phpunit -c tests/phpunit.xml
continue-on-error: ${{ matrix.experimental }}

- name: Setup LDAP
run: |
sudo apt-get install -y libnss-ldap libpam-ldap ldap-utils
tests/resources/openldap/docker-entrypoint-initdb.d/init.sh
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: phpunit:9
extensions: memcached, memcache
tools: cs2pr
extensions: ${{ matrix.php-extensions-full }}
ini-values: ${{ env.PHP_INI_VALUES }}
env:
# https://github.com/shivammathur/setup-php/issues/407#issuecomment-773675741
fail-fast: true

- name: "Run tests on PHP ${{ matrix.php-version }} (Experimental: ${{ matrix.experimental }})"
run: phpunit -c tests/phpunit.xml
continue-on-error: ${{ matrix.experimental }}
- name: "Run tests on PHP ${{ matrix.php-version }} (Experimental: ${{ matrix.experimental }}) with extensions"
run: |
bin/phpunit -c tests/phpunit.xml
continue-on-error: ${{ matrix.experimental }}
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"require": {
"php": ">=7.1",
"symfony/polyfill-php81": "^1.24",
"symfony/polyfill-ctype": "^1.27",
"symfony/polyfill-mbstring": "^1.26"
},
"suggest": {
Expand All @@ -33,9 +34,10 @@
}
},
"require-dev": {
"phpunit/phpunit": "^9",
"phpunit/phpunit": "^7|^8|^9",
"php-parallel-lint/php-parallel-lint": "^1.3",
"rector/rector": "^0.14.8"
"rector/rector": "^0.12.19",
"yoast/phpunit-polyfills": "2.0"
},
"archive": {
"exclude": ["/demos", "/documentation", "/tests"]
Expand Down
8 changes: 3 additions & 5 deletions library/Zend/Cache/Backend/Apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function test($id)
*/
public function save($data, $id, $tags = [], $specificLifetime = false)
{
$lifetime = $this->getLifetime($specificLifetime);
$lifetime = $this->getLifetime($specificLifetime) ?? 0;
$result = apcu_store($id, [$data, time(), $lifetime], $lifetime);
if (count($tags) > 0) {
$this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_APC_BACKEND);
Expand Down Expand Up @@ -146,8 +146,7 @@ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = [])
{
switch ($mode) {
case Zend_Cache::CLEANING_MODE_ALL:
return apcu_clear_cache('user');
break;
return apcu_clear_cache();
case Zend_Cache::CLEANING_MODE_OLD:
$this->_log("Zend_Cache_Backend_Apc::clean() : CLEANING_MODE_OLD is unsupported by the Apc backend");
break;
Expand All @@ -158,7 +157,6 @@ public function clean($mode = Zend_Cache::CLEANING_MODE_ALL, $tags = [])
break;
default:
Zend_Cache::throwException('Invalid mode for clean() method');
break;
}
}

Expand Down Expand Up @@ -259,7 +257,7 @@ public function getIdsMatchingAnyTags($tags = [])
public function getIds()
{
$ids = [];
$iterator = new APCIterator('user', null, APC_ITER_KEY);
$iterator = new APCUIterator(null, APC_ITER_KEY);
foreach ($iterator as $item) {
$ids[] = $item['key'];
}
Expand Down
10 changes: 10 additions & 0 deletions library/Zend/Controller/Request/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ public function setQuery($spec, $value = null)
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed Returns null if key does not exist
*
* @phpstan-return ($key is null ? array<string, mixed> : mixed)
*/
public function getQuery($key = null, $default = null)
{
Expand Down Expand Up @@ -313,6 +315,8 @@ public function setPost($spec, $value = null)
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed Returns null if key does not exist
*
* @phpstan-return ($key is null ? array<string, mixed> : mixed)
*/
public function getPost($key = null, $default = null)
{
Expand All @@ -332,6 +336,8 @@ public function getPost($key = null, $default = null)
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed Returns null if key does not exist
*
* @phpstan-return ($key is null ? array<string, mixed> : mixed)
*/
public function getCookie($key = null, $default = null)
{
Expand All @@ -350,6 +356,8 @@ public function getCookie($key = null, $default = null)
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed Returns null if key does not exist
*
* @phpstan-return ($key is null ? array<string, mixed> : mixed)
*/
public function getServer($key = null, $default = null)
{
Expand All @@ -368,6 +376,8 @@ public function getServer($key = null, $default = null)
* @param string $key
* @param mixed $default Default value to use if key not found
* @return mixed Returns null if key does not exist
*
* @phpstan-return ($key is null ? array<string, mixed> : mixed)
*/
public function getEnv($key = null, $default = null)
{
Expand Down
4 changes: 3 additions & 1 deletion library/Zend/Controller/Router/Route/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ public function assemble($data = [], $reset = false, $encode = true, $partial =
$key = ($encode) ? urlencode((string) $key) : $key;
if (is_array($value)) {
foreach ($value as $arrayValue) {
$arrayValue = ($encode) ? urlencode((string) $arrayValue) : $arrayValue;

$arrayValue = ($encode) ? urlencode((string) $arrayValue) : $arrayValue;

$url .= self::URI_DELIMITER . $key;
$url .= self::URI_DELIMITER . $arrayValue;
}
Expand Down
12 changes: 11 additions & 1 deletion library/Zend/Db/Adapter/Pdo/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,17 @@ protected function _connect()
* @see Zend_Db_Adapter_Exception
*/
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);

$message = $e->getMessage();
if ($e->getPrevious() !== null && preg_match('~^SQLSTATE\[HY000\] \[\d{1,4}\]\s$~', $message)) {
// See https://bugs.php.net/bug.php?id=76604
$message .= $e->getPrevious()->getMessage();
}

/**
* @see Zend_Db_Adapter_Exception
*/
throw new Zend_Db_Adapter_Exception($message, $e->getCode(), $e);
}

}
Expand Down
8 changes: 8 additions & 0 deletions library/Zend/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ protected function _connect()
$this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
}

if (PHP_VERSION_ID >= 80100) {
// ensure $config['driver_options'] is an array
$this->_config['driver_options'] = $this->_config['driver_options'] ?? [];
if (!isset($this->_config['driver_options'][PDO::ATTR_STRINGIFY_FETCHES])) {
$this->_config['driver_options'][PDO::ATTR_STRINGIFY_FETCHES] = true;
}
}

parent::_connect();
}

Expand Down
8 changes: 8 additions & 0 deletions library/Zend/Db/Adapter/Pdo/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ public function __construct(array $config = [])
$this->_config['username'] = null;
$this->_config['password'] = null;

if (PHP_VERSION_ID >= 80100) {
// ensure $config['driver_options'] is an array
$config['driver_options'] = $config['driver_options'] ?? [];
if (!isset($config['driver_options'][PDO::ATTR_STRINGIFY_FETCHES])) {
$config['driver_options'][PDO::ATTR_STRINGIFY_FETCHES] = true;
}
}

return parent::__construct($config);
}

Expand Down
Loading

0 comments on commit e5a1915

Please sign in to comment.