Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
501e3e86
Commit
501e3e86
authored
Oct 20, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #697 from orchitech/DBAL-993
Reset date fields to UNIX epoch in TimeType.
parents
aefb4e7b
0cbb338b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
UPGRADE.md
UPGRADE.md
+10
-0
TimeType.php
lib/Doctrine/DBAL/Types/TimeType.php
+1
-1
TypeConversionTest.php
tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
+1
-1
TimeTest.php
tests/Doctrine/Tests/DBAL/Types/TimeTest.php
+7
-0
No files found.
UPGRADE.md
View file @
501e3e86
# Upgrade to 2.5
# Upgrade to 2.5
## BC BREAK: time type resets date fields to UNIX epoch
When mapping
`time`
type field to PHP's
`DateTime`
instance all unused date fields are
reset to UNIX epoch (i.e. 1970-01-01). This might break any logic which relies on comparing
`DateTime`
instances with date fields set to the current date.
Use
`!`
format prefix (see http://php.net/manual/en/datetime.createfromformat.php) for parsing
time strings to prevent having different date fields when comparing user input and
`DateTime`
instances as mapped by Doctrine.
## BC BREAK: Doctrine\DBAL\Schema\Table
## BC BREAK: Doctrine\DBAL\Schema\Table
The methods
``addIndex()``
and
``addUniqueIndex()``
in
``Doctrine\DBAL\Schema\Table``
The methods
``addIndex()``
and
``addUniqueIndex()``
in
``Doctrine\DBAL\Schema\Table``
...
...
lib/Doctrine/DBAL/Types/TimeType.php
View file @
501e3e86
...
@@ -62,7 +62,7 @@ class TimeType extends Type
...
@@ -62,7 +62,7 @@ class TimeType extends Type
return
$value
;
return
$value
;
}
}
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getTimeFormatString
(),
$value
);
$val
=
\DateTime
::
createFromFormat
(
'!'
.
$platform
->
getTimeFormatString
(),
$value
);
if
(
!
$val
)
{
if
(
!
$val
)
{
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getTimeFormatString
());
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getTimeFormatString
());
}
}
...
...
tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
View file @
501e3e86
...
@@ -59,7 +59,7 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -59,7 +59,7 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
array
(
'datetime'
,
new
\DateTime
(
'2010-04-05 10:10:10'
),
'DateTime'
),
array
(
'datetime'
,
new
\DateTime
(
'2010-04-05 10:10:10'
),
'DateTime'
),
array
(
'datetimetz'
,
new
\DateTime
(
'2010-04-05 10:10:10'
),
'DateTime'
),
array
(
'datetimetz'
,
new
\DateTime
(
'2010-04-05 10:10:10'
),
'DateTime'
),
array
(
'date'
,
new
\DateTime
(
'2010-04-05'
),
'DateTime'
),
array
(
'date'
,
new
\DateTime
(
'2010-04-05'
),
'DateTime'
),
array
(
'time'
,
new
\DateTime
(
'10:10:10'
),
'DateTime'
),
array
(
'time'
,
new
\DateTime
(
'1
970-01-01 1
0:10:10'
),
'DateTime'
),
array
(
'text'
,
str_repeat
(
'foo '
,
1000
),
'string'
),
array
(
'text'
,
str_repeat
(
'foo '
,
1000
),
'string'
),
array
(
'array'
,
array
(
'foo'
=>
'bar'
),
'array'
),
array
(
'array'
,
array
(
'foo'
=>
'bar'
),
'array'
),
array
(
'json_array'
,
array
(
'foo'
=>
'bar'
),
'array'
),
array
(
'json_array'
,
array
(
'foo'
=>
'bar'
),
'array'
),
...
...
tests/Doctrine/Tests/DBAL/Types/TimeTest.php
View file @
501e3e86
...
@@ -34,6 +34,13 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase
...
@@ -34,6 +34,13 @@ class TimeTest extends \Doctrine\Tests\DbalTestCase
);
);
}
}
public
function
testDateFieldResetInPHPValue
()
{
$time
=
$this
->
_type
->
convertToPHPValue
(
'01:23:34'
,
$this
->
_platform
);
$this
->
assertEquals
(
'01:23:34'
,
$time
->
format
(
'H:i:s'
));
$this
->
assertEquals
(
'1970-01-01'
,
$time
->
format
(
'Y-m-d'
));
}
public
function
testInvalidTimeFormatConversion
()
public
function
testInvalidTimeFormatConversion
()
{
{
$this
->
setExpectedException
(
'Doctrine\DBAL\Types\ConversionException'
);
$this
->
setExpectedException
(
'Doctrine\DBAL\Types\ConversionException'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment