When posting or editing a node, users with the "administer nodes" privilege see a section titled "Authoring information," which includes a field labeled "Authored on:" which allows you to change the time/date of a node. When editing an already-existing node, this field is automatically populated with the time/date the node was originally posted, allowing the user to preserve the original time of the post. This is not a problem.

However, when creating a new node, this field is automatically populated with the time the user begins composing the node. This is extremely confusing because the node may not be submitted until much later, if it takes a while to write. When this happens, the node appears to have an incorrect timestamp.

The user can work around this by deleting the time/date entered into that field -- then the node's timestamp will be set to the time it was submitted. This, however, is counterintuitive, especially in version 4.7.0-beta5, since this field is initially hidden from view.

When creating a new node, the "Authored on:" field should be empty.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

archatas’s picture

Don't you think, that if the timestamp is empty when you start creating a node and you want to create that node with the yesterday's date, it will be hard to guess the format of the timestamp?

Sage-1’s picture

Yes, but that can be resolved by providing a label with the format either next to the text box or elsewhere on the page. In fact, you could change the header to display the current date in the correct format as an example, and the user could copy-and-paste to achieve the same results if desired -- that is, you could change "Authored on:" to "Authored on: (2006-03-10 14:17:54 -0600)"

Either way, confusion about the format should be resolved in some way other than automatically populating the Authored On field for a new node. As it stands, users with the "administer nodes" privilege experience a different behavior than users without the privilege. Users with the "administer nodes" privilege should be able to change the behavior, but the default behavior for both types of users should be the same.

Sage-1’s picture

Version: 4.7.0-beta5 » 4.7.0-rc1

This bug still exists in RC1

Sage-1’s picture

Version: 4.7.0-rc1 » 4.7.0-rc2

Still in RC2

hunmonk’s picture

Assigned: Unassigned » hunmonk
Status: Active » Needs review
FileSize
1.24 KB

i agree the behavior should be consistent. here's a simple fix based on a suggestion in the thread. tested and working on current HEAD...

hunmonk’s picture

Status: Needs review » Needs work

hm. there are several problems with that last approach. working on a better solution...

hunmonk’s picture

FileSize
1.85 KB

ok, much happier w/ this effort... :) this patch displays a format description for the authored field upon new node creation, but leaves the field empty and not required. upon form submission, the current time becomes the creation time. for already created nodes, the creation time is populated and the field is marked required.

hunmonk’s picture

Status: Needs work » Needs review

also, i tested this patch under both new node creation and node edits, and it seems to work flawlessly.

chx’s picture

Status: Needs review » Reviewed & tested by the community

An excellent application of form API powers. Works as advertised.

killes@www.drop.org’s picture

Status: Reviewed & tested by the community » Fixed

applied

Steven’s picture

FileSize
2.36 KB

This patch was bogus as far as I can tell: node_validate() still unconditionally requires a valid date for admin users. Leaving it empty (the default for node/add) results in a validation error:

    // Validate the "authored on" field. As of PHP 5.1.O, strtotime returns FALSE instead of -1 upon failure.
    if (strtotime($node->date) <= 0) {
      form_set_error('date', t('You have to specify a valid date.'));
    }

Perhaps validation was broken when this was tested?

Anyway, I don't like the complexity of this approach. There is no reason IMO to make this a special case only for editing.

A scenario which often happens on Drupal.org is that we write announcements as unpublished posts which are revised several times. Then, when the announcement is ready to go live, we change the time to that moment and published it. Why shouldn't this be possible by emptying the date field, relying on node_save() to set it to the current time()?

Attached patch:
- Extends the approach for new nodes to apply to editing as well
- Only validates the node creation date if one was specified (addresses the bug I'm seeing)

Steven’s picture

Status: Fixed » Needs review
Steven’s picture

FileSize
4.47 KB

Sorry that wasn't thorough enough.

Thanks to this patch, we have no excuse to mess with node->changed anymore. Now we can definitely keep node->changed as the actual time of submission (so it is a 100% dependable, internal variable for bookkeeping), while node->created is the visible time, either set by the user, or equal to the time of submission. This means the node_update_index() no longer needs to look at node->created.

So, to sum up:
- At node/add, the authored on field defaults to empty.
- At node/edit, the author on field defaults to whatever node->created was before

In both cases you can either fill in a date to keep it, or leave the field blank to set it to the form submission time.

deekayen’s picture

I verified the validation problem exists in CVS. My preference is to pre-fill the date. If you want to change it, then something is already there to modify AND give an obvious reference how to format the timestamp. Don't make it a required field and have the save function fill in the current timestamp if the form is blank on the timestamp field. That would make it easy to just delete an old timestamp and hit submit to update to the current time().

Jaza’s picture

Version: 4.7.0-rc2 » x.y.z

I agree that the date field should be pre-filled when editing an existing node. If revisions are being used, then automatically setting the created date to time() is no problem, because the old created date will still be stored in the previous revision. But if revisions aren't being used, then the original created date of an existing node will be completely wiped out, and this will seriously mess up a lot of data for a lot of users.

Setting a draft node to 'published' is one use case where the 'created' date needs to be updated. But simply updating an existing published node is another use case, and it's one where the 'created' date should not be updated: the node is being changed, not being created! The latter use case is just as common as the former, and we need to support both.

Moving forward (i.e. in 4.8), I'd like to see the introduction of a checkbox called 'use time of form submission', which will disable and wipe the 'authored on' field when checked (using JS), and which will re-enable the 'authored on' field and re-populate it with the created time when unchecked (default will be unchecked). I've attached some mockup images of this possible UI change below.

Jaza’s picture

FileSize
3.78 KB
Jaza’s picture

FileSize
3.91 KB
Steven’s picture

Priority: Normal » Critical

Setting a draft node to 'published' is one use case where the 'created' date needs to be updated. But simply updating an existing published node is another use case, and it's one where the 'created' date should not be updated: the node is being changed, not being created! The latter use case is just as common as the former, and we need to support both.

Um, we already support both? Editing an existing node will not touch the the 'created date' unless you manually clear the date field.

Steven’s picture

Status: Needs review » Fixed

Committed after green light from chx.

shouchen’s picture

Looks like the changes associated with this issue have reverted the change fixed in http://drupal.org/node/41973. Is there a reason?

Anonymous’s picture

Status: Fixed » Closed (fixed)