Skip to content
Snippets Groups Projects
Commit 1dc17c4e authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Don't set cookies or cookie options when running in CLI. (#1279)

Otherwise Zend\Session\Config\SessionConfig::setStorageOption() throws an exception when it tries to call ini_set with session-specific settings. This would have happened at least when creating a \Zend\Session\Container.
parent 5036cda3
Branches
Tags
No related merge requests found
...@@ -163,8 +163,8 @@ class CookieManager ...@@ -163,8 +163,8 @@ class CookieManager
*/ */
public function proxySetCookie() public function proxySetCookie()
{ {
// Special case: in test suite -- don't actually write headers! // Special case: in test suite or CLI -- don't actually write headers!
return defined('VUFIND_PHPUNIT_RUNNING') return defined('VUFIND_PHPUNIT_RUNNING') || 'cli' === PHP_SAPI
? true : call_user_func_array('setcookie', func_get_args()); ? true : call_user_func_array('setcookie', func_get_args());
} }
......
...@@ -54,11 +54,12 @@ class ManagerFactory implements FactoryInterface ...@@ -54,11 +54,12 @@ class ManagerFactory implements FactoryInterface
protected function getOptions(ContainerInterface $container) protected function getOptions(ContainerInterface $container)
{ {
$cookieManager = $container->get('VuFind\Cookie\CookieManager'); $cookieManager = $container->get('VuFind\Cookie\CookieManager');
$options = [ // Set options only if we are not running from CLI
$options = 'cli' !== PHP_SAPI ? [
'cookie_httponly' => $cookieManager->isHttpOnly(), 'cookie_httponly' => $cookieManager->isHttpOnly(),
'cookie_path' => $cookieManager->getPath(), 'cookie_path' => $cookieManager->getPath(),
'cookie_secure' => $cookieManager->isSecure() 'cookie_secure' => $cookieManager->isSecure()
]; ] : [];
$domain = $cookieManager->getDomain(); $domain = $cookieManager->getDomain();
if (!empty($domain)) { if (!empty($domain)) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment