While investigating a sudden database insert failure
one of our users reported, I was trying to follow the logic of the auto-publishing feature.
It does a conditional insert, setting the various fields relevant to a document’s publish status, including the publishedby field. To set this, it uses the getLoginUserID function. I find the logic of this hard to follow. If the visitor is not logged in, what exactly gets returned? Apparently nothing. As you can see from the failed query mentioned above,
the publishedby field is empty. Now we’ve had plenty of problems trying to install on new MySQL databases that have "strict mode" set on this very issue. What would happen if a user’s hosting company upgraded their MySQL database engine?
I’m also puzzled over the logic of the getLoginUserID function. If a web user is logged in his ID gets used as the publishedby value? hm. And if a manger user is logged in and poking around in his site, his user id is never returned by the function (we’re talking front-end here). This looks like an awkward problem to me.
I would think it would be better to automatically use the createdby value in the case of auto-publishing, or don’t update that value at all, and only use the logged-in userID if it’s being manually published. Which of course makes it interesting if the manager user uses QuickEdit, since the getLoginuserID still won’t return his manager ID, since it’s front-end.