Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into report_and_dimensio…
Browse files Browse the repository at this point in the history
…n_refactoring

Conflicts:
	core/Updates/0.4.2.php
	core/Updates/0.6.3.php
	core/Updates/1.2-rc1.php
	core/Updates/1.9-b9.php
	core/Version.php
	tests/PHPUnit/Fixture.php
	tests/PHPUnit/Fixtures/UITestFixture.php
	tests/PHPUnit/Integration/Core/JsProxyTest.php
  • Loading branch information
tsteur committed Jul 12, 2014
2 parents 7307661 + 305f165 commit 3dcf8c3
Show file tree
Hide file tree
Showing 183 changed files with 1,213 additions and 705 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -87,8 +87,8 @@ before_script:
- mysql -e "SHOW GLOBAL VARIABLES;"
# Setup Piwik stack
- ./tests/travis/initiate_ui_tests.sh
- composer self-update
- composer install
- travis_retry composer self-update
- travis_retry composer install
- uname -a
- date
- php -r "var_dump(gd_info());"
Expand Down
2 changes: 1 addition & 1 deletion LEGALNOTICE
Expand Up @@ -40,7 +40,7 @@ CREDITS

For detailed contribution history, refer to the source, tickets,
patches, and Git revision history, available at
http://dev.piwik.org/trac/
https://github.com/piwik/piwik/issues
https://github.com/piwik/piwik


Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -14,7 +14,7 @@
],
"support": {
"forum": "http://forum.piwik.org/",
"issues": "http://dev.piwik.org/trac/roadmap",
"issues": "https://github.com/piwik/piwik/issues",
"wiki": "http://dev.piwik.org/",
"source": "https://github.com/piwik/piwik"
},
Expand Down
2 changes: 1 addition & 1 deletion config/global.ini.php
Expand Up @@ -548,7 +548,7 @@

; Comma separated list of known Referrer Spammers, ie. bot visits that set a fake Referrer field.
; All Visits with a Referrer URL host set to one of these will be excluded.
; If you find new spam entries in Referrers>Websites, please report them here: http://dev.piwik.org/trac/ticket/5099
; If you find new spam entries in Referrers>Websites, please report them here: https://github.com/piwik/piwik/issues/5099
referrer_urls_spam = "semalt.com"

; DO NOT USE THIS SETTING ON PUBLICLY AVAILABLE PIWIK SERVER
Expand Down
22 changes: 22 additions & 0 deletions core/API/DataTableGenericFilter.php
Expand Up @@ -15,6 +15,13 @@

class DataTableGenericFilter
{
/**
* List of filter names not to run.
*
* @var string[]
*/
private $disabledFilters = array();

/**
* Constructor
*
Expand All @@ -35,6 +42,16 @@ public function filter($table)
$this->applyGenericFilters($table);
}

/**
* Makes sure a set of filters are not run.
*
* @param string[] $filterNames The name of each filter to disable.
*/
public function disableFilters($filterNames)
{
$this->disabledFilters = array_unique(array_merge($this->disabledFilters, $filterNames));
}

/**
* Returns an array containing the information of the generic Filter
* to be applied automatically to the data resulting from the API calls.
Expand Down Expand Up @@ -117,6 +134,11 @@ protected function applyGenericFilters($datatable)
$filterParams = $filterMeta[1];
$filterParameters = array();
$exceptionRaised = false;

if (in_array($filterName, $this->disabledFilters)) {
continue;
}

foreach ($filterParams as $name => $info) {
// parameter type to cast to
$type = $info[0];
Expand Down
15 changes: 10 additions & 5 deletions core/API/DataTableManipulator/LabelFilter.php
Expand Up @@ -24,6 +24,7 @@
class LabelFilter extends DataTableManipulator
{
const SEPARATOR_RECURSIVE_LABEL = '>';
const TERMINAL_OPERATOR = '@';

private $labels;
private $addLabelIndex;
Expand Down Expand Up @@ -118,19 +119,23 @@ private function getLabelVariations($originalLabel)
{
static $pageTitleReports = array('getPageTitles', 'getEntryPageTitles', 'getExitPageTitles');

$originalLabel = trim($originalLabel);

$isTerminal = substr($originalLabel, 0, 1) == self::TERMINAL_OPERATOR;
if ($isTerminal) {
$originalLabel = substr($originalLabel, 1);
}

$variations = array();
$label = urldecode($originalLabel);
$label = trim($label);
$label = trim(urldecode($originalLabel));

$sanitizedLabel = Common::sanitizeInputValue($label);
$variations[] = $sanitizedLabel;

if ($this->apiModule == 'Actions'
&& in_array($this->apiMethod, $pageTitleReports)
) {
// temporary workaround for #4363, if a '%20' is at the end of this label, we assume it is a
// terminal label and only check for a terminal row.
if (substr($originalLabel, -3) == '%20') {
if ($isTerminal) {
array_unshift($variations, ' ' . $sanitizedLabel);
array_unshift($variations, ' ' . $label);
} else {
Expand Down
8 changes: 7 additions & 1 deletion core/API/ResponseBuilder.php
Expand Up @@ -295,6 +295,9 @@ protected function handleScalar($scalar)
*/
protected function handleDataTable($datatable)
{
// process request
$label = $this->getLabelFromRequest($this->request);

// if requested, flatten nested tables
if (Common::getRequestVar('flat', '0', 'string', $this->request) == '1') {
$flattener = new Flattener($this->apiModule, $this->apiMethod, $this->request);
Expand All @@ -312,6 +315,10 @@ protected function handleDataTable($datatable)
// if the flag disable_generic_filters is defined we skip the generic filters
if (0 == Common::getRequestVar('disable_generic_filters', '0', 'string', $this->request)) {
$genericFilter = new DataTableGenericFilter($this->request);
if (!empty($label)) {
$genericFilter->disableFilters(array('Limit', 'Truncate'));
}

$genericFilter->filter($datatable);
}

Expand All @@ -332,7 +339,6 @@ protected function handleDataTable($datatable)
}

// apply label filter: only return rows matching the label parameter (more than one if more than one label)
$label = $this->getLabelFromRequest($this->request);
if (!empty($label)) {
$addLabelIndex = Common::getRequestVar('labelFilterAddLabelIndex', 0, 'int', $this->request) == 1;

Expand Down
2 changes: 1 addition & 1 deletion core/ArchiveProcessor.php
Expand Up @@ -337,7 +337,7 @@ protected function aggregateDataTableRecord($name, $columnsAggregationOperation
}

if ($dataTable instanceof Map) {
// see http://dev.piwik.org/trac/ticket/4377
// see https://github.com/piwik/piwik/issues/4377
$self = $this;
$dataTable->filter(function ($table) use ($self, $columnsToRenameAfterAggregation) {
$self->renameColumnsAfterAggregation($table, $columnsToRenameAfterAggregation);
Expand Down
2 changes: 1 addition & 1 deletion core/Common.php
Expand Up @@ -1066,7 +1066,7 @@ public static function getCurrentLocationProviderId()
/**
* Marks an orphaned object for garbage collection.
*
* For more information: {@link http://dev.piwik.org/trac/ticket/374}
* For more information: {@link https://github.com/piwik/piwik/issues/374}
* @param $var The object to destroy.
* @api
*/
Expand Down
2 changes: 2 additions & 0 deletions core/CronArchive.php
Expand Up @@ -12,6 +12,7 @@
use Piwik\ArchiveProcessor\Rules;
use Piwik\CronArchive\FixedSiteIds;
use Piwik\CronArchive\SharedSiteIds;
use Piwik\Period\Factory;
use Piwik\Plugins\CoreAdminHome\API as APICoreAdminHome;
use Piwik\Plugins\SitesManager\API as APISitesManager;

Expand Down Expand Up @@ -1256,6 +1257,7 @@ private function getPeriodsToProcess()
$restrictToPeriods = explode(',', $restrictToPeriods);
$restrictToPeriods = array_map('trim', $restrictToPeriods);
$restrictToPeriods = array_intersect($restrictToPeriods, $this->getDefaultPeriodsToProcess());
$restrictToPeriods = array_intersect($restrictToPeriods, Factory::getPeriodsEnabledForAPI());
return $restrictToPeriods;
}

Expand Down
2 changes: 1 addition & 1 deletion core/DataAccess/ArchiveWriter.php
Expand Up @@ -266,7 +266,7 @@ public function insertRecord($name, $value)

$tableName = $this->getTableNameToInsert($value);

// duplicate idarchives are Ignored, see http://dev.piwik.org/trac/ticket/987
// duplicate idarchives are Ignored, see https://github.com/piwik/piwik/issues/987
$query = "INSERT IGNORE INTO " . $tableName . "
(" . implode(", ", $this->getInsertFields()) . ")
VALUES (?,?,?,?,?,?,?,?)";
Expand Down
2 changes: 1 addition & 1 deletion core/Db/Schema/Mysql.php
Expand Up @@ -408,7 +408,7 @@ public function createTable($nameWithoutPrefix, $createDefinition)
Db::exec($statement);
} catch (Exception $e) {
// mysql code error 1050:table already exists
// see bug #153 http://dev.piwik.org/trac/ticket/153
// see bug #153 https://github.com/piwik/piwik/issues/153
if (!Db::get()->isErrNo($e, '1050')) {
throw $e;
}
Expand Down
6 changes: 4 additions & 2 deletions core/Log.php
Expand Up @@ -386,9 +386,11 @@ private function logToFile($level, $tag, $datetime, $message)
return;
}

if(!file_put_contents($this->logToFilePath, $message, FILE_APPEND)) {
if (!@file_put_contents($this->logToFilePath, $message, FILE_APPEND)
&& !defined('PIWIK_TEST_MODE')
) {
$message = Filechecks::getErrorMessageMissingPermissions($this->logToFilePath);
throw new \Exception( $message );
throw new \Exception($message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/Period/Factory.php
Expand Up @@ -125,7 +125,7 @@ public static function isPeriodEnabledForAPI($period)
/**
* @return array
*/
private static function getPeriodsEnabledForAPI()
public static function getPeriodsEnabledForAPI()
{
$enabledPeriodsInAPI = Config::getInstance()->General['enabled_periods_API'];
$enabledPeriodsInAPI = explode(",", $enabledPeriodsInAPI);
Expand Down
4 changes: 2 additions & 2 deletions core/Plugin/ControllerAdmin.php
Expand Up @@ -102,7 +102,7 @@ static public function displayWarningIfConfigFileNotWritable()
}

/**
* See http://dev.piwik.org/trac/ticket/4439#comment:8 and https://github.com/eaccelerator/eaccelerator/issues/12
* See https://github.com/piwik/piwik/issues/4439#comment:8 and https://github.com/eaccelerator/eaccelerator/issues/12
*
* Eaccelerator does not support closures and is known to be not comptabile with Piwik. Therefore we are disabling
* it automatically. At this point it looks like Eaccelerator is no longer under development and the bug has not
Expand All @@ -125,7 +125,7 @@ private static function notifyIfEAcceleratorIsUsed()
$message = sprintf("You are using the PHP accelerator & optimizer eAccelerator which is known to be not compatible with Piwik.
We have disabled eAccelerator, which might affect the performance of Piwik.
Read the %srelated ticket%s for more information and how to fix this problem.",
'<a target="_blank" href="http://dev.piwik.org/trac/ticket/4439">', '</a>');
'<a target="_blank" href="https://github.com/piwik/piwik/issues/4439">', '</a>');

$notification = new Notification($message);
$notification->context = Notification::CONTEXT_WARNING;
Expand Down
4 changes: 3 additions & 1 deletion core/Tracker/Action.php
Expand Up @@ -106,9 +106,11 @@ static private function getAllActions(Request $request)
}

/**
* Public so that events listener can access it
*
* @var Request
*/
protected $request;
public $request;

private $idLinkVisitAction;
private $actionIdsCached = array();
Expand Down
19 changes: 18 additions & 1 deletion core/Updater.php
Expand Up @@ -360,12 +360,29 @@ public static function executeMigrationQuery($updateSql, $errorToIgnore, $file)
public static function handleQueryError($e, $updateSql, $errorToIgnore, $file)
{
if (($errorToIgnore === false)
|| !Db::get()->isErrNo($e, $errorToIgnore)
|| !self::isDbErrorOneOf($e, $errorToIgnore)
) {
$message = $file . ":\nError trying to execute the query '" . $updateSql . "'.\nThe error was: " . $e->getMessage();
throw new UpdaterErrorException($message);
}
}

/**
* Returns whether an exception is a DB error with a code in the $errorCodesToIgnore list.
*
* @param int $error
* @param int|int[] $errorCodesToIgnore
*/
public static function isDbErrorOneOf($error, $errorCodesToIgnore)
{
$errorCodesToIgnore = is_array($errorCodesToIgnore) ? $errorCodesToIgnore : array($errorCodesToIgnore);
foreach ($errorCodesToIgnore as $code) {
if (Db::get()->isErrNo($error, $code)) {
return true;
}
}
return false;
}
}

/**
Expand Down
14 changes: 7 additions & 7 deletions core/Updates/0.2.10.php
Expand Up @@ -26,27 +26,27 @@ static function getSql()
option_name VARCHAR( 64 ) NOT NULL ,
option_value LONGTEXT NOT NULL ,
PRIMARY KEY ( idoption , option_name )
)' => false,
)' => 1050,

// 0.1.7 [463]
'ALTER IGNORE TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `location_provider` `location_provider` VARCHAR( 100 ) DEFAULT NULL' => '1054',
CHANGE `location_provider` `location_provider` VARCHAR( 100 ) DEFAULT NULL' => 1054,

// 0.1.7 [470]
'ALTER TABLE `' . Common::prefixTable('logger_api_call') . '`
CHANGE `parameter_names_default_values` `parameter_names_default_values` TEXT,
CHANGE `parameter_values` `parameter_values` TEXT,
CHANGE `returned_value` `returned_value` TEXT' => false,
CHANGE `returned_value` `returned_value` TEXT' => array(1054, 1146),
'ALTER TABLE `' . Common::prefixTable('logger_error') . '`
CHANGE `message` `message` TEXT' => false,
CHANGE `message` `message` TEXT' => array(1054, 1146),
'ALTER TABLE `' . Common::prefixTable('logger_exception') . '`
CHANGE `message` `message` TEXT' => false,
CHANGE `message` `message` TEXT' => array(1054, 1146),
'ALTER TABLE `' . Common::prefixTable('logger_message') . '`
CHANGE `message` `message` TEXT' => false,
CHANGE `message` `message` TEXT' => 1054,

// 0.2.2 [489]
'ALTER IGNORE TABLE `' . Common::prefixTable('site') . '`
CHANGE `feedburnerName` `feedburnerName` VARCHAR( 100 ) DEFAULT NULL' => '1054',
CHANGE `feedburnerName` `feedburnerName` VARCHAR( 100 ) DEFAULT NULL' => 1054,
);
}

Expand Down
4 changes: 2 additions & 2 deletions core/Updates/0.2.12.php
Expand Up @@ -23,11 +23,11 @@ static function getSql()
'ALTER TABLE `' . Common::prefixTable('site') . '`
CHANGE `ts_created` `ts_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL' => false,
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
DROP `config_color_depth`' => false,
DROP `config_color_depth`' => 1091,

// 0.2.12 [673]
// Note: requires INDEX privilege
'DROP INDEX index_idaction ON `' . Common::prefixTable('log_action') . '`' => '1091',
'DROP INDEX index_idaction ON `' . Common::prefixTable('log_action') . '`' => 1091,
);
}

Expand Down
2 changes: 1 addition & 1 deletion core/Updates/0.2.13.php
Expand Up @@ -27,7 +27,7 @@ static function getSql()
option_value LONGTEXT NOT NULL ,
autoload TINYINT NOT NULL DEFAULT '1',
PRIMARY KEY ( option_name )
)" => false,
)" => 1050,
);
}

Expand Down
8 changes: 4 additions & 4 deletions core/Updates/0.2.24.php
Expand Up @@ -21,11 +21,11 @@ static function getSql()
{
return array(
'CREATE INDEX index_type_name
ON ' . Common::prefixTable('log_action') . ' (type, name(15))' => false,
ON ' . Common::prefixTable('log_action') . ' (type, name(15))' => 1072,
'CREATE INDEX index_idsite_date
ON ' . Common::prefixTable('log_visit') . ' (idsite, visit_server_date)' => false,
'DROP INDEX index_idsite ON ' . Common::prefixTable('log_visit') => false,
'DROP INDEX index_visit_server_date ON ' . Common::prefixTable('log_visit') => false,
ON ' . Common::prefixTable('log_visit') . ' (idsite, visit_server_date)' => 1072,
'DROP INDEX index_idsite ON ' . Common::prefixTable('log_visit') => 1091,
'DROP INDEX index_visit_server_date ON ' . Common::prefixTable('log_visit') => 1091,
);
}

Expand Down
10 changes: 5 additions & 5 deletions core/Updates/0.2.27.php
Expand Up @@ -22,10 +22,10 @@ static function getSql()
{
$sqlarray = array(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time`' => false,
ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time`' => 1060,
// 0.2.27 [826]
'ALTER IGNORE TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `visit_goal_converted` `visit_goal_converted` TINYINT(1) NOT NULL' => false,
CHANGE `visit_goal_converted` `visit_goal_converted` TINYINT(1) NOT NULL' => 1060,

'CREATE TABLE `' . Common::prefixTable('goal') . "` (
`idsite` int(11) NOT NULL,
Expand All @@ -38,7 +38,7 @@ static function getSql()
`revenue` float NOT NULL,
`deleted` tinyint(4) NOT NULL default '0',
PRIMARY KEY (`idsite`,`idgoal`)
)" => false,
)" => 1050,

'CREATE TABLE `' . Common::prefixTable('log_conversion') . '` (
`idvisit` int(10) unsigned NOT NULL,
Expand All @@ -61,13 +61,13 @@ static function getSql()
`revenue` float default NULL,
PRIMARY KEY (`idvisit`,`idgoal`),
KEY `index_idsite_date` (`idsite`,`visit_server_date`)
)' => false,
)' => 1050,
);

$tables = DbHelper::getTablesInstalled();
foreach ($tables as $tableName) {
if (preg_match('/archive_/', $tableName) == 1) {
$sqlarray['CREATE INDEX index_all ON ' . $tableName . ' (`idsite`,`date1`,`date2`,`name`,`ts_archived`)'] = false;
$sqlarray['CREATE INDEX index_all ON ' . $tableName . ' (`idsite`,`date1`,`date2`,`name`,`ts_archived`)'] = 1072;
}
}

Expand Down

0 comments on commit 3dcf8c3

Please sign in to comment.