Skip to content

Commit 651681f

Browse files
akhumphreyalquercithePanzxNatekTybaze
committed
NTO-180 merged upstream changes (#6)
* Fix tests to be able to finish it without a fatal error Execute record generator related test first * Fix tests for relationship fetch order when the order is not explicitly set on the query * Fix PHP 7 compatibility about deep isset() on class that implement ArrayAccess Fix comments for record filter * Mark as known bug, integer validation with numbers greater than PHP_INT_MAX * Fix test for export to XML * Fix PHP 7.4 compatibility * Add zlib required PHP extension on composer configuration * Fix code structure about always close connections after each test Co-authored-by: Emanuele Panzeri <thepanz@gmail.com> * Add consistent local environment for testing with docker and docker-compose (FriendsOfSymfony1#86) Related to FriendsOfSymfony1/symfony1#261 Co-authored-by: Emanuele Panzeri <thepanz@gmail.com> * Update Builder.php for PHP8 compatibility (FriendsOfSymfony1#82) Fix mandatory value for array $emittedActAs (PHP 8 compatibility) * PHP 8.0 > Typing of internal function parameters do not allow null value anymore. Method str_replace/strtotime now require a string, not null FIX: PDOStatement::fetch, $cursorOffset must be a int Doctrine_Connection_Statement->fetch() default value to null FIX: Private methods cannot be final as they are never overridden by other classes Doctrine_Query_Having->_parseAliases(), remove "final" * PHP 8.1 > Compatibility sfYamlInline, backport fix from Symfony1. Doctrine_Hydrator_Graph fix array_map, rtrim(): Passing null to parameter #1 ($string) of type string is deprecated I emmit the hypothese that this array_map was broken, because array_map result is not assigned. Doctrine_Migration_Diff:333, str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated Doctrine_Migration_Builder:78:, is_dir(): Passing null to parameter #1 ($filename) of type string is deprecated Doctrine_Validator_Notblank, allow null value HydrationListener, in HydrateTestCase.php, fix strtoupper(): Passing null to parameter #1 ($string) of type string is deprecated internal_method_return_types https://wiki.php.net/rfc/internal_method_return_types see 2b2d173 for details Doctrine_Collection_OnDemand Doctrine_Validator_Exception PHP 8.1 PDO stringify is now disable by default. Activate it for Mysql + Sqlite https://www.php.net/manual/en/migration81.incompatible.php#migration81.incompatible.pdo.mysql PHP 8.1 Fix: Warning: strtotime() : Epoch doesn't fit in a PHP integer in Doctrine_Record. This is only happening on 32bit system, because int 32bit could not map the whole strtotime date scope. Example value: "0000-00-00 00:00:00" Before 8.1 strtotime returns false, after it return false but also raise a Warning. @ is slightly lowering performance, it should not trigger any unwanted error, as if format is invalid strtotime should return "false" As this old project need BC for old system, seems the best fix. PHP 8.1 > Automatic conversion of false to array is deprecated Fix Doctrine_Record _invokedSaveHooks cannot assign array value to boolean Declaration to array instead of boolean PHP 8.1 > Serializable Phase Out https://wiki.php.net/rfc/phase_out_serializable PHP 7.4 add a new Serialize mecanism PHP 8.1 made old method, "Serializable implementation" deprecated PHP 9.0 (no release date at this moment) will drop the support. Temporary Fix: Adding both method serialize/unserialize and __serialize/__unserialize In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4. Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment. PHP 8.1 > internal_method_return_types https://wiki.php.net/rfc/internal_method_return_types PHP 8.0 added return type for abstract methods on Iterator, ArrayAccess, Countable, IteratorAggregate PHP 8.1 made non implementation as a Deprecated Warning PHP 9.0 (no release date at this moment) will drop the support. Temporary Fix : adding this Attribute Will drop the Deprecated warning. Adding return type will break compatibility before PHP 7.4, Return type has been added on PHP 7.0, but "mixed" special type is required, and it has been added on PHP 7.4. In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4 Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment. Update Travis to PHP up to 8.1 PHP 8.0 > Doctrine_Query:36, uncaught TypeError: Unsupported operand types: string % int Doctrine_Parser_Xml:89, htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated https://wiki.php.net/rfc/internal_method_return_types for Doctrine_Node Doctrine_Adapter_Mock Doctrine_EventListener_TestLogger Doctrine_Parser_Xml Doctrine_Ticket_1254_TestCase, replace stftime() by date() with format adaptation. * PR Review - Small bug Fixes Fix BC compatibility for any dev using fetch($currentOffset = null) Fix SQLite Connect to return a boolean Remove useless string cast by testing null before Check TaskName declaration Fix test 1783 - 64bit compatibility On 32 bit system, PHP use a float to overflow a bigint. On 64 bit, PHP int is the same as a database bigint, so this test is not relevant anymore * Fix Annotation and Coding Style * Add proof tast name with empty task name property sets by child class * Use GitHub actions for Continuous Integration tests Note: apparently a running MySQL service is not needed to run our tests * Fix broken tests when not using shared mysql socket within docker containers * Remove deprecated --no-suggest option from composer * Update GitHub actions: run pipeline for PRs too * PHP 8.1 > a few more ReturnTypeWillChange attributes added * Flushing more than once causes a warning. Resetting $_collections to the initial state avoids it. * Added type hint for arrays as the second parameter allows both, a string or an array. * PHP 8.2 > Creation of dynamic property Class::$property is deprecated * PHP 8.2 > Using ${var} in strings is deprecated, use {$var} instead. * PHP 8.0 > Trying to access array offset on value of type bool * PHP 8.2 > added test environment * PHP 8.2 > Removed properties from Doctrine_RawSql and used _preQueried in case of clear() and moved the property _pendingJoinConditions fom Doctrine_Query up to Doctrine_Query_Abstract in the hierarchy. * add double to type check. bug FriendsOfSymfony1#88 * PHP 8.1 > Deprecated: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated * removed automated testing for `php7.4` and `php8.0` * removed duplicate methods from `Collection` * Update(github) Update github workflows, use composer caches * Fix array key access in lib/Doctrine/Import/Builder.php Co-authored-by: Alexandre Quercia <alquerci@email.com> * removed automated testing for old php versions * CI: add PHP v8.3 to the CI pipelines (FriendsOfSymfony1#108) * Remove PHP Pear configurations * Update GitAttributes file * Fix PHP deprecations on ArrayAccess and additional classes * fix(Query): add failed test for column added twice with custom aliases * Revert "Added fields with alias to pendingFields array, fixed DC-585" This reverts commit e3ae69c. * added missing `TRANSACTION` directives to `Mysql` connections * Fix(Query): column added twice with custom aliases * ANA-4734 Add trailing line break to base class files (#7) * Fixed test 1325TestCase.php * fix(tests) replace use of iconv in SearchTestCase.php * add(composer): ext-iconv is now a requirement * Adding columns defined in actAs-templates to the docblock of the generated model class. * Update readme: we dont have 1.5 here * Update min PHP version to v7.4 (FriendsOfSymfony1#122) Co-authored-by: Emanuele Panzeri <thepanz@gmail.com> Co-authored-by: Thomas <th@it-solutions-hirsch.de> * Fix invalid docblock for Collection::fromArray() * Remove unused variable from Collection::fromArray() * [composer] add sort-packages * introduce __DIR__ constants * PHP 8.1 > ReturnTypeWillChange attributes added * fixed CI tasks on relevant folders --------- Co-authored-by: Alexandre Quercia <alquerci@email.com> Co-authored-by: Emanuele Panzeri <thepanz@gmail.com> Co-authored-by: xNatek <nathan.trenet@gmail.com> Co-authored-by: Tybaze <tybaze@users.noreply.github.com> Co-authored-by: Ben Tybaze <6998932+Tybaze@users.noreply.github.com> Co-authored-by: Thomas A. Hirsch <thomas.hirsch@vema-eg.de> Co-authored-by: Karoly Gossler <connor@connor.hu> Co-authored-by: Patrick Pfähler <10995809+paddyhamburg@users.noreply.github.com> Co-authored-by: Alex Coles <alexcoles@users.noreply.github.com> Co-authored-by: Thomas <th@it-solutions-hirsch.de> Co-authored-by: Sergei Miami <miami@blackcrystal.net>
1 parent e549dd6 commit 651681f

16 files changed

+72
-93
lines changed

.docker/php74_81/Dockerfile

-34
This file was deleted.

.github/workflows/continuous-integration.yml

-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ jobs:
3030
strategy:
3131
matrix:
3232
php-version:
33-
- "7.4"
34-
- "8.0"
35-
- "8.1"
3633
- "8.2"
3734
- "8.3"
3835

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121
],
2222
"require": {
23-
"php": ">=8.1",
23+
"php": ">=8.2",
2424
"ext-mbstring": "*",
2525
"ext-pdo": "*",
2626
"ext-zlib": "*"

docker-compose.yml

+4-22
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,12 @@ services:
1515
- |
1616
exec tail -f /dev/null
1717
18-
php81:
18+
php82:
19+
<<: *services_php8x
1920
build:
20-
context: .docker/php74_81
21+
context: .docker/php74_82
2122
args:
22-
PHP_VERSION: '8.1'
23-
working_dir: /app/tests
24-
volumes:
25-
- .:/app
26-
- db_socket:/var/run/mysqld
27-
entrypoint:
28-
- sh
29-
- -c
30-
- |
31-
{
32-
echo 'pdo_mysql.default_socket = /var/run/mysqld/mysql.sock'
33-
echo 'memory_limit = -1'
34-
echo 'short_open_tag = off'
35-
echo 'magic_quotes_gpc = off'
36-
echo 'date.timezone = "UTC"'
37-
} | tee -a /usr/local/etc/php/php.ini
38-
39-
exec tail -f /dev/null
40-
depends_on:
41-
- db
23+
PHP_VERSION: '8.2'
4224

4325
db:
4426
image: mysql:5.5.62

lib/Doctrine/Collection.php

-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ public function __unserialize($data)
198198
$manager = Doctrine_Manager::getInstance();
199199
$connection = $manager->getCurrentConnection();
200200

201-
202201
foreach ($data as $name => $values) {
203202
$this->$name = $values;
204203
}

lib/Doctrine/Import/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ public function writeDefinition(array $definition)
15471547
$code .= "Doctrine_Manager::getInstance()->bindComponent('" . $definition['connectionClassName'] . "', '" . $definition['connection'] . "');" . PHP_EOL;
15481548
}
15491549

1550-
$code .= PHP_EOL . $definitionCode;
1550+
$code .= PHP_EOL . $definitionCode . PHP_EOL;
15511551

15521552
if ($this->_eolStyle) {
15531553
$code = str_replace(PHP_EOL, $this->_eolStyle, $code);

lib/Doctrine/Record/Filter/Compound.php

+15-16
Original file line numberDiff line numberDiff line change
@@ -59,62 +59,61 @@ public function init()
5959
/**
6060
* Provides a way for setting property or relation value to the given record.
6161
*
62-
* @param string $property_or_relation
62+
* @param string $propertyOrRelation
6363
*
6464
* @return Doctrine_Record the given record
6565
*
6666
* @thrown Doctrine_Record_UnknownPropertyException when this way is not available
6767
*/
68-
public function filterSet(Doctrine_Record $record, $property_or_relation, $value)
68+
public function filterSet(Doctrine_Record $record, $propertyOrRelation, $value)
6969
{
7070
foreach ($this->_aliases as $alias) {
7171
// The relationship must be fetched in order to check the field existence.
7272
// Related to PHP-7.0 compatibility so an explicit call to method get is required.
7373
$record[$alias];
7474

75-
if (!$record->exists()) {
76-
if (isset($record[$alias][$property_or_relation])) {
77-
$record[$alias][$property_or_relation] = $value;
75+
if ( ! $record->exists()) {
76+
if (isset($record[$alias][$propertyOrRelation])) {
77+
$record[$alias][$propertyOrRelation] = $value;
7878

7979
return $record;
8080
}
8181
} else {
82-
if (isset($record[$alias][$property_or_relation])) {
83-
$record[$alias][$property_or_relation] = $value;
82+
if (isset($record[$alias][$propertyOrRelation])) {
83+
$record[$alias][$propertyOrRelation] = $value;
8484
}
8585

8686
return $record;
8787
}
8888
}
89-
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $property_or_relation, get_class($record)));
89+
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $propertyOrRelation, get_class($record)));
9090
}
9191

9292
/**
9393
* Provides a way for getting property or relation value from the given record.
9494
*
95-
* @param string $property_or_relation
95+
* @param string $propertyOrRelation
9696
*
9797
* @return mixed
9898
*
9999
* @thrown Doctrine_Record_UnknownPropertyException when this way is not available
100100
*/
101-
public function filterGet(Doctrine_Record $record, $property_or_relation)
101+
public function filterGet(Doctrine_Record $record, $propertyOrRelation)
102102
{
103103
foreach ($this->_aliases as $alias) {
104104
// The relationship must be fetched in order to check the field existence.
105105
// Related to PHP-7.0 compatibility so an explicit call to method get is required.
106106
$record[$alias];
107107

108-
if (!$record->exists()) {
109-
if (isset($record[$alias][$property_or_relation])) {
110-
return $record[$alias][$property_or_relation];
108+
if ( ! $record->exists()) {
109+
if (isset($record[$alias][$propertyOrRelation])) {
111110
}
112111
} else {
113-
if (isset($record[$alias][$property_or_relation])) {
114-
return $record[$alias][$property_or_relation];
112+
if (isset($record[$alias][$propertyOrRelation])) {
113+
return $record[$alias][$propertyOrRelation];
115114
}
116115
}
117116
}
118-
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $property_or_relation, get_class($record)));
117+
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $propertyOrRelation, get_class($record)));
119118
}
120119
}

lib/Doctrine/Record/Filter/Standard.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@
3434
class Doctrine_Record_Filter_Standard extends Doctrine_Record_Filter
3535
{
3636
/**
37-
* @param string $property_or_relation
37+
* @param string $propertyOrRelation
3838
*
3939
* @thrown Doctrine_Record_UnknownPropertyException
4040
*/
41-
public function filterSet(Doctrine_Record $record, $property_or_relation, $value)
41+
public function filterSet(Doctrine_Record $record, $propertyOrRelation, $value)
4242
{
43-
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $property_or_relation, get_class($record)));
43+
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $propertyOrRelation, get_class($record)));
4444
}
4545

4646
/**
47-
* @param string $property_or_relation
47+
* @param string $propertyOrRelation
4848
*
4949
* @thrown Doctrine_Record_UnknownPropertyException
5050
*/
51-
public function filterGet(Doctrine_Record $record, $property_or_relation)
51+
public function filterGet(Doctrine_Record $record, $propertyOrRelation)
5252
{
53-
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $property_or_relation, get_class($record)));
53+
throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $propertyOrRelation, get_class($record)));
5454
}
5555
}

lib/Doctrine/Relation.php

+12
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,18 @@ public function isEqual()
169169
return $this->definition['equal'];
170170
}
171171

172+
/**
173+
* @return bool
174+
*/
172175
#[\ReturnTypeWillChange]
173176
public function offsetExists($offset)
174177
{
175178
return isset($this->definition[$offset]);
176179
}
177180

181+
/**
182+
* @return mixed
183+
*/
178184
#[\ReturnTypeWillChange]
179185
public function offsetGet($offset)
180186
{
@@ -185,6 +191,9 @@ public function offsetGet($offset)
185191
return null;
186192
}
187193

194+
/**
195+
* @return void
196+
*/
188197
#[\ReturnTypeWillChange]
189198
public function offsetSet($offset, $value)
190199
{
@@ -193,6 +202,9 @@ public function offsetSet($offset, $value)
193202
}
194203
}
195204

205+
/**
206+
* @return void
207+
*/
196208
#[\ReturnTypeWillChange]
197209
public function offsetUnset($offset)
198210
{

lib/Doctrine/Table.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ public function getColumnName($fieldName)
11801180
}
11811181

11821182
if (is_null($fieldName)) {
1183-
return;
1183+
return '';
11841184
}
11851185

11861186
return strtolower($fieldName);

lib/Doctrine/Transaction/Mysql.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,28 @@ public function getIsolation()
113113
{
114114
return $this->conn->fetchOne('SELECT @@tx_isolation');
115115
}
116-
}
116+
117+
/**
118+
* Performs the rollback.
119+
*/
120+
protected function _doRollback()
121+
{
122+
$this->conn->getDbh()->exec('ROLLBACK');
123+
}
124+
125+
/**
126+
* Performs the commit.
127+
*/
128+
protected function _doCommit()
129+
{
130+
$this->conn->getDbh()->exec('COMMIT');
131+
}
132+
133+
/**
134+
* Begins a database transaction.
135+
*/
136+
protected function _doBeginTransaction()
137+
{
138+
$this->conn->getDbh()->exec('START TRANSACTION');
139+
}
140+
}

tests/CliTestCase/cli-default.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require_once dirname(__DIR__, 2) . '/lib/Doctrine/Core.php';
99
spl_autoload_register(array('Doctrine_Core', 'autoload'));
1010

11-
require_once(__DIR__ . '/TestTask02.php');
11+
require_once __DIR__ . '/TestTask02.php';
1212

1313
$cli = new Doctrine_Cli();
1414
$cli->run($_SERVER['argv']);

tests/CliTestCase/cli-with-custom-tasks.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
$cli = new Doctrine_Cli();
1212

13-
require_once(__DIR__ . '/TestTask02.php');
13+
require_once __DIR__ . '/TestTask02.php';
1414

1515
//Either...:
1616
$cli->registerTaskClass('Doctrine_Cli_TestCase_TestTask02');

tests/CliTestCase/cli-without-autoregistered-custom-tasks.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require_once dirname(__DIR__, 2) . '/lib/Doctrine/Core.php';
99
spl_autoload_register(array('Doctrine_Core', 'autoload'));
1010

11-
require_once(__DIR__ . '/TestTask02.php');
11+
require_once __DIR__ . '/TestTask02.php';
1212

1313
$cli = new Doctrine_Cli(array('autoregister_custom_tasks' => false));
1414
$cli->run($_SERVER['argv']);

tests/Export/RecordTestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ public function testExportSupportsForeignKeysForManyToManyRelations()
9696

9797
public function testExportModelFromDirectory()
9898
{
99-
10099
Doctrine_Core::createTablesFromModels(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . 'export');
100+
101101
$this->assertEqual($this->adapter->pop(), 'COMMIT');
102102
$this->assertEqual($this->adapter->pop(), 'ALTER TABLE cms__category_languages ADD CONSTRAINT cms__category_languages_category_id_cms__category_id FOREIGN KEY (category_id) REFERENCES cms__category(id) ON DELETE CASCADE');
103103
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category_languages (id BIGINT AUTO_INCREMENT, name TEXT, category_id BIGINT, language_id BIGINT, INDEX index_category_idx (category_id), INDEX index_language_idx (language_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
104-
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category (id BIGINT AUTO_INCREMENT, created DATETIME, parent BIGINT, position MEDIUMINT, active BIGINT, INDEX index_parent_idx (parent), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
104+
$this->assertEqual($this->adapter->pop(), 'CREATE TABLE cms__category (id BIGINT AUTO_INCREMENT, created DATETIME, parent BIGINT, position MEDIUMINT, active BIGINT, INDEX index_parent_idx (parent), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB');
105105
$this->assertEqual($this->adapter->pop(), 'BEGIN TRANSACTION');
106106
}
107107

tests/unsolved.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
2-
require_once __DIR__ . '/../lib/Doctrine/Core.php';
32

3+
require_once dirname(__DIR__) . '/lib/Doctrine/Core.php';
44

55
error_reporting(E_ALL);
66

77
spl_autoload_register(array('Doctrine_Core', 'autoload'));
88
require_once 'classes.php';
9-
require_once __DIR__ . '/../models/location.php';
9+
require_once dirname(__DIR__) . '/models/location.php';
1010

1111
print "<pre>";
1212

0 commit comments

Comments
 (0)