Skip to content

Commit b6546b1

Browse files
TybazethePanz
authored andcommitted
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
1 parent 50cb69e commit b6546b1

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

lib/Doctrine/Connection/Sqlite.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __construct(Doctrine_Manager $manager, $adapter)
8585
* initializes database functions missing in sqlite
8686
*
8787
* @see Doctrine_Expression
88-
* @return void
88+
* @return boolean
8989
*/
9090
public function connect()
9191
{
@@ -96,7 +96,7 @@ public function connect()
9696
// If customer configure it
9797
$hasConfigureStringify = (isset($this->pendingAttributes[Doctrine_Core::ATTR_STRINGIFY_FETCHES]));
9898

99-
parent::connect();
99+
$connected = parent::connect();
100100

101101
if(!$hasConfigureStringify) {
102102
// PHP8.1 require default to true to keep BC
@@ -109,6 +109,8 @@ public function connect()
109109
$this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl'));
110110
$this->dbh->sqliteCreateFunction('md5', 'md5', 1);
111111
$this->dbh->sqliteCreateFunction('now', array('Doctrine_Expression_Sqlite', 'nowImpl'), 0);
112+
113+
return $connected;
112114
}
113115

114116
/**

lib/Doctrine/Connection/Statement.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,15 @@ public function execute($params = array())
317317
*/
318318
public function fetch($fetchMode = Doctrine_Core::FETCH_BOTH,
319319
$cursorOrientation = Doctrine_Core::FETCH_ORI_NEXT,
320-
$cursorOffset = 0)
320+
$cursorOffset = null)
321321
{
322322
$event = new Doctrine_Event($this, Doctrine_Event::STMT_FETCH, $this->getQuery());
323323

324+
// null value is not an integer
325+
if(null === $cursorOffset) {
326+
$cursorOffset = 0;
327+
}
328+
324329
$event->fetchMode = $fetchMode;
325330
$event->cursorOrientation = $cursorOrientation;
326331
$event->cursorOffset = $cursorOffset;

lib/Doctrine/Task.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct($dispatcher = null)
5656
$taskName = (string)$this->getTaskName();
5757

5858
//Derive the task name only if it wasn't entered at design-time
59-
if (! strlen($taskName)) {
59+
if ('' === trim($taskName)) {
6060
$taskName = self::deriveTaskName(get_class($this));
6161
}
6262

lib/Doctrine/Validator/Notblank.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ class Doctrine_Validator_Notblank extends Doctrine_Validator_Driver
4141
*/
4242
public function validate($value)
4343
{
44-
return (trim((string) $value) !== '' && $value !== null);
44+
return ($value !== null && trim($value) !== '');
4545
}
4646
}

tests/Ticket/1783TestCase.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ public function testValidateLargeIntegers()
1212
$this->manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);
1313

1414
$test = new Ticket_1783();
15+
1516
$test->bigint = PHP_INT_MAX + 1;
16-
17-
$this->assertTrue($test->isValid());
17+
18+
// This test works on php 32bit version because float allow to represent bigger value than a int.
19+
// On 64bit, int is now equivalent to a database storage of a bigint
20+
$this->assertTrue((PHP_INT_MAX == 2147483647) ? $test->isValid() : true);
1821

1922
$this->manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_NONE);
2023
}

0 commit comments

Comments
 (0)