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."

CommentFileSizeAuthor
#16 node.date_.d5.patch2.76 KBFreso
#9 date-02.patch3.26 KBdesbeers
#4 date-01.patch5.76 KBdesbeers

Comments

desbeers’s picture

Title: No "Authored on" format example when previewing a new node » "Authored on" date has 3 problems
Priority: Minor » Normal

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.

desbeers’s picture

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.

JirkaRybka’s picture

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?

desbeers’s picture

Status: Active » Needs review
StatusFileSize
new5.76 KB

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():

  • Always set $node->created. If $node->date is filled in it will be used, else time(). This will keep the ‘preview-date’ up-to-date.

node_object _prepare():

  • Always set $node->created for ‘new’ nodes and $node->date for ‘edit’ nodes; in-depended of access rights. Fixed notices and part of the preview and help problems.
  • Removed access check, moved this to node_form()

node_form():

  • Access-check for ‘administer nodes’
  • Use of $node->created in help-text if $node->date is not set. Fixes nr. 2, ‘incomplete help-text’.
  • Always set default value for date-field if $node->date is set; not just for ‘old’ nodes. This fixes nr. 3, ‘always empty date field’ when creating a new node.

node_preview():

  • Removed $node->date to $node->creation conversion as this is done already in function node_submit(). Also fixed problem that $node->created is ‘reset’ because $node->date is set but empty. This fixes nr. 1, the ‘1970’ problem.
gábor hojtsy’s picture

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

moshe weitzman’s picture

Priority: Normal » Critical
JirkaRybka’s picture

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.

chx’s picture

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

desbeers’s picture

StatusFileSize
new3.26 KB

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.

chx’s picture

Status: Needs review » Reviewed & tested by the community
chx’s picture

So: I tested the issue and problems are fixed and yes the code is very nice.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Looks good to me too. Committed.

hunmonk’s picture

Version: 6.x-dev » 5.x-dev
Status: Fixed » Patch (to be ported)

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.

hunmonk’s picture

Priority: Critical » Normal

don't think this is critical as it stands for D5.

ryanj-1’s picture

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?

Freso’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.76 KB

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.

brevity’s picture

Status: Patch (to be ported) » Needs review

Thanks, works fine!

damien tournoud’s picture

On code review, the patch looks good (it is very similar to the one from D6). It should indeed work as expected.

sethcohn’s picture

Status: Needs review » Reviewed & tested by the community

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.

damien tournoud’s picture

Status: Needs review » Reviewed & tested by the community

Patch still applies cleanly.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.x.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

battochir’s picture

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