Unfortunately, problems reported in
http://modxcms.com/forums/index.php/topic,6850.msg47974.html#msg47974 somehow did not catch enough attention.
Here is what I can confirm in beta 2 (rev 1417)
1. manager/includes/document.parser.class.inc.php, line 497, col 108
*** there is spelling error publihsedby
2. manager/includes/document.parser.class.inc.php, line 491, col 136
*** $this->getLoginUserID() is used in SQL statement
", publishedby=" . $this->getLoginUserID()
obviously, when user is not logged in, it causes problem reported in bugs #406 and #539
One of the possible solutions to this would be checking value returned by getLoginUserID() and setting it to 0 if function
returns empty value, like this
", publishedby=" . ($this->getLoginUserID()?$this->getLoginUserID():0)
Of course, I am not experienced with performance issues and coding style of this project and PHP in general,
but I am sure some of Core coders could produce something similar in effect and surely better.
Anyway, introduction of this quick fix seems to solve problem with Scheduled Publishing (for now).
Could someone with permissions commit this into SVN please?
EDIT: Maybe better solution would be to change function getLoginUserID() to something like this
# Returns current user id
function getLoginUserID() {
if ($this->isFrontend() && isset ($_SESSION[’webValidated’])) {
return $_SESSION[’webInternalKey’];
} else
if ($this->isBackend() && isset ($_SESSION[’mgrValidated’])) {
return $_SESSION[’mgrInternalKey’];
}
else
return 0
}
if, of course, value 0 means that user is not logged. However, I did not go deep enough into code to see if ’0’ stands for
status ’not logged’.
BTW, it would be good if someone could comb code in search for "dangling" cases like this. By the practices of good programming, conditional branching should always cover all possible cases. Leaving some cases unprocessed could be very unpleasant time bomb that could be activated by some future (currently unplanned) use of functions containing such code.