diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2019-09-23 00:01:09 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2019-09-23 00:01:09 +0300 |
commit | 83e025eede225579ce3120d3620f812fb037b3b2 (patch) | |
tree | 9e424d86ea94123d0793eaf5abb7f7b43ba55332 /tests/resources | |
parent | 6db4698f572d6500d461e5d2fca565dcf1e12932 (diff) |
If session was already started, do not start it again (#14896)
* If session was already started, do not start it again
refs https://github.com/matomo-org/matomo/issues/12963
refs https://forum.matomo.org/t/an-error-occurred/32500
* Update Session.php
* Update bootstrap.php
* add test
Diffstat (limited to 'tests/resources')
-rw-r--r-- | tests/resources/sessionStarter.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/resources/sessionStarter.php b/tests/resources/sessionStarter.php new file mode 100644 index 0000000000..48a4954934 --- /dev/null +++ b/tests/resources/sessionStarter.php @@ -0,0 +1,32 @@ +<?php +/** + * This php file is used to unit test Piwik::serverStaticFile() + * To make a comprehensive test suit for Piwik::serverStaticFile() (ie. being able to test combinations of request + * headers, being able to test response headers and so on) we need to simulate static file requests in a controlled + * environment + * The php code which simulates requests using Piwik::serverStaticFile() is provided in the same file (ie. this one) + * as the unit testing code for Piwik::serverStaticFile() + * This decision has a structural impact on the usual unit test file structure + * serverStaticFile.test.php has been created to avoid making too many modifications to /tests/core/Piwik.test.php + */ +use Piwik\FrontController; +session_start(); // matomo should not fail if session was started by someone else +define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__).'/../../'); +if(file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) { + require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php'; +} +if (!defined('PIWIK_INCLUDE_PATH')) { + define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT); +} + +require_once PIWIK_INCLUDE_PATH . '/core/bootstrap.php'; + +$environment = new \Piwik\Application\Environment(null); +try { + $environment->init(); +} catch(\Piwik\Exception\NotYetInstalledException $e) { + die($e->getMessage()); +} +FrontController::getInstance()->init(); + +echo 'ok';
\ No newline at end of file |