Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-03-12 14:50:03 +0300
committerdiosmosis <benaka@piwik.pro>2015-03-12 14:50:03 +0300
commit665e84bb698bf9fa1666e55d6e0380fe2fda783d (patch)
treea4367443bc48375f06742a6249ea04920e6c9069 /core
parentd2a2d2b58bfc2ffc6d17cd5b5ea982b07a5c263a (diff)
parent484935ce69c19e94d4b2a95aca33e75b0802abbe (diff)
Merge branch 'master' into geo-attribution-task
Diffstat (limited to 'core')
-rw-r--r--core/Archive.php6
-rw-r--r--core/DataTable.php23
-rw-r--r--core/DataTable/Filter/Sort.php4
-rw-r--r--core/DataTable/Map.php27
-rw-r--r--core/Http.php38
-rw-r--r--core/Tracker/Model.php15
-rw-r--r--core/Version.php2
7 files changed, 106 insertions, 9 deletions
diff --git a/core/Archive.php b/core/Archive.php
index c7eb6e3106..0499756410 100644
--- a/core/Archive.php
+++ b/core/Archive.php
@@ -498,7 +498,11 @@ class Archive
$dataTable = self::getDataTableFromArchive($recordName, $idSite, $period, $date, $segment, $expanded, $idSubtable, $depth);
- $dataTable->filter('ReplaceColumnNames');
+ $dataTable->queueFilter('ReplaceColumnNames');
+
+ if ($expanded) {
+ $dataTable->queueFilterSubtables('ReplaceColumnNames');
+ }
if ($flat) {
$dataTable->disableRecursiveFilters();
diff --git a/core/DataTable.php b/core/DataTable.php
index 0b0d9845f0..48f4c1426b 100644
--- a/core/DataTable.php
+++ b/core/DataTable.php
@@ -489,6 +489,27 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
}
/**
+ * Adds a filter and a list of parameters to the list of queued filters of all subtables. These filters will be
+ * executed when {@link applyQueuedFilters()} is called.
+ *
+ * Filters that prettify the column values or don't need the full set of rows should be queued. This
+ * way they will be run after the table is truncated which will result in better performance.
+ *
+ * @param string|Closure $className The class name of the filter, eg. `'Limit'`.
+ * @param array $parameters The parameters to give to the filter, eg. `array($offset, $limit)` for the Limit filter.
+ */
+ public function queueFilterSubtables($className, $parameters = array())
+ {
+ foreach ($this->getRows() as $row) {
+ $subtable = $row->getSubtable();
+ if ($subtable) {
+ $subtable->queueFilter($className, $parameters);
+ $subtable->queueFilterSubtables($className, $parameters);
+ }
+ }
+ }
+
+ /**
* Adds a filter and a list of parameters to the list of queued filters. These filters will be
* executed when {@link applyQueuedFilters()} is called.
*
@@ -1733,4 +1754,4 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess
{
$this->deleteRow($offset);
}
-} \ No newline at end of file
+}
diff --git a/core/DataTable/Filter/Sort.php b/core/DataTable/Filter/Sort.php
index 632da35dc8..3da11b4119 100644
--- a/core/DataTable/Filter/Sort.php
+++ b/core/DataTable/Filter/Sort.php
@@ -143,9 +143,9 @@ Sort extends BaseFilter
);
}
- protected function getColumnValue(Row $table )
+ protected function getColumnValue(Row $row)
{
- $value = $table->getColumn($this->columnToSort);
+ $value = $row->getColumn($this->columnToSort);
if ($value === false
|| is_array($value)
diff --git a/core/DataTable/Map.php b/core/DataTable/Map.php
index 8787b06404..ccf201c5be 100644
--- a/core/DataTable/Map.php
+++ b/core/DataTable/Map.php
@@ -123,6 +123,19 @@ class Map implements DataTableInterface
}
/**
+ * Apply a queued filter to all subtables contained by this instance.
+ *
+ * @param string|Closure $className Name of filter class or a Closure.
+ * @param array $parameters Parameters to pass to the filter.
+ */
+ public function queueFilterSubtables($className, $parameters = array())
+ {
+ foreach ($this->getDataTables() as $table) {
+ $table->queueFilterSubtables($className, $parameters);
+ }
+ }
+
+ /**
* Returns the array of DataTables contained by this class.
*
* @return DataTable[]|Map[]
@@ -174,6 +187,20 @@ class Map implements DataTableInterface
$this->array[$label] = $table;
}
+ public function getRowFromIdSubDataTable($idSubtable)
+ {
+ $dataTables = $this->getDataTables();
+
+ // find first datatable containing data
+ foreach ($dataTables as $subTable) {
+ $subTableRow = $subTable->getRowFromIdSubDataTable($idSubtable);
+
+ if (!empty($subTableRow)) {
+ return $subTableRow;
+ }
+ }
+ }
+
/**
* Returns a string output of this DataTable\Map (applying the default renderer to every {@link DataTable}
* of this DataTable\Map).
diff --git a/core/Http.php b/core/Http.php
index 08bcbcef15..ffd0bf4383 100644
--- a/core/Http.php
+++ b/core/Http.php
@@ -64,6 +64,9 @@ class Http
* Doesn't work w/ `fopen` transport method.
* @param bool $getExtendedInfo If true returns the status code, headers & response, if false just the response.
* @param string $httpMethod The HTTP method to use. Defaults to `'GET'`.
+ * @param string $httpUsername HTTP Auth username
+ * @param string $httpPassword HTTP Auth password
+ *
* @throws Exception if the response cannot be saved to `$destinationPath`, if the HTTP response cannot be sent,
* if there are more than 5 redirects or if the request times out.
* @return bool|string If `$destinationPath` is not specified the HTTP response is returned on success. `false`
@@ -78,7 +81,17 @@ class Http
* `false` is still returned on failure.
* @api
*/
- public static function sendHttpRequest($aUrl, $timeout, $userAgent = null, $destinationPath = null, $followDepth = 0, $acceptLanguage = false, $byteRange = false, $getExtendedInfo = false, $httpMethod = 'GET')
+ public static function sendHttpRequest($aUrl,
+ $timeout,
+ $userAgent = null,
+ $destinationPath = null,
+ $followDepth = 0,
+ $acceptLanguage = false,
+ $byteRange = false,
+ $getExtendedInfo = false,
+ $httpMethod = 'GET',
+ $httpUsername = null,
+ $httpPassword = null)
{
// create output file
$file = null;
@@ -91,7 +104,7 @@ class Http
}
$acceptLanguage = $acceptLanguage ? 'Accept-Language: ' . $acceptLanguage : '';
- return self::sendHttpRequestBy(self::getTransportMethod(), $aUrl, $timeout, $userAgent, $destinationPath, $file, $followDepth, $acceptLanguage, $acceptInvalidSslCertificate = false, $byteRange, $getExtendedInfo, $httpMethod);
+ return self::sendHttpRequestBy(self::getTransportMethod(), $aUrl, $timeout, $userAgent, $destinationPath, $file, $followDepth, $acceptLanguage, $acceptInvalidSslCertificate = false, $byteRange, $getExtendedInfo, $httpMethod, $httpUsername, $httpPassword);
}
/**
@@ -110,6 +123,8 @@ class Http
* Doesn't work w/ fopen method.
* @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
* @param string $httpMethod The HTTP method to use. Defaults to `'GET'`.
+ * @param string $httpUsername HTTP Auth username
+ * @param string $httpPassword HTTP Auth password
*
* @throws Exception
* @return bool true (or string/array) on success; false on HTTP response error code (1xx or 4xx)
@@ -126,7 +141,9 @@ class Http
$acceptInvalidSslCertificate = false,
$byteRange = false,
$getExtendedInfo = false,
- $httpMethod = 'GET'
+ $httpMethod = 'GET',
+ $httpUsername = null,
+ $httpPassword = null
)
{
if ($followDepth > 5) {
@@ -168,6 +185,11 @@ class Http
$status = null;
$headers = array();
+ $httpAuthIsUsed = !empty($httpUsername) || !empty($httpPassword);
+ if($httpAuthIsUsed && $method != 'curl') {
+ throw new Exception("Specifying HTTP Username and HTTP password is only supported for CURL for now.");
+ }
+
if ($method == 'socket') {
if (!self::isSocketEnabled()) {
// can be triggered in tests
@@ -315,7 +337,9 @@ class Http
$acceptInvalidSslCertificate = false,
$byteRange,
$getExtendedInfo,
- $httpMethod
+ $httpMethod,
+ $httpUsername,
+ $httpPassword
);
}
@@ -462,6 +486,12 @@ class Http
@curl_setopt($ch, CURLOPT_NOBODY, true);
}
+ if(!empty($httpUsername) && !empty($httpPassword)) {
+ $curl_options += array(
+ CURLOPT_USERPWD => $httpUsername . ':' . $httpPassword,
+ );
+ }
+
@curl_setopt_array($ch, $curl_options);
self::configCurlCertificate($ch);
diff --git a/core/Tracker/Model.php b/core/Tracker/Model.php
index e40f845e00..bb4fc1075a 100644
--- a/core/Tracker/Model.php
+++ b/core/Tracker/Model.php
@@ -391,6 +391,21 @@ class Model
return $visitRow;
}
+ /**
+ * Returns true if the site doesn't have log data.
+ *
+ * @param int $siteId
+ * @return bool
+ */
+ public function isSiteEmpty($siteId)
+ {
+ $sql = sprintf('SELECT idsite FROM %s WHERE idsite = ? limit 1', Common::prefixTable('log_visit'));
+
+ $result = \Piwik\Db::fetchOne($sql, array($siteId));
+
+ return $result == null;
+ }
+
private function visitFieldsToQuery($valuesToUpdate)
{
$updateParts = array();
diff --git a/core/Version.php b/core/Version.php
index 0d5a9e14b9..71c2a66f40 100644
--- a/core/Version.php
+++ b/core/Version.php
@@ -20,7 +20,7 @@ final class Version
* The current Piwik version.
* @var string
*/
- const VERSION = '2.12.0-b1';
+ const VERSION = '2.12.0-b2';
public function isStableVersion($version)
{