putenv(TZ) hack in LocalSettings.php now gives warnings

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

putenv(TZ) hack in LocalSettings.php now gives warnings

jidanni
Nowadays one gets:

PHP Warning: date(): It is not safe to rely on the system's timezone
settings. You are *required* to use the date.timezone setting or the
date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely
misspelled the timezone identifier. We selected the timezone 'UTC' for
now, but please set date.timezone to select your timezone. in
LocalSettings.php on line 82
MediaWiki 1.20alpha Updater

Given

3 matches for "timez" in buffer: LocalSettings.php
     28:  case 'ABJ':$wgLocaltimezone='America/Chicago';
     47:  case ...  :$wgLocaltimezone='Asia/Taipei';
     82:putenv("TZ=$wgLocaltimezone");$wgLocalTZoffset=date('Z')/60;

I found making that line 82 now

date_default_timezone_set($wgLocaltimezone);putenv("TZ=$wgLocaltimezone");$wgLocalTZoffset=date('Z')/60;

fixes the problem.

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

jidanni
Gee, I hope none of my users will be affected...
mysql> select distinct up_value from user_properties where up_property = "timecorrection";
+--------------------------+
| up_value                 |
+--------------------------+
| Offset|0                 |
| 08:00                    |
| System|480               |
| ZoneInfo|480|Asia/Taipei |
+--------------------------+

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

Chad
In reply to this post by jidanni
On Mon, Mar 19, 2012 at 9:13 PM,  <[hidden email]> wrote:

> Nowadays one gets:
>
> PHP Warning: date(): It is not safe to rely on the system's timezone
> settings. You are *required* to use the date.timezone setting or the
> date_default_timezone_set() function. In case you used any of those
> methods and you are still getting this warning, you most likely
> misspelled the timezone identifier. We selected the timezone 'UTC' for
> now, but please set date.timezone to select your timezone. in
> LocalSettings.php on line 82
> MediaWiki 1.20alpha Updater
>
> Given
>
> 3 matches for "timez" in buffer: LocalSettings.php
>     28:  case 'ABJ':$wgLocaltimezone='America/Chicago';
>     47:  case ...  :$wgLocaltimezone='Asia/Taipei';
>     82:putenv("TZ=$wgLocaltimezone");$wgLocalTZoffset=date('Z')/60;
>
> I found making that line 82 now
>
> date_default_timezone_set($wgLocaltimezone);putenv("TZ=$wgLocaltimezone");$wgLocalTZoffset=date('Z')/60;
>
> fixes the problem.
>

Using putenv("TZ=....") has been removed as of PHP 5.4. From the
changelog:

"Removed support for putenv("TZ=..") for setting the timezone."

-Chad

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

Daniel Friesen-4
In reply to this post by jidanni
On Mon, 19 Mar 2012 18:13:58 -0700, <[hidden email]> wrote:

> Nowadays one gets:
>
> PHP Warning: date(): It is not safe to rely on the system's timezone
> settings. You are *required* to use the date.timezone setting or the
> date_default_timezone_set() function. In case you used any of those
> methods and you are still getting this warning, you most likely
> misspelled the timezone identifier. We selected the timezone 'UTC' for
> now, but please set date.timezone to select your timezone. in
> LocalSettings.php on line 82
> MediaWiki 1.20alpha Updater
>
> Given
>
> 3 matches for "timez" in buffer: LocalSettings.php
>      28:  case 'ABJ':$wgLocaltimezone='America/Chicago';
>      47:  case ...  :$wgLocaltimezone='Asia/Taipei';
>      82:putenv("TZ=$wgLocaltimezone");$wgLocalTZoffset=date('Z')/60;
>
> I found making that line 82 now
>
> date_default_timezone_set($wgLocaltimezone);putenv("TZ=$wgLocaltimezone");$wgLocalTZoffset=date('Z')/60;
>
> fixes the problem.

Why don't you just set `date.timezone` in your php config and make all the  
hacks go away?

--
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

jidanni
In reply to this post by Chad
OK I will try my best to keep up with your changes

        for i in RELEASE-NOTES-* includes/installer/LocalSettingsGenerator.php
        do
            echo $i diff:
            svn diff -r ${BASE-BASE}:HEAD $i|wdiff -d -3|tee /tmp/mediawikiDiff$$
        done

And also watchlist http://www.mediawiki.org/wiki/Manual:LocalSettings.php

Alas that is still not enough to reveal to what the current vanilla
LocalSettings.php that gets produced deals with the issue. Perhaps
someone would be kind enough to post one.

>Why don't you just set `date.timezone` in your php config and make all the
>hacks go away?

I want to keep all this stuff in one file, LocalSettings.php, on my many systems.

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

jidanni
In reply to this post by Daniel Friesen-4
Is there any way I can just run
$ cd includes/installer && php LocalSettingsGenerator.php
to see what it generates using my current values,
so I don't have to install all over again just to see what it makes looks like?
I did the above line and nothing happens.

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

Chad
On Wed, Mar 21, 2012 at 2:38 PM,  <[hidden email]> wrote:
> Is there any way I can just run
> $ cd includes/installer && php LocalSettingsGenerator.php
> to see what it generates using my current values,
> so I don't have to install all over again just to see what it makes looks like?
> I did the above line and nothing happens.
>

Of course it won't. LocalSettingsGenerator.php only has a class--no
executable code. You could write a maintenance script to do that
though.

You can pass it an array of all the values you want to output in it
(it's pretty well documented), and you could read your current
LocalSettings to get those values. Not the most straightforward
use-case but the installer didn't call for that behavior. YMMV.

-Chad

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

Platonides
In reply to this post by jidanni
On 21/03/12 19:38, [hidden email] wrote:
> Is there any way I can just run
> $ cd includes/installer && php LocalSettingsGenerator.php
> to see what it generates using my current values,
> so I don't have to install all over again just to see what it makes looks like?
> I did the above line and nothing happens.

The latest MW version gives it for you to download, instead of saving it
as LocalSettings.php so it's easier for comparison.


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

jidanni
In reply to this post by Chad
>>>>> "C" == Chad  <[hidden email]> writes:
C> Of course it won't. LocalSettingsGenerator.php only has a class--no
C> executable code. You could write a maintenance script to do that
C> though.

C> You can pass it an array of all the values you want to output in it
C> (it's pretty well documented), and you could read your current
C> LocalSettings to get those values. Not the most straightforward
C> use-case but the installer didn't call for that behavior. YMMV.

Ah, of course! A simple

 public function execute() {
                $vars = Installer::getExistingLocalSettings();
                $ls = new LocalSettingsGenerator( $this );
                $ls->writeFile( "/tmp/LocalSettings.php" );
        }

Unfortunately it is 1 0 0 0 times more complicated than that and it
would be 1 0 0 0 times easier to just download another copy of MediaWiki
and stumble forth from there.

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: putenv(TZ) hack in LocalSettings.php now gives warnings

jidanni
In reply to this post by Daniel Friesen-4
Hey Jidanni, you can just eliminate your whole
>date_default_timezone_set($wgLocaltimezone); putenv("TZ=$wgLocaltimezone");$wgLocalTZoffset=date('Z')/60;
line. It's already taken care of for you in includes/Setup.php !
You don't even need to reinstall Mediawiki just to find out how they do
it in the current generated LocalSettings.php .
Don't worry. The next time your wiki stops working because something
needs to be updated in LocalSettings.php just look at the...

_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l