Welcome Guest, Not a member yet? Register   Sign In
CI Model Timestamp changes from 4.4.3 to 4.4.4 ?
#1

Hi guys,
Does anyone know if there has been any changes or bug fixes regarding timestamps in the latest release? After upgrading, my original code crashes with a db exception.

PHP Code:
protected $useTimestamps true;              
protected $updatedField;  // leave empty to prevent this field being updated 

To fix, I had to actually initialise the variable as per current documentation. The original code hadn't been updated in 3 years. The requirement perhaps changed somewhere along the lines but did not see any mention of it in previous upgrade notes and it hadn't caused any trouble until now.
PHP Code:
protected $updatedField '';  // set empty to prevent this field being updated 

Without setting updatedField to an empty string, it would add an extra date value to the INSERT string

Code:
INSERT INTO `log`(
    `session_id`,
    `category`,
    `type`,
    `message`,
    `created_at`,
)
VALUES(
    '323',
    'session',
    'success',
    'Session started.',
    '2024-01-09 14:58:34',
    '2024-01-09 14:58:34' // extra date injected
)
Reply
#2

Most likly a php version requiring it to be initilized.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

I didn't update anything but CI. PHP before and after the update was 8.1.6.
Reply
#4

I just went through the the change logs and did not see anytrhing to do with the model timeStamp.

Went back to 4.4.0 version.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

Thanks for having a look. I couldn't see anything when I quickly checked either. I guess it will be an unsolved mystery.
Reply
#6

I would ask the developers on GitHub if they know anything about this.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

Sorry, it seems because of https://github.com/codeigniter4/CodeIgniter4/pull/8193

But your past code was a misuse.
See
https://github.com/codeigniter4/CodeIgni...#L121-L126
$updatedField type is string, not nullable. So it should not be null (uninitialized).
Reply
#8

@kenjis Thank you for clarifing this for us.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#9

(01-11-2024, 03:51 AM)kenjis Wrote: Sorry, it seems because of https://github.com/codeigniter4/CodeIgniter4/pull/8193

But your past code was a misuse.
See
https://github.com/codeigniter4/CodeIgni...#L121-L126
$updatedField type is string, not nullable. So it should not be null (uninitialized).

Thanks for the response. Yes, code is wrong as per current documentation. However, I'm certain the documentation would have shown it uninitialized some time in the past (my code is over 3 years old). Simply because I'm not that clever to code CI features without examples and would have copied what was shown in the docs.

This post might help those who used example code from documentation way back.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB