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:
authorrobocoder <anthon.pang@gmail.com>2010-12-19 20:55:50 +0300
committerrobocoder <anthon.pang@gmail.com>2010-12-19 20:55:50 +0300
commit9414694ad3974b5709b5b7e8be2d862efc14f05f (patch)
tree693b64e42409f6c888c9793867fe1d1843774e8b /core
parent21b2d996bdd82acc704c8a103143c43825695694 (diff)
fixes #1901, refs #1592 - we can't use mock objects because of static method calls, so the wrappers around Zend_Session and Zend_Session_Namespace dummy initialize when executing from php-cli or headless php-cgi; this also addresses the hack by Parallels in their APS scripts
git-svn-id: http://dev.piwik.org/svn/trunk@3468 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core')
-rw-r--r--core/Nonce.php4
-rw-r--r--core/Session.php7
-rw-r--r--core/Session/Namespace.php30
3 files changed, 38 insertions, 3 deletions
diff --git a/core/Nonce.php b/core/Nonce.php
index 7ef98d8878..55888ef137 100644
--- a/core/Nonce.php
+++ b/core/Nonce.php
@@ -35,7 +35,7 @@ class Piwik_Nonce
static public function getNonce($id, $ttl = 300)
{
// save session-dependent nonce
- $ns = new Zend_Session_Namespace($id);
+ $ns = new Piwik_Session_Namespace($id);
$nonce = $ns->nonce;
// re-use an unexpired nonce (a small deviation from the "used only once" principle, so long as we do not reset the expiration)
@@ -60,7 +60,7 @@ class Piwik_Nonce
*/
static public function verifyNonce($id, $cnonce)
{
- $ns = new Zend_Session_Namespace($id);
+ $ns = new Piwik_Session_Namespace($id);
$nonce = $ns->nonce;
// validate token
diff --git a/core/Session.php b/core/Session.php
index 0874311434..ea56cb38ab 100644
--- a/core/Session.php
+++ b/core/Session.php
@@ -17,8 +17,13 @@
*/
class Piwik_Session extends Zend_Session
{
- public static function start($options = false)
+ public static function start($options = false)
{
+ if(Piwik_Common::isPhpCliMode())
+ {
+ return;
+ }
+
// use cookies to store session id on the client side
@ini_set('session.use_cookies', '1');
diff --git a/core/Session/Namespace.php b/core/Session/Namespace.php
new file mode 100644
index 0000000000..919928298d
--- /dev/null
+++ b/core/Session/Namespace.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ * @version $Id$
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+
+/**
+ * Session namespace.
+ *
+ * @package Piwik
+ */
+class Piwik_Session_Namespace extends Zend_Session_Namespace
+{
+ public function __construct($namespace = 'Default', $singleInstance = false)
+ {
+ if(Piwik_Common::isPhpCliMode())
+ {
+ self::$_readable = true;
+ return;
+ }
+
+ parent::__construct($namespace, $singleInstance);
+ }
+}