fix warnings, if headers are already sent, eg. in phpUnit/Travis

This commit is contained in:
Ralf Becker 2020-03-05 10:23:29 +01:00
parent 5e592b09a1
commit 5154bc2f70
2 changed files with 28 additions and 24 deletions

View File

@ -41,12 +41,9 @@ before_script:
# configure apache virtual hosts # configure apache virtual hosts
- sudo cp -f doc/travis-ci-apache.conf /etc/apache2/sites-available/000-default.conf - sudo cp -f doc/travis-ci-apache.conf /etc/apache2/sites-available/000-default.conf
- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
# remove .htaccess as it is read by Apache, but content is for mod_php
- rm -f .htaccess - rm -f .htaccess
- sudo service apache2 restart - sudo service apache2 restart
- curl -i http://localhost/doc/rpm-build/debian.changes
- sudo tail /var/log/apache2/error.log
- curl -i http://localhost/egroupware/doc/rpm-build/debian.changes
- sudo tail /var/log/apache2/error.log
- php -m - php -m
- php -i - php -i
- php install-cli.php --ignore-platform-reqs - php install-cli.php --ignore-platform-reqs
@ -59,7 +56,7 @@ script:
# install egroupware using MariaDB as domain "default" # install egroupware using MariaDB as domain "default"
# and add an admin user "demo" with password "guest" # and add an admin user "demo" with password "guest"
- php doc/rpm-build/post_install.php --domain default - php doc/rpm-build/post_install.php --domain default
--source_dir `pwd` --start_db '' --autostart_db '' --start_webserver '' --webserver_user '' --source_dir `pwd` --start_db '' --autostart_db '' --start_webserver '' --autostart_webserver='' --webserver_user ''
--admin_user demo --admin_passwd guest --admin_email noreply@example.com --admin_user demo --admin_passwd guest --admin_email noreply@example.com
# disable PostgreSQL install as it fails in Travis with Fatal error: Call to unimplemented native function pg_set_client_encoding # disable PostgreSQL install as it fails in Travis with Fatal error: Call to unimplemented native function pg_set_client_encoding
# install egroupware using PostgreSQL as domain "pgsql", need some specific handling we can not create users via sql # install egroupware using PostgreSQL as domain "pgsql", need some specific handling we can not create users via sql
@ -72,7 +69,6 @@ script:
#- php doc/rpm-build/post_install.php --domain ldap --db_name ldap --db_user ldap #- php doc/rpm-build/post_install.php --domain ldap --db_name ldap --db_user ldap
# --account-auth ldap --ldap_suffix dc=local --ldap_admin 'cn=admin,$suffix' --ldap_admin_pw secret # --account-auth ldap --ldap_suffix dc=local --ldap_admin 'cn=admin,$suffix' --ldap_admin_pw secret
# --source_dir `pwd` --start_db '' --autostart_db '' --start_webserver '' --webserver_user '' # --source_dir `pwd` --start_db '' --autostart_db '' --start_webserver '' --webserver_user ''
- curl -i http://localhost/egroupware/groupdav.php/
# Ubuntu has problems with #!/usr/bin/env php -dapc.enable=1, it stalls forever # Ubuntu has problems with #!/usr/bin/env php -dapc.enable=1, it stalls forever
- vendor/bin/phpunit -c doc -dapc.enable_cli=1 - vendor/bin/phpunit -c doc -dapc.enable_cli=1
# do not run syntax check for hhvm, as it always fails / get terminated after 10m # do not run syntax check for hhvm, as it always fails / get terminated after 10m

View File

@ -555,7 +555,7 @@ class Session
session_id($this->sessionid); session_id($this->sessionid);
} }
} }
else elseif (!headers_sent()) // only gives warnings, nothing we can do
{ {
self::cache_control(); self::cache_control();
session_start(); session_start();
@ -566,6 +566,10 @@ class Session
} }
$this->sessionid = session_id(); $this->sessionid = session_id();
} }
else
{
$this->sessionid = session_id() ?: Auth::randomstring(24);
}
$this->kp3 = Auth::randomstring(24); $this->kp3 = Auth::randomstring(24);
$GLOBALS['egw_info']['user'] = $this->read_repositories(); $GLOBALS['egw_info']['user'] = $this->read_repositories();
@ -644,6 +648,8 @@ class Session
} }
$GLOBALS['egw']->db->transaction_commit(); $GLOBALS['egw']->db->transaction_commit();
if (!headers_sent())
{
if ($GLOBALS['egw_info']['server']['usecookies'] && !$no_session) if ($GLOBALS['egw_info']['server']['usecookies'] && !$no_session)
{ {
self::egw_setcookie(self::EGW_SESSION_NAME, $this->sessionid); self::egw_setcookie(self::EGW_SESSION_NAME, $this->sessionid);
@ -664,6 +670,8 @@ class Session
} }
if (self::ERROR_LOG_DEBUG) error_log(__METHOD__ . "($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid"); if (self::ERROR_LOG_DEBUG) error_log(__METHOD__ . "($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid");
}
elseif (self::ERROR_LOG_DEBUG) error_log(__METHOD__ . "($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) could NOT set session cookies, headers already sent");
// hook called once session is created // hook called once session is created
Hooks::process(array( Hooks::process(array(