Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-12-13 12:45:20

The-Exit
Member
From: Berlin
Registered: 2005-07-16
Posts: 175
Website

[issue] article time stamp and incorrect date

Today I wanted to display an article in the future, but instead of altering the publication time, i altered the publication date. i inserted into the field for the month the value “18” which is not valid.

textpattern didn’t show a message, as i would expect. instead, the publication date was changed to 1970-01-01 which is really not the behaviour i expect.

could there an error message inserted?

Offline

#2 2006-12-13 15:42:05

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [issue] article time stamp and incorrect date

I don’t know for certain, but yes, I think there’s no error checking done there, and there should be.

The question is how to handle it properly. I’m thinking force dates into the correct structure (so 18 becomes 12, etc), but give you a warning (like we warn about duplicate url titles, for instance).

Offline

#3 2006-12-13 15:49:13

The-Exit
Member
From: Berlin
Registered: 2005-07-16
Posts: 175
Website

Re: [issue] article time stamp and incorrect date

or probably just no change if the inserted value is not correct, i.e. if the inserted date is not valid, e.g. the 30th february :)

Offline

#4 2006-12-13 16:00:56

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [issue] article time stamp and incorrect date

Unless you’re referring to some kind of JavaScript early warning, which I can see, that wouldn’t be a good idea: the result would be completely losing all your changes. That’d be the quickest way to send most people into orbit. ;p

Offline

#5 2006-12-13 16:25:53

The-Exit
Member
From: Berlin
Registered: 2005-07-16
Posts: 175
Website

Re: [issue] article time stamp and incorrect date

well, for that, i’m not deep enough in the code.

i just thought:

when user clicks “save”
1. check if entered date is valid
2. if date is not valid, use the value, which was stored in the db.

problem: if user changes date to invalid value before 1st save. then you could use the current date.

or you can go for:
if entered date is not valid, use current date

in both cases the user should get a error message.

Offline

#6 2006-12-13 17:49:05

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: [issue] article time stamp and incorrect date

Hmm… if you don’t mind letting MySQL do the error checking, you can do this:
  1. store the old date (or current date for new articles) in a hidden form field when displaying the article edit page.
  2. after saving the article, fetch the stored date from the database, compare it with the date entered by the user. If they differ, restore the old date (stored in hidden field), otherwise it’s okay.
    It costs an extra, but simple query on each article save, but avoids having to add complex date validation code in TXP

Last edited by ruud (2006-12-13 17:50:18)

Offline

#7 2008-12-01 14:59:38

hongster
New Member
Registered: 2008-12-01
Posts: 7

Re: [issue] article time stamp and incorrect date

The-Exit wrote:

well, for that, i’m not deep enough in the code.

i just thought:

when user clicks “save”
1. check if entered date is valid
2. if date is not valid, use the value, which was stored in the db.

problem: if user changes date to invalid value before 1st save. then you could use the current date.

or you can go for:
if entered date is not valid, use current date

in both cases the user should get a error message.

I agree with those suggestions. By default, the input fields for article expiry date is empty, when new article is created. When I edit the article and click “Save”, SQL error message appeared on top of the page!

The error start with the following string:
Incorrect datetime value: '0' for column 'Expires' at row 1 update txp_textpattern set Title = ...

Offline

#8 2008-12-01 15:13:21

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: [issue] article time stamp and incorrect date

hongster, which MySQL version are you using?

Offline

#9 2008-12-01 15:39:03

hongster
New Member
Registered: 2008-12-01
Posts: 7

Re: [issue] article time stamp and incorrect date

MySQL 5.0.45

Offline

#10 2008-12-01 18:10:41

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: [issue] article time stamp and incorrect date

hongster, can you open a new topic for this specific error and include exact steps to reproduce. This appears to be something that is dependent on MySQL version and may be a bug in TXP.
This topic is quite old and deals with a problem that’s not related to the error message you’re getting.

Offline

#11 2008-12-01 22:32:08

rooon
New Member
From: Melbourne, Australia
Registered: 2008-12-01
Posts: 7

Re: [issue] article time stamp and incorrect date

I’m also getting this error… was the new topic created?

Offline

#12 2008-12-01 23:02:18

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: [issue] article time stamp and incorrect date

No, but feel free to do so yourself.

Offline

Board footer

Powered by FluxBB