update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -25,6 +25,7 @@ class Mysqli extends Db
|
|||
protected $username;
|
||||
protected $password;
|
||||
protected $charset;
|
||||
protected $activeTransaction = false;
|
||||
|
||||
/**
|
||||
* Builds the DB object
|
||||
|
|
@ -38,13 +39,13 @@ class Mysqli extends Db
|
|||
$this->host = null;
|
||||
$this->port = null;
|
||||
$this->socket = $dbInfo['unix_socket'];
|
||||
} else if ($dbInfo['port'][0] == '/') {
|
||||
} elseif ($dbInfo['port'][0] == '/') {
|
||||
$this->host = null;
|
||||
$this->port = null;
|
||||
$this->socket = $dbInfo['port'];
|
||||
} else {
|
||||
$this->host = $dbInfo['host'];
|
||||
$this->port = $dbInfo['port'];
|
||||
$this->port = (int)$dbInfo['port'];
|
||||
$this->socket = null;
|
||||
}
|
||||
$this->dbname = $dbInfo['dbname'];
|
||||
|
|
@ -72,7 +73,14 @@ class Mysqli extends Db
|
|||
$timer = $this->initProfiler();
|
||||
}
|
||||
|
||||
$this->connection = mysqli_connect($this->host, $this->username, $this->password, $this->dbname, $this->port, $this->socket);
|
||||
$this->connection = mysqli_init();
|
||||
|
||||
// Make sure MySQL returns all matched rows on update queries including
|
||||
// rows that actually didn't have to be updated because the values didn't
|
||||
// change. This matches common behaviour among other database systems.
|
||||
// See #6296 why this is important in tracker
|
||||
$flags = MYSQLI_CLIENT_FOUND_ROWS;
|
||||
mysqli_real_connect($this->connection, $this->host, $this->username, $this->password, $this->dbname, $this->port, $this->socket, $flags);
|
||||
if (!$this->connection || mysqli_connect_errno()) {
|
||||
throw new DbException("Connect failed: " . mysqli_connect_error());
|
||||
}
|
||||
|
|
@ -204,8 +212,8 @@ class Mysqli extends Db
|
|||
return $result;
|
||||
} catch (Exception $e) {
|
||||
throw new DbException("Error query: " . $e->getMessage() . "
|
||||
In query: $query
|
||||
Parameters: " . var_export($parameters, true));
|
||||
In query: $query
|
||||
Parameters: " . var_export($parameters, true), $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +239,7 @@ class Mysqli extends Db
|
|||
{
|
||||
if (!$parameters) {
|
||||
$parameters = array();
|
||||
} else if (!is_array($parameters)) {
|
||||
} elseif (!is_array($parameters)) {
|
||||
$parameters = array($parameters);
|
||||
}
|
||||
|
||||
|
|
@ -276,4 +284,62 @@ class Mysqli extends Db
|
|||
{
|
||||
return mysqli_affected_rows($this->connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start Transaction
|
||||
* @return string TransactionID
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
if (!$this->activeTransaction === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->connection->autocommit(false)) {
|
||||
$this->activeTransaction = uniqid();
|
||||
return $this->activeTransaction;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
* @param $xid
|
||||
* @throws DbException
|
||||
* @internal param TransactionID $string from beginTransaction
|
||||
*/
|
||||
public function commit($xid)
|
||||
{
|
||||
if ($this->activeTransaction != $xid || $this->activeTransaction === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->activeTransaction = false;
|
||||
|
||||
if (!$this->connection->commit()) {
|
||||
throw new DbException("Commit failed");
|
||||
}
|
||||
|
||||
$this->connection->autocommit(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
* @param $xid
|
||||
* @throws DbException
|
||||
* @internal param TransactionID $string from beginTransaction
|
||||
*/
|
||||
public function rollBack($xid)
|
||||
{
|
||||
if ($this->activeTransaction != $xid || $this->activeTransaction === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->activeTransaction = false;
|
||||
|
||||
if (!$this->connection->rollback()) {
|
||||
throw new DbException("Rollback failed");
|
||||
}
|
||||
|
||||
$this->connection->autocommit(true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -30,6 +30,8 @@ class Mysql extends Db
|
|||
protected $password;
|
||||
protected $charset;
|
||||
|
||||
protected $activeTransaction = false;
|
||||
|
||||
/**
|
||||
* Builds the DB object
|
||||
*
|
||||
|
|
@ -40,14 +42,19 @@ class Mysql extends Db
|
|||
{
|
||||
if (isset($dbInfo['unix_socket']) && $dbInfo['unix_socket'][0] == '/') {
|
||||
$this->dsn = $driverName . ':dbname=' . $dbInfo['dbname'] . ';unix_socket=' . $dbInfo['unix_socket'];
|
||||
} else if (!empty($dbInfo['port']) && $dbInfo['port'][0] == '/') {
|
||||
} elseif (!empty($dbInfo['port']) && $dbInfo['port'][0] == '/') {
|
||||
$this->dsn = $driverName . ':dbname=' . $dbInfo['dbname'] . ';unix_socket=' . $dbInfo['port'];
|
||||
} else {
|
||||
$this->dsn = $driverName . ':dbname=' . $dbInfo['dbname'] . ';host=' . $dbInfo['host'] . ';port=' . $dbInfo['port'];
|
||||
}
|
||||
|
||||
$this->username = $dbInfo['username'];
|
||||
$this->password = $dbInfo['password'];
|
||||
$this->charset = isset($dbInfo['charset']) ? $dbInfo['charset'] : null;
|
||||
|
||||
if (isset($dbInfo['charset'])) {
|
||||
$this->charset = $dbInfo['charset'];
|
||||
$this->dsn .= ';charset=' . $this->charset;
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
|
|
@ -66,8 +73,17 @@ class Mysql extends Db
|
|||
$timer = $this->initProfiler();
|
||||
}
|
||||
|
||||
$this->connection = @new PDO($this->dsn, $this->username, $this->password, $config = array());
|
||||
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
// Make sure MySQL returns all matched rows on update queries including
|
||||
// rows that actually didn't have to be updated because the values didn't
|
||||
// change. This matches common behaviour among other database systems.
|
||||
// See #6296 why this is important in tracker
|
||||
$config = array(
|
||||
PDO::MYSQL_ATTR_FOUND_ROWS => true,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
);
|
||||
|
||||
$this->connection = @new PDO($this->dsn, $this->username, $this->password, $config);
|
||||
|
||||
// we may want to setAttribute(PDO::ATTR_TIMEOUT ) to a few seconds (default is 60) in case the DB is locked
|
||||
// the piwik.php would stay waiting for the database... bad!
|
||||
// we delete the password from this object "just in case" it could be printed
|
||||
|
|
@ -192,9 +208,8 @@ class Mysql extends Db
|
|||
}
|
||||
return $sth;
|
||||
} catch (PDOException $e) {
|
||||
throw new DbException("Error query: " . $e->getMessage() . "
|
||||
In query: $query
|
||||
Parameters: " . var_export($parameters, true));
|
||||
$message = $e->getMessage() . " In query: $query Parameters: " . var_export($parameters, true);
|
||||
throw new DbException("Error query: " . $message, (int) $e->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -234,4 +249,58 @@ class Mysql extends Db
|
|||
{
|
||||
return $queryResult->rowCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start Transaction
|
||||
* @return string TransactionID
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
if (!$this->activeTransaction === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->connection->beginTransaction()) {
|
||||
$this->activeTransaction = uniqid();
|
||||
return $this->activeTransaction;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit Transaction
|
||||
* @param $xid
|
||||
* @throws DbException
|
||||
* @internal param TransactionID $string from beginTransaction
|
||||
*/
|
||||
public function commit($xid)
|
||||
{
|
||||
if ($this->activeTransaction != $xid || $this->activeTransaction === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->activeTransaction = false;
|
||||
|
||||
if (!$this->connection->commit()) {
|
||||
throw new DbException("Commit failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback Transaction
|
||||
* @param $xid
|
||||
* @throws DbException
|
||||
* @internal param TransactionID $string from beginTransaction
|
||||
*/
|
||||
public function rollBack($xid)
|
||||
{
|
||||
if ($this->activeTransaction != $xid || $this->activeTransaction === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->activeTransaction = false;
|
||||
|
||||
if (!$this->connection->rollBack()) {
|
||||
throw new DbException("Rollback failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue