PHP error Uncaught Exception: DateTimeZone



  • Dear all,

    I’m making a fresh install based on https://wiki.fogproject.org/wiki/index.php?title=CentOS_7 on fog trunk

    os: centos 7
    php verson : 7
    I try to set up the last version on the git --> git pull last version :)
    What other information you need ?

    Step during the installation:

     * You still need to install/update your database schema.
     * This can be done by opening a web browser and going to:
    
       http://10.10.0.15/fog/management
    
     * Press [Enter] key when database is updated/installed.
    
    

    I go to the following webpage with firefox http://10.10.0.15/fog/management/?node=schemaupdater

    error encountered during the installation in /var/log/httpd/error_log:

    [Mon Mar 14 22:19:28.092636 2016] [:error] [pid 9074] [client 10.10.0.2:49366] PHP Fatal error:  Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone () in /var/www/html/fog/lib/fog/fogbase.class.php:65\nStack trace:
    \n#0 internal function]: DateTimeZone->__construct('')
    \n#1 /var/www/html/fog/lib/fog/fogbase.class.php(65): ReflectionClass->newInstanceArgs(Array)
    \n#2 /var/www/html/fog/lib/fog/fogbase.class.php(233): FOGBase->getClass('DateTimeZone', '')
    \n#3 /var/www/html/fog/lib/fog/fogbase.class.php(469): FOGBase->nice_date()
    \n#4 /var/www/html/fog/lib/fog/eventmanager.class.php(28): FOGBase->log('Method does not...', 0)
    \n#5 /var/www/html/fog/lib/plugins/location/hooks/changeitems.hook.php(58): EventManager->register('HOST_EDIT_AFTER...', Array)
    \n#6 [internal function]: unknown()
    \n#7 /var/www/html/fog/commons/init.php(138): spl_autoload('changeitems')
    \n#8 [internal function]: Initiator->FOGLoader('changeitems')
    \n#9 [internal function]: spl_autoload_call('changeitems')
    \n#10 /var/www/html/fog/lib/fog/fogbase.class.php(63): ReflectionClass->__construct('changeitems')
    \n#11 /var/www/html/fog/lib/fog/eve in /var/www/html/fog/lib/fog/fogbase.class.php on line 65
    

  • Developer

    @kortnor I am marking this solved as the initial OP is now properly handled, thanks Tom!!

    Probably best if you start a new topic if you run into another problem. I am sure we’ll be able to help you fix it as well!


  • Senior Developer

    @kortnor The datetimezone issue should be fixed in the latest update. I wasn’t implicitly defining a Timezone, so it would not find any data in the case of a fresh install.

    I found two places that I could use to ensure the timezone is set (albeit not necessarily accurate) in the case the DB hasn’t been loaded yet (fresh install), the php.ini file does not have a date.timezone specified (php defaults to commenting the timezone out). The fix, for now, is test the presence of the variable by means of checking if it’s empty or not.

    Mind you if the php.ini file IS set with the date timezone setting, it will NOT try to use the one defined in the DB anyway. However, if you aren’t comfortable messing in /etc/php.ini, the current push of FOG should take over and operate as originally expected (no more 500 heres or erroneous error messages.)



  • @Sebastian-Roth
    that’s really interresting, I’ll create a fresh new vm ( aside the my running one, ) and try what’s you’re proposing, I should do that for thursday evening

    In the meantime, I need to learn how to fine tune the images because at the end I would like to apply it on a cluser created with 6 intel nuc.
    On each nuc, I’ll push my images but after every nuc needs to be configurer with a static ip ( for sure different for everyone ) :D


  • Developer

    @kortnor Ahhhh… the “old” mysql package is still newer than the mariadb package (5.5.48 vs 5.5.44). Therefore yum prefers to install the EL6 mysql version instead of using EL7 mariadb.

    yum remove remi-release-6
    rpm -Uvh  http://rpms.remirepo.net/enterprise/remi-release-7.rpm
    yum -y update
    yum --enablerepo=remi list mysql
    


  • @Sebastian-Roth
    i’m using the following package

    [root@fog ~]# rpm -qa | grep -e mysql -e mariadb
    mysql-5.5.48-1.el6.remi.x86_64
    mysql-libs-5.5.48-1.el6.remi.x86_64
    php-mysqlnd-7.0.4-1.el7.remi.x86_64
    mysql-server-5.5.48-1.el6.remi.x86_64
    

    But i can’t use mariadb also and that’s a major threat for me:
    everytime I restart my server host, I need to create the /var/run/mysqld /; touch /var/run/mysqld.pid ; chown -R mysql:mysql /var/run/mysqld
    otherwise mysql won’t start



  • @Sebastian-Roth
    hereunder the result of the requested command line

    [root@fog ~]# yum --enablerepo=remi list mysql
    Loaded plugins: fastestmirror, replace
    Loading mirror speeds from cached hostfile
     * base: ftp.belnet.be
     * epel: ftp.nluug.nl
     * extras: miroir.univ-paris13.fr
     * remi: mirror5.layerjet.com
     * remi-php70: mirror5.layerjet.com
     * remi-safe: mirror5.layerjet.com
     * rpmforge: ftp.nluug.nl
     * updates: miroir.univ-paris13.fr
    Installed Packages
    mysql.x86_64                                   5.5.48-1.el6.remi                                    @remi
    [root@fog ~]# yum --enablerepo=remi list mariadb
    Loaded plugins: fastestmirror, replace
    Loading mirror speeds from cached hostfile
     * base: ftp.belnet.be
     * epel: ftp.nluug.nl
     * extras: miroir.univ-paris13.fr
     * remi: mirror5.layerjet.com
     * remi-php70: mirror5.layerjet.com
     * remi-safe: mirror5.layerjet.com
     * rpmforge: ftp.nluug.nl
     * updates: miroir.univ-paris13.fr
    Available Packages
    mariadb.x86_64                                 1:5.5.44-2.el7.centos                                 base
    

  • Developer

    @kortnor Try running the following commands on your system. Here is what they show on my system (as well CentOS 7 fresh install but installs mariadb):

    $ dnf list --enablerepo=remi mysql
    Using metadata from Tue Mar 15 19:11:26 2016
    Available Packages
    mariadb.x86_64                                   1:5.5.44-2.el7.centos                                   base
    $ yum --enablerepo=remi list mysql
    ...
    Error: No matching Packages to list
    $ yum --enablerepo=remi list mariadb
    ...
    Available Packages
    mariadb.x86_64                                    1:5.5.44-2.el7.centos                                    base
    

    I am wondering why you have mysql el6 packages installed…?!?



  • @Tom-Elliott
    also, After deleting the whole opt/fog directory I suppose the install script reacts like it will be a new installation ==> so creating the folder again.

    Now what I’ve done is:

    • yum remove mariadb*
    • check 2 time if there is no mysql pkg wih ==> yum list installed | grep mysql

    make a new installation again.

    Now I arrived to the fog webui

    for your info the script has installed the following mysql package
    mysql.x86_64 5.5.48-1.el6.remi @remi
    mysql-libs.x86_64 5.5.48-1.el6.remi @remi
    mysql-server.x86_64 5.5.48-1.el6.remi @remi

    now, because mysql is replaced by mariadb , will there be any changed applied to the script when its run to centos 7 or rhel 7 ?

    Best,


  • Developer

    @kortnor On my system I was not able to fully remove the mariadb/mysql packages because mariadb/mysql-libs is needed by some very important system packages. So I am wondering if you somehow managed to install mysql-libs and are not able to get rid of it anymore? rpm -qa | grep -e mysql -e mariadb (just a wild guess)



  • @Sebastian-Roth
    I tried that also :)
    Cleaning setup

    • delete /etc/httpd/conf.d/fog
    • rm -rf /var/www/html/fog
    • rm -rf /opt/fog/
    • fully delete mysql (lke explained before)

    restart install

    • cd /opt/fogGit/
    • git pull
    • cd bin
    • ./installfog.sh

    I don’ think I’m missing something.


  • Senior Developer

    @Sebastian-Roth To add an, if you still want to update, but want dynamic packages, just remove the packages line altogether from the .fogsettings file (while maintaining the file itself.)


  • Developer

    @kortnor Please check your /opt/fog/.fogsettings file. I guess it says:

    ...
    packages='... mysql mysql-server...'
    ...
    

    Forcing the installer to try and install mysql. Just remove the .fogsettings file if you are doing a clean new install anyway - maybe backup if in case you need it later on.



  • @Tom-Elliott
    I’ve noticed ( at least on a fresh installation ) that when I install centos 7 minimal on a vm (virtual box ) that when I restart the vm and I restart the mysqld daemon that he indicates me the mysqld.pid can’t be created because there is not mysqld folder in /var/run

    now i’ve tried to clean the actual centos 7 from mysql meaning by that a yum remove mysql mysql-* and also delete the /var/lib/mysql
    Then Ive installed mariadb ( mariadb-server mariadb-libs mariadb) with yum and configured with :

    after I try a reinstallation of the trunk ( before I make a git pull in order to be sure I’m on the last version ) then I receive the following error

    I would like to know also, if the script detect the specific version of centos family or does he embed it in redhat ( Base linux: Red Hat )

     * Here are the settings FOG will use:
     * Base Linux: Redhat
     * Detected Linux Distribution: CentOS Linux
     * Server IP Address: 10.10.0.15
     * Server Subnet Mask: 255.255.255.0
     * Interface: eth0
     * Installation Type: Normal Server
     * Donate: 0
     * Internationalization: 0
     * Image Storage Location: /images
     * Using FOG DHCP: Yes
     * DHCP router Address: 10.10.0.100
     * DHCP DNS Address: 10.10.0.254
    
    
     * Are you sure you wish to continue (Y/N) Y
    
     * Installation Started
    
     * Installing required packages, if this fails
     | make sure you have an active internet connection.
    
     * Adding needed repository....................................OK
     * Preparing Package Manager...................................OK
     * Packages to be installed:
    
    	httpd php php-cli php-common php-gd mysql mysql-server dhcp tftp-server nfs-utils vsftpd net-tools wget xinetd tar gzip make m4 gcc gcc-c++ lftp php-mysqlnd curl php-mcrypt php-mbstring mod_ssl php-fpm php-process
    
    
     * Skipping package: httpd.....................................(Already Installed)
     * Skipping package: php.......................................(Already Installed)
     * Skipping package: php-cli...................................(Already Installed)
     * Skipping package: php-common................................(Already Installed)
     * Skipping package: php-gd....................................(Already Installed)
     * Installing package: mysql...................................Failed!
    

    log within the error_xxx.log which indicates the script still try to install mysql in place of using the mariadb.

    ransaction Summary
    ================================================================================
    Install  1 Package (+1 Dependent package)
    
    Total download size: 6.5 M
    Installed size: 33 M
    Downloading packages:
    --------------------------------------------------------------------------------
    Total                                              202 kB/s | 6.5 MB  00:33
    Running transaction check
    Running transaction test
    
    
    Transaction check error:
      file /etc/my.cnf from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/lib64/mysql/libmysqlclient.so.18.0.0 from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
      file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.5.48-1.el6.remi.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
    

  • Developer

    I just ran into the same issue - yeah replicated! In /etc/php.ini there is no timezone defined. Lookes like this:

    ...
    [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone
    ;date.timezone =
    ...
    

    Changed it to date.timezone = Europe/Berlin (removed the leading ;) and systemctl restart httpd.service fixed this for me!


  • Senior Developer

    I’m not following.

    CentOS 7 should be using the remi repository (of late it’s been a real pain to try to handle – don’t know why, I just know that it has been.) I’ve updated the code as I did have one error that might prevent the php packages from installing properly. We NEVER want to use 5.4 any more, if we can help it, which is why I started installing the remi repo to begin with.

    The mysql/mysql-server || mariadb/mariadb-server should automatically be chosen properly.

    Don’t know what you mean by:

    @kortnor said:

    I’m wondering if the cause isn’t that now centos 7 has also passed to mariadb and fog should target the mariadb and mariadb-server package
    Am I right?

    Also with mysql 5.4 on centos 7, everytime you restarting your host, the folder /var/run/mysqld and the file /var/run/mysqld/mysqld.pid are disapearing

    The /var/run/mysqld/mysqld.pid are disappearing? What do you mean by this. Normally the /run partition is mounted to a tmpfs space which is essentially loaded into RAM. Those files disappearing shouldn’t impede operation of mysql/mariadb instances though. CentOS 7, by default, installs mariadb even if you call mysql to be installed.



  • I’m wondering if the cause isn’t that now centos 7 has also passed to mariadb and fog should target the mariadb and mariadb-server package
    Am I right?

    Also with mysql 5.4 on centos 7, everytime you restarting your host, the folder /var/run/mysqld and the file /var/run/mysqld/mysqld.pid are disapearing



  • @Tom-Elliott

    ok, then where can I find this information? or better is the mysql procedure handeled with the root user or with the fog user? like fog is creating the stuff on it

    also I don’t see anything strange in the mysqld.log neither in the foginstall.log

    EDIT

    indeed there is another error

    [Mon Mar 14 23:00:08.367265 2016] [:error] [pid 5160] [client 10.10.0.2:50430] PHP Warning:  mysqli::real_connect(): MySQL server has gone away in /var/www/html/fog/lib/db/mysql.class.php on line 30
    

    EDIT 2:
    WHen I restart the install
    the script fails on backing up database
    however there are no database fog in mysql ( show databases )


  • Senior Developer

    @kortnor What I mean is the errors you’re seeing, the http error log, will have somewhere before the start of the datetimezone stuff, mysql unable to be logged into. The backing up database code is not a real good indicator as it’s using the data but not properly “failing”. THe DB Backup file will likely be 0 bytes.



  • @Tom-Elliott
    hm good question hereunder the print out of the installation

     * Configuring services
    
     * Setting up fog user.........................................Already setup
     * Setting up fog password.....................................OK
     * Stopping FOGMulticastManager.service Service................OK
     * Stopping FOGImageReplicator.service Service.................OK
     * Stopping FOGSnapinReplicator.service Service................OK
     * Stopping FOGScheduler.service Service.......................OK
     * Stopping FOGPingHosts.service Service.......................OK
     * Setting up and starting MySQL...............................OK
     * Backing up user reports.....................................OK
     * Stopping web service........................................OK
     * Removing vhost file.........................................OK
     * Is the MySQL password blank? (Y/n) Y
     * Setting up Apache and PHP files.............................OK
     * Testing and removing symbolic links if found................OK
     * Backing up old data.........................................OK
     * Copying new files to web folder.............................OK
     * Creating config file........................................OK
     * Getting checksum files for kernels and inits................OK
     * Downloading inits, kernels, and the fog client..............OK
     * Comparing checksums of kernels and inits....................Done
     * Enabling apache and fpm services on boot....................OK
     * Creating SSL CA.............................................OK
     * Creating SSL Private Key....................................OK
     * Creating SSL Certificate....................................OK
     * Creating auth pub key and cert..............................OK
     * Resetting SSL Permissions...................................OK
     * Setting up SSL FOG Server...................................OK
     * Restarting Apache2 for fog vhost............................OK
     * Changing permissions on apache log files....................OK
     * Backing up database.........................................OK
    
    

    EDIT I check on mysql and i can connect with root without any password and here is no fog databases in it


Log in to reply
 

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.