Skip to content

Commit

Permalink
compatibility with php 7.4 and 8.x (propelorm#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 authored and DanielFortuyn committed Feb 10, 2023
1 parent 678736a commit d24a5c2
Show file tree
Hide file tree
Showing 149 changed files with 176 additions and 272 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
24 changes: 19 additions & 5 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,6 +14,7 @@
},
"include-path": ["runtime/lib", "generator/lib"],
"require": {
<<<<<<< HEAD
"php": "^7.1",
"phing/phing": "~2.4"

Expand All @@ -23,18 +24,31 @@
"phpunit/phpunit": "^9.0.0",
"phpcompatibility/php-compatibility": "^9.3",
"squizlabs/php_codesniffer": "^3.5"
=======
"php": "^8.0|^7.4",
"phing/phing": "^2.17",
"ext-pdo": "*"
},
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
"require-dev": {
"phpunit/phpunit": "^9.0.0",
"phpcompatibility/php-compatibility": "^9.3",
"squizlabs/php_codesniffer": "^3.5",
"ext-simplexml": "*",
"ext-dom": "*"
>>>>>>> 73148f83 (compatibility with php 7.4 and 8.x (#4))
},
"replace": {
"propel/propel1": "^1.8"
},
<<<<<<< HEAD
"repositories": [
{
"type": "pear",
"url": "https://pear.php.net"
}
],
=======
>>>>>>> 73148f83 (compatibility with php 7.4 and 8.x (#4))
"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",
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM thecodingmachine/php:7.4-v3-cli
FROM thecodingmachine/php:8.0-v4-cli
USER root
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales

Expand Down
9 changes: 9 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ services:
volumes:
- ../:/usr/src/app
environment:
<<<<<<< HEAD
- PHP_EXTENSIONS=intl pdo_sqlite sqlite3
- STARTUP_COMMAND_1=composer install
- STARTUP_COMMAND_2=bash test/reset_tests.sh
=======
- 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
>>>>>>> 73148f83 (compatibility with php 7.4 and 8.x (#4))

db:
image: percona
Expand Down
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
5 changes: 2 additions & 3 deletions generator/lib/behavior/versionable/VersionableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/VersionableBehaviorObjectBuilderModifier.php';
require_once dirname(__FILE__) . '/VersionableBehaviorQueryBuilderModifier.php';
require_once dirname(__FILE__) . '/VersionableBehaviorPeerBuilderModifier.php';



/**
* Keeps tracks of all the modifications in an ActiveRecord object
Expand Down
1 change: 0 additions & 1 deletion generator/lib/builder/om/ExtensionQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/OMBuilder.php';

/**
* Generates the empty PHP5 stub class for object query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/OMBuilder.php';

/**
* Generates the empty PHP5 stub query class for use with single table inheritance.
Expand Down
1 change: 0 additions & 1 deletion generator/lib/builder/om/OMBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/../DataModelBuilder.php';

/**
* Baseclass for OM-building classes.
Expand Down
1 change: 0 additions & 1 deletion generator/lib/builder/om/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/OMBuilder.php';

/**
* Base class for Peer-building classes.
Expand Down
1 change: 0 additions & 1 deletion generator/lib/builder/om/PHP5ExtensionNodeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/ObjectBuilder.php';

/**
* Generates the empty PHP5 stub node object class for user object model (OM).
Expand Down
1 change: 0 additions & 1 deletion generator/lib/builder/om/PHP5ExtensionNodePeerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/PeerBuilder.php';

/**
* Generates the empty PHP5 stub node peer class for user object model (OM).
Expand Down
1 change: 0 additions & 1 deletion generator/lib/builder/om/PHP5ExtensionObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @license MIT License
*/

require_once dirname(__FILE__) . '/ObjectBuilder.php';

/**
* Generates the empty PHP5 stub object class for user object model (OM).
Expand Down
Loading

0 comments on commit d24a5c2

Please sign in to comment.