Skip to content

Commit 245cc86

Browse files
committed
Merge branch 3.3/release/3.3.3 into 3.3/master
2 parents 3d7a7cd + c352da3 commit 245cc86

File tree

16 files changed

+112
-19
lines changed

16 files changed

+112
-19
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
composer.lock
2+
vendor/*
3+
koharness_bootstrap.php
4+

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
- 5.6
8+
- hhvm
9+
10+
before_script:
11+
- composer install --prefer-dist
12+
- vendor/bin/koharness
13+
14+
script:
15+
- cd /tmp/koharness && ./vendor/bin/phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php
16+
17+
notifications:
18+
email: false

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Kohana - database access module
2+
3+
| ver | Stable | Develop |
4+
|-------|--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
5+
| 3.3.x | [![Build Status - 3.3/master](https://travis-ci.org/kohana/database.svg?branch=3.3%2Fmaster)](https://travis-ci.org/kohana/database) | [![Build Status - 3.3/develop](https://travis-ci.org/kohana/database.svg?branch=3.3%2Fdevelop)](https://travis-ci.org/kohana/database) |
6+
| 3.4.x | [![Build Status - 3.4/master](https://travis-ci.org/kohana/database.svg?branch=3.4%2Fmaster)](https://travis-ci.org/kohana/database) | [![Build Status - 3.4/develop](https://travis-ci.org/kohana/database.svg?branch=3.4%2Fdevelop)](https://travis-ci.org/kohana/database) |

classes/Kohana/Config/Database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @copyright (c) 2012 Kohana Team
1010
* @license http://kohanaframework.org/license
1111
*/
12-
class Kohana_Config_Database extends Kohana_Config_Database_Writer
12+
class Kohana_Config_Database extends Config_Database_Writer
1313
{
1414

1515
}

classes/Kohana/Config/Database/Writer.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
/**
44
* Database writer for the config system
55
*
6+
* Schema for configuration table:
7+
*
8+
* CREATE TABLE IF NOT EXISTS `config` (
9+
* `group_name` varchar(128) NOT NULL,
10+
* `config_key` varchar(128) NOT NULL,
11+
* `config_value` text,
12+
* PRIMARY KEY (`group_name`,`config_key`)
13+
* ) ENGINE=InnoDB;
14+
*
615
* @package Kohana
716
* @category Configuration
817
* @author Kohana Team

classes/Kohana/Database/MySQL/Result.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,42 @@ public function current()
5151
// Increment internal row for optimization assuming rows are fetched in order
5252
$this->_internal_row++;
5353

54+
// FIXME mysql_fetch_object has been deprecated as of php 5.5!
55+
// Please use mysqli_fetch_object or PDOStatement::fetch(PDO::FETCH_OBJ) instead.
56+
5457
if ($this->_as_object === TRUE)
5558
{
5659
// Return an stdClass
5760
return mysql_fetch_object($this->_result);
5861
}
5962
elseif (is_string($this->_as_object))
6063
{
61-
// Return an object of given class name
62-
return mysql_fetch_object($this->_result, $this->_as_object, $this->_object_params);
64+
/* The second and third argument for mysql_fetch_object are optional, but do
65+
* not have default values defined. Passing _object_params with a non-array value results
66+
* in undefined behavior that varies by PHP version. For example, if NULL is supplied on
67+
* PHP 5.3, the resulting behavior is identical to calling with array(), which results in the
68+
* classes __construct function being called with no arguments. This is only an issue when
69+
* the _as_object class does not have an explicit __construct method resulting in the
70+
* cryptic error "Class %s does not have a constructor hence you cannot use ctor_params."
71+
* In contrast, the same function call on PHP 5.5 will 'functionally' interpret
72+
* _object_params == NULL as an omission of the third argument, resulting in the original
73+
* intended functionally.
74+
*
75+
* Because the backing code for the mysql_fetch_object has not changed between 5.3 and 5.5,
76+
* I suspect this discrepancy is due to the way the classes are instantiated on a boarder
77+
* level. Additionally, mysql_fetch_object has been deprecated in 5.5 and should probably be
78+
* replaced by mysqli_fetch_object or PDOStatement::fetch(PDO::FETCH_OBJ) in Kohana 3.4.
79+
*/
80+
if ($this->_object_params !== NULL)
81+
{
82+
// Return an object of given class name with constructor params
83+
return mysql_fetch_object($this->_result, $this->_as_object, $this->_object_params);
84+
}
85+
else
86+
{
87+
// Return an object of given class name without constructor params
88+
return mysql_fetch_object($this->_result, $this->_as_object);
89+
}
6390
}
6491
else
6592
{

classes/Kohana/Database/PDO.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public function connect()
6060
array(':error' => $e->getMessage()),
6161
$e->getCode());
6262
}
63+
64+
if ( ! empty($this->_config['charset']))
65+
{
66+
// Set the character set
67+
$this->set_charset($this->_config['charset']);
68+
}
6369
}
6470

6571
/**

classes/Kohana/Database/Query/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function _compile_conditions(Database $db, array $conditions)
8080
// Convert "val = NULL" to "val IS NULL"
8181
$op = 'IS';
8282
}
83-
elseif ($op === '!=')
83+
elseif ($op === '!=' OR $op === '<>')
8484
{
8585
// Convert "val != NULL" to "valu IS NOT NULL"
8686
$op = 'IS NOT';

classes/Kohana/Database/Query/Builder/Insert.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct($table = NULL, array $columns = NULL)
3131
if ($table)
3232
{
3333
// Set the inital table name
34-
$this->_table = $table;
34+
$this->table($table);
3535
}
3636

3737
if ($columns)
@@ -47,11 +47,14 @@ public function __construct($table = NULL, array $columns = NULL)
4747
/**
4848
* Sets the table to insert into.
4949
*
50-
* @param mixed $table table name or array($table, $alias) or object
50+
* @param string $table table name
5151
* @return $this
5252
*/
5353
public function table($table)
5454
{
55+
if ( ! is_string($table))
56+
throw new Kohana_Exception('INSERT INTO syntax does not allow table aliasing');
57+
5558
$this->_table = $table;
5659

5760
return $this;

classes/Kohana/Database/Query/Builder/Select.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public function union($select, $all = TRUE)
309309
*/
310310
public function offset($number)
311311
{
312-
$this->_offset = $number;
312+
$this->_offset = ($number === NULL) ? NULL : (int) $number;
313313

314314
return $this;
315315
}
@@ -404,13 +404,14 @@ public function compile($db = NULL)
404404

405405
if ( ! empty($this->_union))
406406
{
407+
$query = '('.$query.')';
407408
foreach ($this->_union as $u) {
408409
$query .= ' UNION ';
409410
if ($u['all'] === TRUE)
410411
{
411412
$query .= 'ALL ';
412413
}
413-
$query .= $u['select']->compile($db);
414+
$query .= '('.$u['select']->compile($db).')';
414415
}
415416
}
416417

0 commit comments

Comments
 (0)