Author |
Message |
neralex
Site Admin

Joined: Aug 22, 2007
Posts: 1775
|
Posted:
Tue May 01, 2012 1:59 pm |
|
hey!
The following date string for the autonews is not stored correctly as timestamp in the database.
File: modules/News/admin/index.php
check in function postAdminStory and function postStory:
Code:$date = $year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
|
the correct string is:
Code:$date = ''.$year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
|
 |
Last edited by neralex on Thu May 03, 2012 1:50 pm; edited 2 times in total |
|
|
 |
spasticdonkey
RavenNuke(tm) Development Team

Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Wed May 02, 2012 5:45 pm |
|
I haven't tried this, and maybe I'm missing something, but I'm not seeing how that change does anything different. |
|
|
|
 |
neralex

|
Posted:
Wed May 02, 2012 5:54 pm |
|
if you use the first version, then the date string was not stored correctly.
stored: 2012-05-01 021:06:3
correct: 2012-05-01 21:06:30
i suspect it is on the field type of column in the database. it is not at all a datetime column type. if you stored a submit news, you have a timestamp as varchar, in the stories table you have a datetime field. i know this issue from old php nuke version. it was the same crazy thing.  |
|
|
|
 |
spasticdonkey

|
Posted:
Wed May 02, 2012 9:46 pm |
|
ok that makes sense and good find  |
|
|
|
 |
fkelly
Former Moderator in Good Standing

Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY
|
Posted:
Thu May 03, 2012 9:20 am |
|
I'm not following, sorry. The way dates are stored in the autonews, queue and stories tables is crazy, I will concede that. The stories table has a time field, which is datetime datatype. That's as it should be I think. The queue table, which stores news articles submitted through submit news has a field called timestamp which is also in datetime format. Aside from naming confusion, that's okay. The autonews table, which stores news articles that are "programmed" to be effective at a future time, uses a varchar(19) field named time. 19 characters works out to be just the right number to store a datetime field but the field type should really be datetime.
I noticed a few other errors popping up on my localhost when I was testing but I was unable to replicate the problem with date format you posted, either for an article created as autonews or for one created through submit news.
I've sat here parsing mentally,
$date = $year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
versus
$date = ''.$year.'-'.$month.'-'.$day.' '.$hour.':'.$min.':00';
The second of which you said is correct. I don't see why we'd put quote marks in front the .$year???
We could put out fires with this horrible code until the cows come home but what we really need to do is start over with news. We don't need a whole module for submit news nor do we need separate tables for the queue and for autonews. We need a field in the stories table that tells us that the story is pending administrative approval and thus should be skipped in news/index.php and anything else that displays stories for users. And we need an effective (starting) date for stories and again anything displaying stories for users would just use a beginning date in the SQL that is >= to the starting date. Not to mention that we don't need separate functions for adminstory, autoedit, autosavedit, changestory, displaystory, editstory, previewadminstory and previewstory, to name just some. I think the original author must have been getting paid by the line of code produced and the result is a maintenance nightmare. |
|
|
|
 |
neralex

|
Posted:
Thu May 03, 2012 1:47 pm |
|
ok i have checked my variables and you have fully right, fkelly! there was an error of the order of my variables that i give over into the function.
so we let the cow in the village
with the functions and tables of the news module you have fully right, too. its a good idea to put all in one table. but its a hard work to refresh this "maintenance nightmare". |
|
|
|
 |
|