Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

owncloud server 9 > logtimezone #23134

Closed
StrannikST opened this issue Mar 11, 2016 · 17 comments
Closed

owncloud server 9 > logtimezone #23134

StrannikST opened this issue Mar 11, 2016 · 17 comments

Comments

@StrannikST
Copy link

Hello. Help please , updated to 9 owncloud server. Now it does not work logtimezone (config.php). And now fail2ban not bans . Since time does not match. What to do?

Steps to reproduce

  1. logtimezone > config.php
  2. php.ini date

Expected behaviour

When recording a log does not change the time zone

Actual behaviour

When recording logs must change the time zone

Server configuration

Operating system:
ubuntu server 14.01
Web server:
apache2
Database:
mysql
PHP version:
php 7
ownCloud version: (see ownCloud admin page)
owncloud server 9

@alraban
Copy link

alraban commented Mar 11, 2016

I can confirm that I'm seeing the same thing here. The LogTimeZone setting in the config.php does not appear to affect the actual timestamps in the logs, which breaks fail2ban.

@HocEman
Copy link

HocEman commented Mar 11, 2016

I am seeing the same behavior. Log time stamps do not reflect the timezone set.

@schnello
Copy link

I can confirm the problem also.

{"reqId":"rRw4WfPoRl0DscSMS8mb","remoteAddr":"185.65.xxx.xxx","app":"core","message":"Login failed: 'User' (Remote IP: '185.65.xxx.xxx')","level":2,"time":"2016-03-12T09:30:18+00:00"} root@nas:/home/nas# date Sat Mar 12 10:30:51 CET 2016

root@nas:/home/nas# cat /var/www/owncloud/config/config.php | grep time 'logtimezone' => 'Europe/Berlin', root@nas:/home/nas#

@StrannikST
Copy link
Author

I decided this issue . One possible solution is: file owncloud \ lib \ private \ log \ owncloud.php replace strings

$time = DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""), $timezone);
        if ($time === false) {
            $time = new DateTime(null, $timezone);
        }

on

$time = new DateTime(null, $timezone);

@schnello
Copy link

Thx @StrannikST for the temp solution

@StrannikST
Copy link
Author

You’re welcome

@Phiber2000
Copy link
Contributor

I can confirm this issue, too. It is caused by commits d0464bf, 7fce06b.
The fix by StrannikST from above reverts these commits.

Troubleshooting

The problem seems to be caused by the function 'DateTime::createFromFormat', which has the following constraint:

The timezone parameter and the current timezone are ignored when the time parameter either contains a UNIX timestamp (e.g. 946684800) or specifies a timezone (e.g. 2010-01-28T15:00:00+02:00).

Source: https://secure.php.net/manual/en/datetime.createfromformat.php

Fix proposal

Remove the timezone parameter from "DateTime::createFromFormat" because it has no effect and just set timezone afterwards.

$time = DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""));
$time ? $time->setTimezone($timezone) : $time = new DateTime(null, $timezone);

That's it!

@PVince81 PVince81 added this to the 9.0.1-current-maintenance milestone Mar 14, 2016
@PVince81
Copy link
Contributor

CC @schnidrig

@PVince81
Copy link
Contributor

This is the PR in question #18978

@nickvergessen
Copy link
Contributor

@Phiber2000 looks good, mind turning it into a PR?

@nickvergessen
Copy link
Contributor

PS: but dont use inline if for something like that.

@Phiber2000
Copy link
Contributor

@nickvergessen I'll create the PR in some minutes, using if-else blocks in code.

@MorrisJobke MorrisJobke modified the milestones: 9.1-current, 9.0.1-current-maintenance Mar 14, 2016
@MorrisJobke
Copy link
Contributor

#23225 was merged

@Steve8291
Copy link

Thank you for posting the fix for this. It has been driving me insane.

@enoch85
Copy link
Member

enoch85 commented Mar 26, 2016

Is this backported?

@Phiber2000
Copy link
Contributor

Yes it is: #23240

@lock
Copy link

lock bot commented Aug 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants