Opened 13 months ago

#13309 new Patch - Bug Fix

mysql 5.7+ inserting NULLs into session modified column causes error instead of current timestamp

Reported by: alan-hicks Owned by: Stuart Auchterlonie
Priority: minor Milestone: needs_triage
Component: Plugin - MythWeb Version: Master Head
Severity: medium Keywords: mysql 5.7 mythweb
Cc: Ticket locked: no

Description

With explicit_defaults_for_timestamp enabled, inserting NULL into a TIMESTAMP NOT NULL column now produces an error (as it already did for other NOT NULL data types), instead of inserting the current timestamp. (Bug #68472, Bug #16394472)

SQL Error: Column 'modified' cannot be null #1048

file: /usr/local/www/mythweb/includes/session.php line: 72

class: Database

function: query

type: -> args: Array

(

[0] => REPLACE INTO mythweb_sessions (id, modified, data) VALUES (?,NULL,?) [1] => user:alan [2] => cache_engine|s:10:"Cache_Null";stream|a:1:{s:25:"include_user_and_password";b:0;}prefer_channum|s:1:"1";recorded_pixmaps|b:1;guide_favonly|b:0;timeslot_size|i:300;num_time_slots|i:36;timeslot_blocks|i:3;timeslotbar_skip|i:20;max_stars|i:4;star_character|s:7:"★";show_popup_info|i:1;show_channel_icons|i:1;sortby_channum|i:1;recorded_paging|N;genre_colors|i:1;show_video_covers|i:1;settings|a:1:{s:7:"screens";a:1:{s:2:"tv";a:1:{s:19:"upcoming recordings";a:4:{s:5:"title";s:2:"on";s:7:"channel";s:2:"on";s:11:"record date";s:2:"on";s:6:"length";s:2:"on";}}}}backend|a:2:{s:15:"192.168.202.215";a:1:{s:13:"proto_version";a:2:{s:18:"last_check_version";s:2:"91";s:15:"last_check_time";i:1534162688;}}s:8:"timezone";a:2:{s:5:"value";s:15:"Europe/Guernsey";s:15:"last_check_time";i:1534162688;}}language|s:7:"English";date_statusbar|s:22:"%a %b %e, %Y, %I:%M %p";date_scheduled|s:23:"%a %b %e, %Y (%I:%M %p)";date_scheduled_popup|s:12:"%a %b %e, %Y";date_recorded|s:23:"%a %b %e, %Y (%I:%M %p)";date_search|s:22:"%a %b %e, %Y, %I:%M %p";date_listing_key|s:22:"%a %b %e, %Y, %I:%M %p";date_listing_jump|s:12:"%a %b %e, %Y";date_channel_jump|s:12:"%a %b %e, %Y";date_job_status|s:22:"%a %b %e, %Y, %I:%M %p";time_format|s:8:"%I:%M %p";tv|a:1:{s:4:"last";a:1:{i:0;s:4:"list";}}list_time|i:1534165200;

)

The following patch fixes this issue by replacing NULL with CURRENT_TIMESTAMP. It is compatible with sqlite3 mysql 5.7+ and postgresql.

diff --git a/includes/session.php b/includes/session.php index ab915816..1bf4f1e6 100644 --- a/includes/session.php +++ b/includes/session.php @@ -68,7 +68,7 @@

return;

if (!empty($_SERVERREMOTE_USER?))

$id = 'user:'.$_SERVER['REMOTE_USER'];

  • $db->query('REPLACE INTO mythweb_sessions (id, modified, data) VALUES (?,NULL,?)',

+ $db->query('REPLACE INTO mythweb_sessions (id, modified, data) VALUES (?,CURRENT_TIMESTAMP,?)',

$id, $data);

if (!$db->affected_rows())

return false;

Change History (0)

Note: See TracTickets for help on using tickets.