-
Notifications
You must be signed in to change notification settings - Fork 336
Description
Call to a member function setTimezone() on false …\app\Http\RequestHandlers\SiteLogsPage.php:77
#0 …\app\Http\Middleware\RequestHandler.php(52): Fisharebest\Webtrees\Http\RequestHandlers\SiteLogsPage->handle(Object(Nyholm\Psr7\ServerRequest))
line 76:
$earliest = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $earliest, new DateTimeZone('UTC'))
->setTimezone(new DateTimeZone(Auth::user()->getPreference(UserInterface::PREF_TIME_ZONE, 'UTC')))
->format('Y-m-d');
“Y-m-d H:i:s” is requested (MySQL standard, no milliseconds), but SqlSrv datetime (always) has 3 millisecond digits. Hence the error. Excerpt from log table
log_id log_time log_type log_message ip_address user_id gedcom_id
1 2025-10-28 14:32:42.853 config Site preference "WT_SCHEMA_VERSION" set to "1" 127.0.0.1 NULL NULL
2 2025-10-28 14:32:42.877 config Site preference "WT_SCHEMA_VERSION" set to "2" 127.0.0.1 NULL NULL
SqlSrv datetime is obsolete and should be replaced by datetime2(precision). So here datetime2(0).
webtrees uses in Migration0.php line 95 the default precision:
DB::schema()->create('log', static function (Blueprint $table): void {
$table->integer('log_id', true);
$table->timestamp('log_time')->useCurrent();
that in vendor/iluminate/database/Shema/Grammars, it is implemented correctly for our purposes in MySql, but is implemented unfavorably for SqlSrv in SqlServerGrammer.php line 837:
return $column->precision ? “datetime2($column->precision)” : ‘datetime’;
Fix:
use in all DB definition the requested precision 0 like migraion0.php line 97
$table->timestamp('log_time', 0)->useCurrent();
I change 5 occurrence in mig0, 1 in mig40
and additionally a change in SqlServerGrammer.php line 837
return isset($column->precision) ? “datetime2($column->precision)” : ‘datetime’;
I'm not sure how to make this change permanent, as it gets overwritten with every composer update.