diff options
author | Fabian Becker <fabian.becker@uni-tuebingen.de> | 2013-09-30 11:24:06 +0400 |
---|---|---|
committer | Fabian Becker <fabian.becker@uni-tuebingen.de> | 2013-09-30 11:24:06 +0400 |
commit | 43a3b7fdf40071263f1d4853081783fe597bdf7b (patch) | |
tree | 6af3b22c18ba2cb129cd6c11c1d2085b6b638b77 | |
parent | 2b11c2f677d3b468b23fc895bb7691a1a31bc6fe (diff) | |
parent | e2de21361ae1a858e3b339fdb3b040b0429dac4f (diff) |
Merge branch 'master' into registry
-rw-r--r-- | core/DataAccess/ArchiveWriter.php | 43 | ||||
-rw-r--r-- | core/FrontController.php | 7 | ||||
-rw-r--r-- | plugins/Installation/Controller.php | 7 | ||||
-rw-r--r-- | plugins/Live/stylesheets/visitor_profile.less | 2 | ||||
-rw-r--r-- | plugins/Live/templates/_dataTableViz_visitorLog.twig | 14 | ||||
-rw-r--r-- | tests/README.md | 25 |
6 files changed, 72 insertions, 26 deletions
diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php index d3be8a4cce..17f4bff9b5 100644 --- a/core/DataAccess/ArchiveWriter.php +++ b/core/DataAccess/ArchiveWriter.php @@ -52,6 +52,31 @@ class ArchiveWriter $this->dateStart = $this->period->getDateStart(); } + protected function getArchiveLockName() + { + $numericTable = $this->getTableNumeric(); + $dbLockName = "allocateNewArchiveId.$numericTable"; + return $dbLockName; + } + + /** + * @return array + * @throws \Exception + */ + protected function acquireArchiveTableLock() + { + $dbLockName = $this->getArchiveLockName(); + if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) { + throw new Exception("allocateNewArchiveId: Cannot get named lock for table $numericTable."); + } + } + + protected function releaseArchiveTableLock() + { + $dbLockName = $this->getArchiveLockName(); + Db::releaseDbLock($dbLockName); + } + public function getIdArchive() { if ($this->idArchive === false) { @@ -87,14 +112,10 @@ class ArchiveWriter $numericTable = $this->getTableNumeric(); $idSite = $this->idSite; - $db = Db::get(); + $this->acquireArchiveTableLock(); + $locked = self::PREFIX_SQL_LOCK . Common::generateUniqId(); $date = date("Y-m-d H:i:s"); - $dbLockName = "allocateNewArchiveId.$numericTable"; - - if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) { - throw new Exception("allocateNewArchiveId: Cannot get named lock for table $numericTable."); - } $insertSql = "INSERT INTO $numericTable " . " SELECT ifnull(max(idarchive),0)+1, '" . $locked . "', @@ -106,7 +127,7 @@ class ArchiveWriter 0 " . " FROM $numericTable as tb1"; try { // TODO: this is temporary, remove when deadlocking issue is fixed - $db->exec($insertSql); + Db::get()->exec($insertSql); } catch (Exception $ex) { if (Db::get()->isErrNo($ex, 1213)) { $deadlockInfo = \Piwik\Db::fetchAll("SHOW ENGINE INNODB STATUS"); @@ -114,9 +135,9 @@ class ArchiveWriter } throw $ex; } - Db::releaseDbLock($dbLockName); + $this->releaseArchiveTableLock(); $selectIdSql = "SELECT idarchive FROM $numericTable WHERE name = ? LIMIT 1"; - $id = $db->fetchOne($selectIdSql, $locked); + $id = Db::get()->fetchOne($selectIdSql, $locked); return $id; } @@ -155,11 +176,15 @@ class ArchiveWriter protected function deletePreviousArchiveStatus() { + // without advisory lock here, the DELETE would acquire Exclusive Lock + $this->acquireArchiveTableLock(); Db::query("DELETE FROM " . $this->getTableNumeric() . " WHERE idarchive = ? AND (name = '" . $this->doneFlag . "' OR name LIKE '" . self::PREFIX_SQL_LOCK . "%')", array($this->getIdArchive()) ); + + $this->releaseArchiveTableLock(); } protected function logArchiveStatusAsFinal() diff --git a/core/FrontController.php b/core/FrontController.php index 7ec2ada073..c7b895cc2a 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -227,10 +227,11 @@ class FrontController $directoriesToCheck = array( '/tmp/', - '/tmp/templates_c/', - '/tmp/cache/', '/tmp/assets/', - '/tmp/tcpdf/' + '/tmp/cache/', + '/tmp/logs/', + '/tmp/tcpdf/', + '/tmp/templates_c/', ); Filechecks::dieIfDirectoriesNotWritable($directoriesToCheck); diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index 234467f0e0..3c66647838 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -721,12 +721,13 @@ class Controller extends \Piwik\Controller\Admin $directoriesToCheck = array_merge($directoriesToCheck, array( '/tmp/', - '/tmp/templates_c/', - '/tmp/cache/', '/tmp/assets/', + '/tmp/cache/', '/tmp/latest/', - '/tmp/tcpdf/', + '/tmp/logs/', '/tmp/sessions/', + '/tmp/tcpdf/', + '/tmp/templates_c/', )); $infos['directories'] = Filechecks::checkDirectoriesWritable($directoriesToCheck); diff --git a/plugins/Live/stylesheets/visitor_profile.less b/plugins/Live/stylesheets/visitor_profile.less index 1301022b8c..c47acc1186 100644 --- a/plugins/Live/stylesheets/visitor_profile.less +++ b/plugins/Live/stylesheets/visitor_profile.less @@ -197,7 +197,7 @@ } .visitor-profile-os { - width:75px; + width:78px; display:inline-block; } diff --git a/plugins/Live/templates/_dataTableViz_visitorLog.twig b/plugins/Live/templates/_dataTableViz_visitorLog.twig index aa94aa6af3..244b09e5dc 100644 --- a/plugins/Live/templates/_dataTableViz_visitorLog.twig +++ b/plugins/Live/templates/_dataTableViz_visitorLog.twig @@ -4,22 +4,18 @@ <tr> <th style="display:none;"></th> <th id="label" class="sortable label" style="cursor: auto;width:190px;" width="190px"> - <div id="thDIV">{{ 'General_Date'|translate }} - <div> + <div id="thDIV">{{ 'General_Date'|translate }}</div> </th> {% if displayVisitorsInOwnColumn %} <th id="label" class="sortable label" style="cursor: auto;width:225px;" width="225px"> - <div id="thDIV">{{ 'General_Visitors'|translate }} - <div> + <div id="thDIV">{{ 'General_Visitors'|translate }}</div> </th> {% endif %} <th id="label" class="sortable label" style="cursor: auto;width:230px;" width="230px"> - <div id="thDIV">{{ 'Live_Referrer_URL'|translate }} - <div> + <div id="thDIV">{{ 'Live_Referrer_URL'|translate }}</div> </th> <th id="label" class="sortable label" style="cursor: auto;"> - <div id="thDIV">{{ 'General_ColumnNbActions'|translate }} - <div> + <div id="thDIV">{{ 'General_ColumnNbActions'|translate }}</div> </th> </tr> </thead> @@ -134,7 +130,7 @@ GPS (lat/long): {{ visitor.getColumn('latitude') }},{{ visitor.getColumn('longit {% endif %} {% if visitor.getColumn('referrerType') == 'search' %} {%- set keywordNotDefined = 'General_NotDefined'|translate('General_ColumnKeyword'|translate) -%} - {%- set showKeyword = visitor.getColumn('referrerKeyword') is not empty and visitor.getColumn('referrerKeyword') != keywordNotDefined %-} + {%- set showKeyword = visitor.getColumn('referrerKeyword') is not empty and visitor.getColumn('referrerKeyword') != keywordNotDefined -%} {% if visitor.getColumn('searchEngineIcon') %} <img src="{{ visitor.getColumn('searchEngineIcon') }}" alt="{{ visitor.getColumn('referrerName') }}"/> {% endif %} diff --git a/tests/README.md b/tests/README.md index f09999d9a3..5e4f0e3141 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,6 +4,7 @@ This document briefly describes how to use and modify Piwik tests. ## How To Run Piwik Tests To run tests, you must use the Git master. Tests files are not in the Piwik zip archive. + You can get the latest Git revision at: http://github.com/piwik/piwik ``` @@ -15,7 +16,10 @@ To execute the tests: * In your php.ini make sure you have the setting to show all errors: `error_reporting = E_ALL | E_STRICT` - * Go to tests/index.php to see the tests homepage and run the Integration tests via a visual UI, or run JS Tests + * Go to tests/index.php to see the tests homepage + and run the Integration tests via a visual UI, or run JS Tests + + * Next you will need to install PHPUnit ## Integration Tests @@ -75,6 +79,24 @@ Otherwise, if you didn't expect to modify the API outputs, it might be that your 5. Write more tests :) See ["Writing Unit tests with PHPUnit"](http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html) +### PHP 5.5: also update PHPUnit to latest + +See http://phpunit.de/manual/current/en/installation.html +or try: + $ sudo pear install -a phpunit/PHPUnit + +### Troubleshooting + +If you get any of these errors: + * `RuntimeException: Unable to create the cache directory ( piwik/tmp/templates_c/66/77).` + * or `fopen( piwik/tmp/latest/testgz.txt): failed to open stream: No such file or directory` + * or `Exception: Error while creating the file: piwik/tmp/latest/LATEST` + * or `PHP Warning: file_put_contents( piwik/tmp/logs/piwik.test.log): failed to open stream: Permission denied in [..]` + +On your dev server, give your user permissions to write to the directory: + + $ sudo chmod 777 -R piwik/tmp/ + ## JavaScript Tests piwik.js is unit tested and you can run tests via piwik/tests/javascript/ @@ -101,6 +123,7 @@ You should now have some interesting data to test with in November 2012! ## Selenium Webdriver tests We would like to add Webdriver selenium testing for the following: installation, auto update from 1.0, initial user login. + Task is tracked in: http://dev.piwik.org/trac/ticket/2935 ## Scheduled Reports Tests |