Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f93c590
kill it - ErrorLog class not found
DavidGoodwin May 29, 2023
65c17c4
use psalm phar, add missing pear package ( pear/pear_packagefilemanag…
DavidGoodwin May 29, 2023
c5b6474
php8.1 things from psalm
DavidGoodwin May 29, 2023
a053f40
change tests to point to the docker mysql container
DavidGoodwin May 29, 2023
bbc2ce8
update docker image, use php8.1
DavidGoodwin May 29, 2023
5c8c95f
initial github actions support
DavidGoodwin May 29, 2023
30e1015
configure psalm to use baseline
DavidGoodwin May 29, 2023
91822a1
remove mysql client
DavidGoodwin May 29, 2023
dcfc7a7
remove docker users
DavidGoodwin May 29, 2023
33850d7
try removing -t ... to stop "the input device is not a TTY" when runn…
DavidGoodwin May 29, 2023
956d713
hmm
DavidGoodwin May 29, 2023
a8f3bc4
stop installing apache in docker container
DavidGoodwin May 30, 2023
2f423cc
make class name match filename
DavidGoodwin May 31, 2023
8b0f152
make class name match filename
DavidGoodwin May 31, 2023
778246b
make class names match filenames
DavidGoodwin May 31, 2023
c7fad2f
cannot do str_replace on a resource, so skip this if it is a resource
DavidGoodwin May 31, 2023
9cfacc2
fix db for docker test
DavidGoodwin May 31, 2023
a7967fb
fix db for docker test
DavidGoodwin May 31, 2023
c4d9f26
unnecessary assertions
DavidGoodwin May 31, 2023
f25d50a
remove dead code
DavidGoodwin May 31, 2023
cc2f5b9
simplify
DavidGoodwin May 31, 2023
7f9931f
simplify
DavidGoodwin May 31, 2023
386f3e0
silence docker pull a bit
DavidGoodwin May 31, 2023
617abc0
docker - try waiting?
DavidGoodwin Jun 1, 2023
c1f8aa2
stop docker thinking the php container has died
DavidGoodwin Jun 1, 2023
5a177e9
run the test setup manually
DavidGoodwin Jun 1, 2023
a37a07a
disable the Delegate behaviour test - i do not use the behaviour i do…
DavidGoodwin Jun 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/github.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
push:

jobs:
build:
runs-on: ubuntu-22.04

strategy:
fail-fast: true
matrix:
php-versions: ['8.1']

steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer
extensions: curl, mysql, mbstring
env:
runner: self-hosted

- 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 }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- run: composer install -n
- run: composer validate
- run: composer lint

- name: start up docker
run: docker compose up -d --wait --quiet-pull

- name: initialise database and generate propel files etc
run: docker compose run php sh -c "test/reset_tests.sh"

- name: Run MySQL test suite
run: docker compose run php sh -c "vendor/bin/phpunit -c phpunit.xml.dist --debug test/testsuite"

- name: Tidy up
if: always()
run: docker compose down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@
},
"include-path": ["runtime/lib", "generator/lib"],
"require": {
"php": "^7.4|^8.0",
"php": "^8.1",
"phing/phing": "^2.17",
"pear/pear-core-minimal": "*",
"pear/log": "^1.13"
"pear/log": "^1.13",
"pear/pear_packagefilemanager": "dev-trunk"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpcompatibility/php-compatibility": "^9.3",
"squizlabs/php_codesniffer": "^3.5",
"ext-simplexml" : "*",
"ext-dom" : "*",
"vimeo/psalm": "^4.0"
"psalm/phar": "^4.0",
"php-parallel-lint/php-parallel-lint": "^1.3"
},
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"],
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
"lint": "@php vendor/bin/parallel-lint generator runtime test",
"psalm": "@php vendor/bin/psalm.phar --output-format=github --use-baseline=psalm.baseline --threads=$(nproc --all)"
}
}
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: '3'

services:
php:
build:
context: .
dockerfile: docker/Dockerfile
working_dir: /usr/src/app
tty: true
volumes:
- .:/usr/src/app
depends_on:
mysql:
condition: service_healthy
postgresql:
condition: service_healthy

mysql:
image: mysql:5.7
command: >
--sql-mode="NO_ENGINE_SUBSTITUTION"
--character-set-server="utf8"
--collation-server="utf8_unicode_ci"
--default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: "test"
healthcheck:
test: ["CMD-SHELL", "exit | mysql -h localhost -P 3306 -u root -e 'select 1'" ]
interval: 5s
timeout: 20s
retries: 30

postgresql:
image: postgres:14-bullseye
environment:
POSTGRES_PASSWORD: "password"
restart: always
healthcheck:
test: ["CMD-SHELL", "su - postgres -c pg_isready"]
interval: 10s
timeout: 5s
retries: 5

15 changes: 10 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
FROM debian:bullseye
USER root
RUN apt-get -q update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y locales php7.4 php7.4-sqlite php7.4-pgsql php7.4-pdo php7.4-mysql php7.4-cli php7.4-intl php7.4-xml default-mysql-client curl php7.4-curl && \

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get -q update && apt-get -qy install eatmydata curl && curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg && \
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ bullseye main" > /etc/apt/sources.list.d/php.list && \
apt-get -q update && \
eatmydata -- apt-get -qy install --no-install-recommends locales php8.1-sqlite php8.1-pgsql php8.1-pdo php8.1-mysql php8.1-cli php8.1-intl php8.1-xml default-mysql-client curl php8.1-curl php8.1-mbstring && \
apt-get clean && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
RUN adduser docker

USER docker
RUN curl -o /usr/local/bin/composer https://getcomposer.org/download/2.5.1/composer.phar && chmod 755 /usr/local/bin/composer

ENV LANG en_US.UTF-8

24 changes: 0 additions & 24 deletions docker/docker-compose.yml

This file was deleted.

4 changes: 2 additions & 2 deletions docker/reset.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

mysql -u root -h db -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'
mysql -u root -h db -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'
mysql -u root -h mysql -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'
mysql -u root -h mysql -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'
11 changes: 4 additions & 7 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#!/usr/bin/env bash

set -x

id
pwd
cd $(dirname $0)

/bin/bash docker/reset.sh

curl -o composer https://getcomposer.org/download/2.5.1/composer.phar
chmod 755 composer
env

./composer install -n
bash test/reset_tests.sh
bash -x ../test/reset-tests.sh
30 changes: 30 additions & 0 deletions psalm.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="runtime/lib/adapter/DBOracle.php">
<NullReference occurrences="1">
<code>$params</code>
</NullReference>
</file>
<file src="runtime/lib/adapter/DBSQLSRV.php">
<UndefinedConstant occurrences="5">
<code>PDO::SQLSRV_ATTR_ENCODING</code>
<code>PDO::SQLSRV_ATTR_ENCODING</code>
<code>PDO::SQLSRV_ENCODING_BINARY</code>
<code>PDO::SQLSRV_ENCODING_SYSTEM</code>
<code>PDO::SQLSRV_ENCODING_UTF8</code>
</UndefinedConstant>
</file>
<file src="runtime/lib/om/NodeObject.php">
<UndefinedDocblockClass occurrences="4">
<code>Node</code>
<code>Node</code>
<code>Node</code>
<code>Node[]</code>
</UndefinedDocblockClass>
</file>
<file src="runtime/lib/util/BasePeer.php">
<EmptyArrayAccess occurrences="1">
<code>$joinClause</code>
</EmptyArrayAccess>
</file>
</files>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
errorBaseline="psalm.baseline"
>
<projectFiles>
<directory name="runtime/" />
Expand Down
4 changes: 2 additions & 2 deletions runtime/lib/adapter/DBAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ public function cleanupSQL(&$sql, array &$params, Criteria $values, DatabaseMap
/**
* Modifies the passed-in SQL to add LIMIT and/or OFFSET.
*
* @param string $sql
* @param string $sql
* @param integer $offset
* @param integer $limit
*/
abstract public function applyLimit(&$sql, $offset, $limit);
abstract public function applyLimit(string &$sql, $offset, $limit);

/**
* Gets the SQL string that this adapter uses for getting a random number.
Expand Down
2 changes: 1 addition & 1 deletion runtime/lib/adapter/DBOracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function strLength($s)
* @param integer $limit
* @param null|Criteria $criteria
*/
public function applyLimit(&$sql, $offset, $limit, $criteria = null)
public function applyLimit(string &$sql, $offset, $limit, $criteria = null)
{
if (BasePeer::needsSelectAliases($criteria)) {
$crit = clone $criteria;
Expand Down
8 changes: 4 additions & 4 deletions runtime/lib/adapter/MSSQL/MssqlPropelPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MssqlPropelPDO extends PropelPDO
*
* @return bool
*/
public function beginTransaction()
public function beginTransaction():bool
{
$return = true;
$opcount = $this->getNestedTransactionCount();
Expand All @@ -49,7 +49,7 @@ public function beginTransaction()
*
* @throws PropelException
*/
public function commit()
public function commit():bool
{
$return = true;
$opcount = $this->getNestedTransactionCount();
Expand All @@ -76,9 +76,9 @@ public function commit()
* It is necessary to override the abstract PDO transaction functions here, as
* the PDO driver for MSSQL does not support transactions.
*
* @return integer
* @return bool
*/
public function rollBack()
public function rollBack():bool
{
$return = true;
$opcount = $this->getNestedTransactionCount();
Expand Down
7 changes: 6 additions & 1 deletion runtime/lib/connection/DebugPDOStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public function getExecutedQueryString(array $values = array())

// trimming extra quotes, making sure value is properly quoted afterwards
$boundValue = $boundValues[$pos];
if (is_resource($boundValue)) {
// do nothing.... can't str_replace with a resource.
continue;
}

if (is_string($boundValue)) { // quoting only needed for string values
$boundValue = trim($boundValue, "'");
$boundValue = $this->pdo->quote($boundValue);
Expand All @@ -101,7 +106,7 @@ public function execute($input_parameters = null)
$debug = $this->pdo->getDebugSnapshot();
$return = parent::execute($input_parameters);

$sql = $this->getExecutedQueryString($input_parameters?$input_parameters:array());
$sql = $this->getExecutedQueryString($input_parameters ? $input_parameters : array());
$this->pdo->log($sql, null, __METHOD__, $debug);
$this->pdo->setLastExecutedQuery($sql);
$this->pdo->incrementQueryCount();
Expand Down
Loading