Hello,
until now I thought that using "publishedon" is safer than to rely on "pub_date", because it always has a value, i.e. for ordering documents in a list. But in the following case (MODx 1.0.5, but it seems to be also in Revo) this value seems to be incorrect:
Let’s say the current date: 2011-03-03.
I create a new document and publish it. So "pub_date" and "publishedon" are set to 2011-03-03. That’s okay.
Now I think this document should have been published yesterday. So I edit the document, set "pub_date" to 2011-03-02 and save.
Unfortunately "publishedon" doesn’t change. It is still set to 2011-03-03.
If I unpublish the document first, then save, then edit and set "pub_date" in the past, then save, "publishedon" will be set to the current time.
In "manager/processors/save_content_processor.php" on line 463 the script (that’s the save-edit-part) doesn’t bother about "pub_date" being in the past. It always sets "publishedon" to the current time or rather to the value it had before. In the save-new-part on line 296 it’s the same...
if (!$was_published && $published) {
$publishedon = time();
$publishedby = $modx->getLoginUserID();
}
elseif ($was_published && !$published) {
$publishedon = 0;
$publishedby = 0;
} else {
$publishedon = 'publishedon';
$publishedby = 'publishedby';
}
I thought it should be
if (!$was_published && $published) {
$publishedon = ($pub_date < time() && $pub_date != 0) ? $pub_date : time();
$publishedby = $modx->getLoginUserID();
}
elseif ($was_published && !$published) {
$publishedon = 0;
$publishedby = 0;
} else {
$publishedon = ($pub_date < time() && $pub_date != 0) ? $pub_date : 'publishedon';
$publishedby = 'publishedby';
}
I thought, that if I set "pub_date" in the past "publishedon" will be in the past too.
Am I thinking in the wrong direction?