"Authored on" date has 3 problems
John Morahan - September 14, 2007 - 20:54
| Project: | Drupal |
| Version: | 5.x-dev |
| Component: | node system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
Log in as a user with 'administer nodes' access. Go to node/add/page (or node/add/anything), fill in any required fields and hit Preview. Then look in the "Authoring information" fieldset. Under the "Authored on" field you see this:
"Format: . Leave blank to use the time of form submission."
instead of the usual e.g.:
"Format: 2007-09-14 21:44:50 +0100. Leave blank to use the time of form submission."

#1
There are currently 3 problems with the 'authority date':
PROBLEMS:
1 - If a use previews a new node and has no 'administer nodes' access; the 'preview date' will be somewhere in 1970. Very ugly.
2 - If a use previews a new node and has no 'administer nodes' access; part of the help-text disappears as mentioned in this issue.
3 - If a user previews a new node and does have 'administer nodes' access and alters the 'authority date field' the proper date is displayed in the preview and the help-text but the form-field will be empty again.
All these problems are only with -new- nodes!
REASON WHY:
1 - $node->date is empty on previewing for people without administer nodes rights.
2 - On first prepare of the node form default values will be filled in; but after preview $node->date will be empty if nothing is filled-in the 'authority-date-field'. The $node->date is used in the help-text.
3 - The form-field will not be filled-in with a default value because there is no $node->nid yet.
SOLUTION:
None yet :-( I managed to solve the problem but it was ugly and maybe unsafe. It seems that the author/date fields are only available for people with'administer nodes' rights and this is checked on several places. In 'node_form' and 'node_submit' for example.
I don't understand why because it looks double for me. If the access in the form is restricted than it should be safe to add missing values. I suppose... $node->name is set anyway (if not anonymous) so why not $node->date or $node->created as well? It gives notices as well when creating a node without admin rights.
I'll make a patch if I have some more knowledge about the safety concerns.
#2
Oeps,
Problem 2 - If a use previews a new node and DOES HAVE 'administer nodes' access; part of the help-text disappears as mentioned in this issue.
#3
The most serious problem for me is the 1970's date on non-admin's preview, because it's end-user facing (already reported as bug on my site...). I think it may be solved easily, if I only knew where in code, by simply just using current time in case of empty $node->date, just for the sake of preview-rendering. This would be a tiny 6.x bugfixing patch before we proceed to the rest?
#4
The ‘1970’ is the most visible problem, but nr. 2 is worse because the date field it non-functional for creating new nodes. Anyway, attached a patch to fix all 3 problems and some notices.
ALTERED FUNCTIONS:
node_submit():
node_object _prepare():
node_form():
node_preview():
#5
This is indeed a nasty issue and the missing date problem also blocked one patch around that form field description (but I don't remember the issue ID).
#6
#7
I confirm all the described behaviors (problem 1. even occurs with uid=1 on fresh install).
Tested the patch from #4 on recent 6.x-dev: All mentioned bugs solved, no visible problems for me. I've tested all I can think of (previewing nodes with/-out changing date, removing date from form field, saving nodes straight away with no preview, editing old nodes...), all fine now.
Code reads OK to me, although I'm not much experienced in node module. Deserves RTBC if others agree.
#8
While this patch works it's a step back. With #access we were able to make the node form consistent. If you are conditionally adding elements then it's inconsistent again :/
#9
I wasn't sure if the #access in the form was enough (it was already there all the time) and moved the user_access just to be on the safe side (see comment #1).
Now removed the conditional statement and access-rights is still working correct so user_access was unneeded and #access in the form is enough.
Attached a new patch.
#10
#11
So: I tested the issue and problems are fixed and yes the code is very nice.
#12
Looks good to me too. Committed.
#13
looks like this is still a problem in Drupal 5. at the very least, users without 'administer nodes' perms are getting the 1970 date as the created time in their previews.
#14
don't think this is critical as it stands for D5.
#15
Am I the only one who needs a patch for 5.x? I would make one if I knew how, but my PHP knowledge is very limited. Does anyone have any idea when this is going to be done?
#16
Here's a port of the patch. I haven't tested it though, and there are a few differences between D5's and D6's node.module, so this should be tested properly.
#17
Thanks, works fine!
#18
On code review, the patch looks good (it is very similar to the one from D6). It should indeed work as expected.
#19
Tested, works to solve the date preview issue(s).
+1
Please add this patch, so it makes it for D5.8, to fix the incorrect previews for those of us who are required to maintain a clean D5 core without non-critical patches.
#20
Patch still applies cleanly.
#21
Committed to 5.x.
#22
Automatically closed -- issue fixed for two weeks with no activity.
#23
Hello Freso,
Thanks for the patch! Very cool of you to make and share it. This date problem was ugly and a nasty pain in the arse. It's been around awhile and I'm surprised that in a supported version of drupal it's not been taken care of in core. Thanks again...you rock,
cheers,
wim