Bug 19625 - php-ini updates offer rpmnew in rpmdrake. The wrong answer breaks zoneminder.
Summary: php-ini updates offer rpmnew in rpmdrake. The wrong answer breaks zoneminder.
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: PHP Stack Maintainers
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-19 19:18 CEST by Barry Jackson
Modified: 2018-11-20 00:07 CET (History)
2 users (show)

See Also:
Source RPM: php-ini
CVE:
Status comment:


Attachments
index.php (8.83 KB, text/plain)
2018-11-19 22:57 CET, Barry Jackson
Details

Description Barry Jackson 2016-10-19 19:18:42 CEST
Description of problem:
Every update to php-ini offers the user the chance to "use rpmnew" for php.ini.
If selected this breaks ZoneMinder by removing the "date.timezone" entry in php.ini which is essential for it to run.

I think that date.timezone should be set automatically on install of php according to the locale, and users should not be given the opportunity to shoot themselves in the foot in rpmdrake.

Our ZoneMinder setup script does check for and create the php.ini date.timezone entry on installation if it is missing, but it can't protect users from accepting rpmnew.
 
Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
Comment 1 Marja Van Waes 2016-10-19 22:09:35 CEST
Assigning to all packagers collectively, since there is no registered maintainer for this package.

CC: (none) => marja11
Assignee: bugsquad => pkg-bugs

Comment 2 David Walser 2016-10-21 01:10:14 CEST
This isn't so much an rpmdrake problem as an upstream problem.  PHP used to read the timezone from the system.  Then upstream decided at one point to stop doing that and force you to have to set the variable in php.ini.  This was frankly a stupid regression.  Furthermore, we really need software to stop relying on a huge configuration file that you're supposed to edit.  They should either use two files (one with defaults and one with local settings) or a php.ini.d directory with drop-ins where you can store your local changes without editing a package-owned file.  Ideally, config(noreplace) files shouldn't be a thing.
Comment 3 Barry Jackson 2016-10-21 14:50:53 CEST
This looks interesting:
http://php.net/manual/en/configuration.changes.modes.php
Comment 4 Marc Krämer 2017-10-31 13:38:34 CET
@David: I think the main problem of having a user-specific config is already solved:
the /etc/php.d dir is scanned for config settings. 
First we only have to create these files on install but we can leave them as they are.

With this directiv it should be easy to have user settings in php.d and leave php.ini untouched.

CC: (none) => mageia

Comment 5 Marja Van Waes 2017-12-03 21:27:37 CET
(In reply to Marja van Waes from comment #1)
> Assigning to all packagers collectively, since there is no registered
> maintainer for this package.

I should have assigned this bug to the php maintainer group instead.

Assignee: pkg-bugs => php

Comment 6 Marc Krämer 2018-01-04 02:28:22 CET
Splitted the ini file into separate files. This should make updates more comfortable and can prevent this error.

Resolution: (none) => FIXED
Status: NEW => RESOLVED

Comment 7 Barry Jackson 2018-11-07 00:30:17 CET
(In reply to Marc Krämer from comment #6)
> Splitted the ini file into separate files. This should make updates more
> comfortable and can prevent this error.

So we now have /etc/php.d/*.ini files which take precedence over anything  in php.ini? Is that correct?

Why are random lat/long and azimuth etc. values already written in /etc/php.d/05date.ini when the date.timezone is blank? They are not from my location.


I just tried to install zoneminder in cauldron and there was an apparently invalid entry in php.ini of date.timezone=GB:: I have no idea where it came from but it broke the set up, as the zmsetup script assumes that if there is an entry for date.timezone then it will be valid.

I will update zmsetup to ignore php.ini and look for an entry in /etc/php.d/05date.ini and if it's missing, write a valid one from the system.
Comment 8 Marc Krämer 2018-11-08 22:56:29 CET
jepp, that is correct.
Comment 9 Barry Jackson 2018-11-09 00:47:09 CET
Thanks,
I still get 'invalid timezone' error from zoneminder with "Europe/London" in /etc/php.d/05date.ini  :\

I will try to figure out how it arrives at this conclusion.
Comment 10 Barry Jackson 2018-11-09 01:04:59 CET
Here is the php code that checks for a valid date.timezone

// Check time zone is set
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone'))) {
  date_default_timezone_set('UTC');
  Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" );
}

Any clues as to why this fails in current cauldron.
It is the same code in Mga6 zoneminder with "Europe/London" which is working fine.
Comment 11 Marc Krämer 2018-11-09 15:02:57 CET
nope, it works fine for me.
I assume /etc/php.d/ is not parsed correctly. Are you using php-cli, or anything else?
Comment 12 Barry Jackson 2018-11-19 22:56:32 CET
(In reply to Marc Krämer from comment #11)
> nope, it works fine for me.
> I assume /etc/php.d/ is not parsed correctly. Are you using php-cli, or
> anything else?

It's ZoneMinder that checks for the date.timezone in php.ini using the code snippet in #10.

That code is from /usr/share/zoneminder/www/index.php.

I will attach that file although iirc it is the same in the current version in svn.

I have never played with php so any help would be appreciated.
Comment 13 Barry Jackson 2018-11-19 22:57:46 CET
Created attachment 10486 [details]
index.php
Comment 14 Marc Krämer 2018-11-19 23:28:18 CET
can you attach the ouput of
php -i|grep date
Comment 15 Marc Krämer 2018-11-19 23:31:41 CET
and please attach /etc/php.d/05date.ini, /etc/php.ini and php -v
Comment 16 Barry Jackson 2018-11-20 00:04:43 CET
OK Marc, I found it.

There was a file /etc/php.d/05date.ini as well as the correct /etc/php.d/05_date.ini

It was created by an intermediate version of zmsetup that I was working on that had a typo in the filename.

The GB.. came from the original method of finding the timezone that no longer works correctly.

Your php -i|grep date took me straight to it!

All working now so I can finish updating and testing the package.

Thanks!
Comment 17 Marc Krämer 2018-11-20 00:07:08 CET
ah :) very well. Finnally we've got it working.

Note You need to log in before you can comment on or make changes to this bug.