Skip to content

Commit

Permalink
Merge branch 'master' into DeviceDetectorIntegration
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Apr 3, 2014
2 parents 7a98bec + 644b63f commit e380ce2
Show file tree
Hide file tree
Showing 64 changed files with 1,226 additions and 656 deletions.
4 changes: 4 additions & 0 deletions config/global.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
; Allow automatic upgrades to Beta or RC releases
allow_upgrades_to_beta = 0

; Set to 1 by default. If you set to 0, the standalone plugins (with their own git repositories)
; will not be loaded when executing tests.
enable_load_standalone_plugins_during_tests = 1

[General]
; the following settings control whether Unique Visitors will be processed for different period types.
; year and range periods are disabled by default, to ensure optimal performance for high traffic Piwik instances
Expand Down
8 changes: 2 additions & 6 deletions core/API/ResponseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*/
class ResponseBuilder
{
const DISPLAY_BACKTRACE_DEBUG = false;

private $request = null;
private $outputFormat = null;

Expand Down Expand Up @@ -162,12 +160,10 @@ protected function decorateExceptionWithDebugTrace(Exception $e)
{
// If we are in tests, show full backtrace
if (defined('PIWIK_PATH_TEST_TO_ROOT')) {
if (self::DISPLAY_BACKTRACE_DEBUG
|| \Piwik_ShouldPrintBackTraceWithMessage()
) {
if (\Piwik_ShouldPrintBackTraceWithMessage()) {
$message = $e->getMessage() . " in \n " . $e->getFile() . ":" . $e->getLine() . " \n " . $e->getTraceAsString();
} else {
$message = $e->getMessage() . "\n \n --> To temporarily debug this error further, set const DISPLAY_BACKTRACE_DEBUG=true; in " . basename(__FILE__);
$message = $e->getMessage() . "\n \n --> To temporarily debug this error further, set const PIWIK_PRINT_ERROR_BACKTRACE=true; in index.php";
}
return new Exception($message);
}
Expand Down
35 changes: 0 additions & 35 deletions core/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,6 @@ public function setSuperUserAccess($bool = true)
}
}

/**
* @see Access::setSuperUserAccess()
* @deprecated deprecated since version 2.0.4
*/
public function setSuperUser($bool = true)
{
self::setSuperUserAccess($bool);
}

/**
* Returns true if the current user is logged in as the Super User
*
Expand All @@ -264,15 +255,6 @@ public function hasSuperUserAccess()
return $this->hasSuperUserAccess;
}

/**
* @see Access::hasSuperUserAccess()
* @deprecated deprecated since version 2.0.4
*/
public function isSuperUser()
{
return $this->hasSuperUserAccess();
}

/**
* Returns the current user login
*
Expand Down Expand Up @@ -314,14 +296,6 @@ protected function getAnySuperUserAccessLogin()
return $firstSuperUser['login'];
}

/**
* @deprecated deprecated since version 2.0.4
*/
public function getSuperUserLogin()
{
return $this->getAnySuperUserAccessLogin();
}

/**
* Returns an array of ID sites for which the user has at least a VIEW access.
* Which means VIEW or ADMIN or SUPERUSER.
Expand Down Expand Up @@ -377,15 +351,6 @@ public function checkUserHasSuperUserAccess()
}
}

/**
* @see Access::checkUserHasSuperUserAccess()
* @deprecated deprecated since version 2.0.4
*/
public function checkUserIsSuperUser()
{
self::checkUserHasSuperUserAccess();
}

/**
* If the user doesn't have an ADMIN access for at least one website, throws an exception
*
Expand Down
2 changes: 1 addition & 1 deletion core/ArchiveProcessor/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private static function getSegmentsToProcess($idSites)
return $segmentsToProcess;
}

private static function getDoneFlagArchiveContainsOnePlugin(Segment $segment, $plugin, $isSkipAggregationOfSubTables = false)
public static function getDoneFlagArchiveContainsOnePlugin(Segment $segment, $plugin, $isSkipAggregationOfSubTables = false)
{
$partial = self::isFlagArchivePartial($plugin, $isSkipAggregationOfSubTables);
return 'done' . $segment->getHash() . '.' . $plugin . $partial ;
Expand Down
6 changes: 3 additions & 3 deletions core/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ private function getDefaultPiwikCommands()
$commands = array(
'Piwik\CliMulti\RequestCommand'
);

if (class_exists('Piwik\Plugins\CloudAdmin\CloudAdmin')) {
$extra = new \Piwik\Plugins\CloudAdmin\CloudAdmin();
if (class_exists('Piwik\Plugins\EnterpriseAdmin\EnterpriseAdmin')) {
$extra = new \Piwik\Plugins\EnterpriseAdmin\EnterpriseAdmin();
$extra->addConsoleCommands($commands);
}
return $commands;
Expand Down
10 changes: 8 additions & 2 deletions core/CronArchive.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ private function archiveVisitsAndSegments($idsite, $period, $lastTimestampWebsit

$url .= self::APPEND_TO_API_REQUEST;

$visitsInLastPeriods = 0;
$visitsInLastPeriods = $visitsLastPeriod = 0;
$success = true;

$urls = array();
Expand Down Expand Up @@ -1122,12 +1122,18 @@ private function logFatalErrorUrlExpected()

private function getVisitsLastPeriodFromApiResponse($stats)
{
if(empty($stats)) {
return 0;
}
$today = end($stats);
return $today['nb_visits'];
}

private function getVisitsFromApiResponse($stats)
{
if(empty($stats)) {
return 0;
}
$visits = 0;
foreach($stats as $metrics) {
if(empty($metrics['nb_visits'])) {
Expand Down Expand Up @@ -1200,7 +1206,7 @@ public function __construct($message, $fullOutput = null)
$this->fullOutput = $fullOutput;
}

public function logAndExit($cronArchiver)
public function logAndExit(CronArchive$cronArchiver)
{
if ($cronArchiver->isCoreInited()) {
$cronArchiver->logError($this->getMessage());
Expand Down
18 changes: 18 additions & 0 deletions core/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,24 @@ static public function dropTables($tables)
return self::query("DROP TABLE " . implode(',', $tables));
}

/**
* Get columns information from table
*
* @param string|array $table The name of the table you want to get the columns definition for.
* @return \Zend_Db_Statement
*/
static public function getColumnNamesFromTable($table)
{
$columns = self::fetchAll("SHOW COLUMNS FROM " . $table);

$columnNames = array();
foreach ($columns as $column) {
$columnNames[] = $column['Field'];
}

return $columnNames;
}

/**
* Locks the supplied table or tables.
*
Expand Down
31 changes: 1 addition & 30 deletions core/Db/Schema/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,6 @@ public function getTablesCreateSql()
location_city varchar(255) DEFAULT NULL,
location_latitude float(10, 6) DEFAULT NULL,
location_longitude float(10, 6) DEFAULT NULL,
custom_var_k1 VARCHAR(200) DEFAULT NULL,
custom_var_v1 VARCHAR(200) DEFAULT NULL,
custom_var_k2 VARCHAR(200) DEFAULT NULL,
custom_var_v2 VARCHAR(200) DEFAULT NULL,
custom_var_k3 VARCHAR(200) DEFAULT NULL,
custom_var_v3 VARCHAR(200) DEFAULT NULL,
custom_var_k4 VARCHAR(200) DEFAULT NULL,
custom_var_v4 VARCHAR(200) DEFAULT NULL,
custom_var_k5 VARCHAR(200) DEFAULT NULL,
custom_var_v5 VARCHAR(200) DEFAULT NULL,
PRIMARY KEY(idvisit),
INDEX index_idsite_config_datetime (idsite, config_id, visit_last_action_time),
INDEX index_idsite_datetime (idsite, visit_last_action_time),
Expand Down Expand Up @@ -264,16 +254,6 @@ public function getTablesCreateSql()
revenue_shipping float default NULL,
revenue_discount float default NULL,
custom_var_k1 VARCHAR(200) DEFAULT NULL,
custom_var_v1 VARCHAR(200) DEFAULT NULL,
custom_var_k2 VARCHAR(200) DEFAULT NULL,
custom_var_v2 VARCHAR(200) DEFAULT NULL,
custom_var_k3 VARCHAR(200) DEFAULT NULL,
custom_var_v3 VARCHAR(200) DEFAULT NULL,
custom_var_k4 VARCHAR(200) DEFAULT NULL,
custom_var_v4 VARCHAR(200) DEFAULT NULL,
custom_var_k5 VARCHAR(200) DEFAULT NULL,
custom_var_v5 VARCHAR(200) DEFAULT NULL,
PRIMARY KEY (idvisit, idgoal, buster),
UNIQUE KEY unique_idsite_idorder (idsite, idorder),
INDEX index_idsite_datetime ( idsite, server_time )
Expand All @@ -293,16 +273,7 @@ public function getTablesCreateSql()
idaction_event_category INTEGER(10) UNSIGNED DEFAULT NULL,
idaction_event_action INTEGER(10) UNSIGNED DEFAULT NULL,
time_spent_ref_action INTEGER(10) UNSIGNED NOT NULL,
custom_var_k1 VARCHAR(200) DEFAULT NULL,
custom_var_v1 VARCHAR(200) DEFAULT NULL,
custom_var_k2 VARCHAR(200) DEFAULT NULL,
custom_var_v2 VARCHAR(200) DEFAULT NULL,
custom_var_k3 VARCHAR(200) DEFAULT NULL,
custom_var_v3 VARCHAR(200) DEFAULT NULL,
custom_var_k4 VARCHAR(200) DEFAULT NULL,
custom_var_v4 VARCHAR(200) DEFAULT NULL,
custom_var_k5 VARCHAR(200) DEFAULT NULL,
custom_var_v5 VARCHAR(200) DEFAULT NULL,
custom_float FLOAT NULL DEFAULT NULL,
PRIMARY KEY(idlink_va),
INDEX index_idvisit(idvisit),
Expand Down
11 changes: 9 additions & 2 deletions core/Menu/MenuAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,17 @@ private function applyEdits()
$mainMenuToEdit = $edit[0];
$subMenuToEdit = $edit[1];
$newUrl = $edit[2];
if (!isset($this->menu[$mainMenuToEdit][$subMenuToEdit])) {

if ($subMenuToEdit === null) {
$menuDataToEdit = @$this->menu[$mainMenuToEdit];
} else {
$menuDataToEdit = @$this->menu[$mainMenuToEdit][$subMenuToEdit];
}

if (empty($menuDataToEdit)) {
$this->buildMenuItem($mainMenuToEdit, $subMenuToEdit, $newUrl);
} else {
$this->menu[$mainMenuToEdit][$subMenuToEdit]['_url'] = $newUrl;
$menuDataToEdit['_url'] = $newUrl;
}
}
}
Expand Down
78 changes: 9 additions & 69 deletions core/Piwik.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,16 @@ static public function getJavascriptCode($idSite, $piwikUrl, $mergeSubdomains =
* this event to customise the JavaScript tracking code that is displayed to the
* user.
*
* @param array $codeImpl An array containing snippets of code that the event handler
* can modify. Will contain the following elements:
* @param array &$codeImpl An array containing snippets of code that the event handler
* can modify. Will contain the following elements:
*
* - **idSite**: The ID of the site being tracked.
* - **piwikUrl**: The tracker URL to use.
* - **options**: A string of JavaScript code that customises
* the JavaScript tracker.
* - **idSite**: The ID of the site being tracked.
* - **piwikUrl**: The tracker URL to use.
* - **options**: A string of JavaScript code that customises
* the JavaScript tracker.
*
* The **httpsPiwikUrl** element can be set if the HTTPS
* domain is different from the normal domain.
* The **httpsPiwikUrl** element can be set if the HTTPS
* domain is different from the normal domain.
* @param array $parameters The parameters supplied to the `Piwik::getJavascriptCode()`.
*/
self::postEvent('Piwik.getJavascriptCode', array(&$codeImpl, $parameters));
Expand Down Expand Up @@ -257,22 +257,6 @@ static public function getCurrentUserEmail()
return $user['email'];
}

/**
* @deprecated deprecated since version 2.0.4
*/
static public function getSuperUserLogin()
{
return Access::getInstance()->getSuperUserLogin();
}

/**
* @deprecated deprecated since version 2.0.4
*/
static public function getSuperUserEmail()
{
return '';
}

/**
* Get a list of all email addresses having Super User access.
*
Expand Down Expand Up @@ -335,24 +319,6 @@ static public function hasUserSuperUserAccessOrIsTheUser($theUser)
}
}

/**
* @see Piwik::hasUserSuperUserAccessOrIsTheUser()
* @deprecated deprecated since version 2.0.4
*/
static public function isUserIsSuperUserOrTheUser($theUser)
{
return self::hasUserSuperUserAccessOrIsTheUser($theUser);
}

/**
* @see Piwik::checkUserHasSuperUserAccessOrIsTheUser()
* @deprecated deprecated since version 2.0.4
*/
static public function checkUserIsSuperUserOrTheUser($theUser)
{
self::checkUserHasSuperUserAccessOrIsTheUser($theUser);
}

/**
* Check that the current user is either the specified user or the superuser.
*
Expand Down Expand Up @@ -404,14 +370,6 @@ static public function hasTheUserSuperUserAccess($theUser)
return false;
}

/**
* @see Piwik::hasUserSuperUserAccess()
* @deprecated deprecated since version 2.0.4
*/
static public function isUserIsSuperUser()
{
return self::hasUserSuperUserAccess();
}

/**
* Returns true if the current user has Super User access.
Expand Down Expand Up @@ -464,24 +422,6 @@ static public function setUserHasSuperUserAccess($bool = true)
Access::getInstance()->setSuperUserAccess($bool);
}

/**
* @see Piwik::setUserHasSuperUserAccess()
* @deprecated deprecated since version 2.0.4
*/
static public function setUserIsSuperUser($bool = true)
{
self::setUserHasSuperUserAccess($bool);
}

/**
* @see Piwik::checkUserHasSuperUserAccess()
* @deprecated deprecated since version 2.0.4
*/
static public function checkUserIsSuperUser()
{
self::checkUserHasSuperUserAccess();
}

/**
* Check that the current user has superuser access.
*
Expand Down Expand Up @@ -889,7 +829,7 @@ protected static function getJavascriptTagOptions($idSite, $mergeSubdomains, $me
}
$options = '';
if ($mergeSubdomains && !empty($websiteHosts)) {
$options .= PHP_EOL . ' _paq.push(["setCookieDomain", "*.' . $websiteHosts[0] . '"]);' . PHP_EOL;
$options .= ' _paq.push(["setCookieDomain", "*.' . $websiteHosts[0] . '"]);' . PHP_EOL;
}
if ($mergeAliasUrls && !empty($websiteHosts)) {
$urls = '["*.' . implode('","*.', $websiteHosts) . '"]';
Expand Down
Loading

0 comments on commit e380ce2

Please sign in to comment.