Fixing issue described in bug #33348, related to JModelAdmin (libraries/legacy/model/admin.php)
When trying to publish an item, the related table might be(en) checked out by another user. Thus, publishing will fail silently, since the table is going to try to check in only if is not checked out at all or if the user trying to check it in equals the one having checked it out. If they mismatch nothing is stated to the user trying to change its state, which is no good. So i added a check for this circumstance.
<p>When trying to publish an item, the related table might be(en) checked out by another user. Thus, publishing will fail silently, since the table is going to try to check in only if is not checked out at all or if the user trying to check it in equals the one having checked it out. If they mismatch nothing is stated to the user trying to change its state, which is no good. So i added a check for this circumstance.</p>
⇒
<p>When trying to publish an item, the related table might be(en) checked out by another user. Thus, publishing will fail silently, since the table is going to try to check in only if is not checked out at all or if the user trying to check it in equals the one having checked it out. If they mismatch nothing is stated to the user trying to change its state, which is no good. So i added a check for this circumstance.</p>
<p>Find the related TrackerItem at <a href="http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=33348">joomlacode.org</a></p>
Ok, so i'll close this PR and create a new one as i don't know how to update this one against the latest Joomla! version here on GitHub and creating a new one is the fastest way for me. I create all my PRs directly on GitHub.
When i started to create the new PR i noticed that JModelAdmin::reorder() and JModelAdmin::saveorder() also change an item's state not considering that it might be checked out by a different user. As i think every change to an item's state while it might be checked out by a different user should be checked for this conflict i wonder if it wouldn't be better to extend JModelAdmin::canEditState() rather than introducing code duplication.
I don't want to create the new PR with duplicate code but would like to update all methods that appear to be buggy like JModelAdmin::publish() regarding the editor mismatch.
@itbra I agree with your comment that the checked out status should be taken into account of the reorder/saveorder actions.
However I think we should fix it a little higher up in the chain. If you look at JTable::published() we have the checked out check there as well. This code:
// Determine if there is checkin support for the table.if (property_exists($this, 'checked_out') ||property_exists($this, 'checked_out_time')){$query->where('('.$this->getColumnAlias('checked_out') .' = 0 OR '.$this->getColumnAlias('checked_out') .' = '. (int) $userId.')');$checkin=true;}else{$checkin=false;}
Not sure if we can/should wrap this into a method of it's own. You are setting 2 values here and it is only a single if/else block. Using this block in the existing methods might be just as effective as you don't have to juggle with parameters and return values.
It shouldn't be RTC/merged with Travis failures, no. There's extra whitespace on the new line 929 (should be a blank line). The rest of the failures come from the fact this PR is based on such an old version of staging that the Travis config at the time is no longer valid.
@itbra Could you please update the PR so it is up-to-date. I did a quick test with manual code change and it works for me and is a good fix. Thanks.