Skip to content

Commit

Permalink
compatibility with php 7.4 and 8.x (#4)
Browse files Browse the repository at this point in the history
* Correct deprecated methods in PHP7.4 (propelorm#1079)

* runtime/lib/query/Join.php
  implode() was used against the definition (wrong PHP documentation

* runtime/lib/query/ModelCriteria.php
  count() was used on non-countable variable (non-array)

* 7.4 and phpunit9 changes. Tests are passing

* Compatibility changes

* Added docker setup

* updated travis

* added correct path

* 7.4 final travis setup

* propelorm#1086: Code review suggestions applying

* remove dependency on docker mysql

* remove 5.6 and 7.2 from test matrix; add 8.0 and 8.1

* Upgraded PHP version and removed some deprecations

* Migrated phpunit.xml.dist

* Switched to PHP8.0 in Dockerfile

* Removed usage of ReflectionClass->getClass in favor of ReflectionClass->getType

* Changed order of arguments in ModelCriteriaTest.php and ModelCriteriaWithNamespaceTest.php

* Fixed signatures of PropelOnDemandCollection::asort and PropelOnDemandCollection::ksort

* Removed require_once from all the classes because we have autoloading via composer

* Rector automated upgrade to PHP8

* Fixed invalid handling of resource type for binded value in DebugPDOStatement.php

* Fixed invalid way of checking if method exists in delegated class via is_callable. Switched to method_exists

* Replaced order of params because of failed tests

* [STYLE]: Added simplified usage because of version support dropping

* Fix use of abs() with string on PHP8.0

Can happen when using Yaml's multiline syntax

* specify minimum version of phing for php8

* drop php 7.3 from test matrix

* update to ubuntu-20.04

* fork propel/propel1 for versions >=1.8

Co-authored-by: Michal Drozd <[email protected]>
Co-authored-by: Luke Adamczewski <[email protected]>
Co-authored-by: Łukasz Adamczewski <[email protected]>
Co-authored-by: Jeffrey Wong <[email protected]>
Co-authored-by: Luke Adamczewski <[email protected]>
Co-authored-by: Paulo Magalhaes <[email protected]>
  • Loading branch information
7 people committed Dec 20, 2022
1 parent 7f42869 commit 73148f8
Show file tree
Hide file tree
Showing 310 changed files with 618 additions and 687 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ jobs:
env:
DB: mysql
DB_USER: root
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
php:
- '5.6'
- '7.2'
- '7.3'
- '7.4'
# - '8.0'
# - '8.1'
- '8.0'
- '8.1'
composer:
- ''
- '--prefer-lowest'
Expand Down
34 changes: 4 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
language: php
dist: trusty

branches:
only:
- 1.6
- master
- gh-pages
- php7.4

php:
- 5.4
- 5.5
- hhvm
services: docker

env:
- DB=mysql DB_USER=root

before_script:
# MySQL
- sh -c "if [ '$DB' = 'mysql' ]; then 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;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'; fi"

# Composer
- wget http://getcomposer.org/composer.phar
- php composer.phar install --prefer-source

- ./test/reset_tests.sh

script: vendor/bin/phpunit

matrix:
include:
- php: 5.3
dist: precise
allow_failures:
- php: hhvm
script:
bash docker/run.sh
32 changes: 16 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "propel/propel1",
"name": "dayspring-tech/propel1",
"description": "Propel is an open-source Object-Relational Mapping (ORM) for PHP5.",
"keywords": ["orm", "active record", "mapping", "database", "persistence"],
"homepage": "http://www.propelorm.org/",
Expand All @@ -14,23 +14,23 @@
},
"include-path": ["runtime/lib", "generator/lib"],
"require": {
"php": ">=5.2.4",
"phing/phing": "~2.4"
"php": "^8.0|^7.4",
"phing/phing": "^2.17",
"ext-pdo": "*"
},
"require-dev": {
"pear-pear.php.net/PEAR_PackageFileManager2": "@stable",
"phpunit/phpunit": "~4.0||~5.0"
"phpunit/phpunit": "^9.0.0",
"phpcompatibility/php-compatibility": "^9.3",
"squizlabs/php_codesniffer": "^3.5",
"ext-simplexml": "*",
"ext-dom": "*"
},
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
"replace": {
"propel/propel1": "^1.8"
},
"repositories": [
{
"type": "pear",
"url": "https://pear.php.net"
}
],
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"]
"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"
}
}
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM thecodingmachine/php:8.0-v4-cli
USER root
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales

RUN 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

USER docker
ENV LANG en_US.UTF-8

29 changes: 29 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3'
services:
php:
build:
context: .
dockerfile: Dockerfile
working_dir: /usr/src/app
command: phpunit
volumes:
- ../:/usr/src/app
environment:
- PHP_EXTENSIONS=intl pdo_sqlite sqlite3 xdebug
- STARTUP_COMMAND_1=composer install
- STARTUP_COMMAND_2=bash test/reset_tests.sh
- PHP_IDE_CONFIG="serverName=propel"
- XDEBUG_MODE=debug
- XDEBUG_SESSION=1

db:
image: percona
command: >
mysqld
--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'
4 changes: 4 additions & 0 deletions docker/reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

mysql -u root -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 -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'
7 changes: 7 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
cd docker
docker-compose up -d db
sleep 20
docker-compose exec -T db bash < reset.sh
docker-compose build
docker-compose run php
2 changes: 1 addition & 1 deletion generator/lib/behavior/DelegateBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function objectCall($builder)
$relationName = $builder->getFKPhpNameAffix($fk);
}
$script .= "
if (is_callable(array('$ARFQCN', \$name))) {
if (method_exists('$ARFQCN', \$name)) {
if (!\$delegate = \$this->get$relationName()) {
\$delegate = new $ARClassName();
\$this->set$relationName(\$delegate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @license MIT License
*/

require_once 'AggregateColumnRelationBehavior.php';

/**
* Keeps an aggregate column updated with related table
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
* @license MIT License
*/

require_once 'AggregateColumnRelationBehavior.php';

/**
* Keeps an aggregate column updated with related table
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Computes the value of the aggregate column <?php echo $column->getName() ?>
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Updates the aggregate column <?php echo $column->getName() ?>
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Update the aggregate column in the related <?php echo $relationName ?> object
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Finds the related <?php echo $foreignTable->getPhpName() ?> objects and keep them for later
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

protected function updateRelated<?php echo $relationName ?>s($con)
{
foreach ($this-><?php echo $variableName ?>s as $<?php echo $variableName ?>) {
Expand Down
3 changes: 1 addition & 2 deletions generator/lib/behavior/archivable/ArchivableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/ArchivableBehaviorObjectBuilderModifier.php';
require_once dirname(__FILE__) . '/ArchivableBehaviorQueryBuilderModifier.php';


/**
* Keeps tracks of an ActiveRecord object, even after deletion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Removes the object from the database without archiving it.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Get an archived version of the current object.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Populates the the current object based on a $archiveTablePhpName archive object.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Revert the the current object to the state it had when it was last archived.
* The object must be saved afterwards if the changes must persist.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Persists the object to the database without archiving it.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Copy the data of the objects satisfying the query into <?php echo $archiveTablePhpName ?> archive objects.
* The archived objects are then saved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Delete records matching the current query without archiving them.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Enable/disable auto-archiving on delete for the next query.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Enable/disable auto-archiving on update for the next query.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Delete records matching the current query without archiving them.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once 'ConcreteInheritanceParentBehavior.php';

/**
* Makes a model inherit another one. The model with this behavior gets a copy
Expand Down
5 changes: 2 additions & 3 deletions generator/lib/behavior/i18n/I18nBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/I18nBehaviorObjectBuilderModifier.php';
require_once dirname(__FILE__) . '/I18nBehaviorQueryBuilderModifier.php';
require_once dirname(__FILE__) . '/I18nBehaviorPeerBuilderModifier.php';



/**
* Allows translation of text columns through transparent one-to-many relationship
Expand Down
1 change: 0 additions & 1 deletion generator/lib/behavior/i18n/templates/objectAttributes.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Current locale
* @var string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Returns the current translation
*
Expand Down
1 change: 0 additions & 1 deletion generator/lib/behavior/i18n/templates/objectGetLocale.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Gets the locale for translations
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Gets the locale for translations.
* Alias for getLocale(), for BC purpose.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Returns the current translation for a given locale
*
Expand Down
1 change: 0 additions & 1 deletion generator/lib/behavior/i18n/templates/objectPostDelete.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// emulate delete cascade
<?php echo $i18nQueryName ?>::create()
->filterBy<?php echo $objectClassname ?>($this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Remove the translation for a given locale
*
Expand Down
1 change: 0 additions & 1 deletion generator/lib/behavior/i18n/templates/objectSetLocale.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Sets the locale for translations
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Sets the locale for translations.
* Alias for setLocale(), for BC purpose.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Sets the translation for a given locale
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<?php echo $comment ?>
<?php echo $functionStatement ?>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<?php echo $comment ?>
<?php echo $functionStatement ?>
$this->getCurrentTranslation()->set<?php echo $columnPhpName ?>(<?php echo $params ?>);
Expand Down
1 change: 0 additions & 1 deletion generator/lib/behavior/i18n/templates/queryJoinI18n.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Adds a JOIN clause to the query using the i18n relation
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Adds a JOIN clause to the query and hydrates the related I18n object.
* Shortcut for $c->joinI18n($locale)->with()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Use the I18n relation query object
*
Expand Down
5 changes: 2 additions & 3 deletions generator/lib/behavior/nestedset/NestedSetBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/NestedSetBehaviorObjectBuilderModifier.php';
require_once dirname(__FILE__) . '/NestedSetBehaviorQueryBuilderModifier.php';
require_once dirname(__FILE__) . '/NestedSetBehaviorPeerBuilderModifier.php';



/**
* Behavior to adds nested set tree structure columns and abilities
Expand Down
7 changes: 3 additions & 4 deletions generator/lib/behavior/sortable/SortableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/SortableBehaviorObjectBuilderModifier.php';
require_once dirname(__FILE__) . '/SortableBehaviorQueryBuilderModifier.php';
require_once dirname(__FILE__) . '/SortableBehaviorPeerBuilderModifier.php';
require_once dirname(__FILE__) . '/SortableRelationBehavior.php';




/**
* Gives a model class the ability to be ordered
Expand Down
Loading

0 comments on commit 73148f8

Please sign in to comment.