2006-12-13 12:45:20

The-Exit
Member
êta
From: Berlin
Known languages: English, German, French
Website

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

 

2006-12-13 15:42:05

Mary
Sock Enthusiast
omega
From: Canada

Re: 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).


My email address has changed recently. If you need to contact me, use the forum contact form.

Offline

 

2006-12-13 15:49:13

The-Exit
Member
êta
From: Berlin
Known languages: English, German, French
Website

Re: 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

 

2006-12-13 16:00:56

Mary
Sock Enthusiast
omega
From: Canada

Re: 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


My email address has changed recently. If you need to contact me, use the forum contact form.

Offline

 

2006-12-13 16:25:53

The-Exit
Member
êta
From: Berlin
Known languages: English, German, French
Website

Re: 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

 

2006-12-13 17:49:05

ruud
Developer emeritus
omega
Real name: Ruud van Melick
From: a galaxy far far away
Known languages: li,nl,en,(de)
Website

Re: 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

 

2008-12-01 14:59:38

hongster
New Member
alpha

Re: 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

 

2008-12-01 15:13:21

ruud
Developer emeritus
omega
Real name: Ruud van Melick
From: a galaxy far far away
Known languages: li,nl,en,(de)
Website

Re: article time stamp and incorrect date

hongster, which MySQL version are you using?

Offline

 

2008-12-01 15:39:03

hongster
New Member
alpha

Re: article time stamp and incorrect date

MySQL 5.0.45

Offline

 

2008-12-01 18:10:41

ruud
Developer emeritus
omega
Real name: Ruud van Melick
From: a galaxy far far away
Known languages: li,nl,en,(de)
Website

Re: 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

 

Powered by FluxBB