-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#33348] fix JModelAdmin::publish() #3190
Conversation
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.
Replaced 'AND' by '&&'
The model assumed the table has a field named 'checked_out'. But this might cause an error being thrown trying to access a non-existing property with tables not having this field.
Added property existence check
Fixed logical error in line 936
// If the table is checked out by another user, drop it and report to the user trying to change its state. | ||
if (property_exists($table, 'checked_out') && $table->checked_out && ($table->checked_out != $user->id)) | ||
{ | ||
JLog::add(JText::sprintf('COM_KEY2SWAP_ERROR_ROW_IS_CHECKED_OUT_BY', $pks[$i]), JLog::WARNING, 'jerror'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itbra
COM_KEY2SWAP_ERROR_ROW_IS_CHECKED_OUT_BY
Is not a Core language string can you change it to something that is a core one or add an new core one?
@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. |
I can do that, but i'm afraid it makes no sense as it seems there is no further interest to accept and merge it. See how old it is. |
Agree, once the PR is up-to-date I will merge it as we have 2 good tests. Thanks @itbra |
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. |
Guys i need your opinions! When i started to create the new PR i noticed that 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 What do you think? |
@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. That is my idea. |
I have checked this issue in my local, able to reproduce the issue of changing the state of checked item. Joomla! Version: Joomla! 3.4.8 Stable [ Ember ] 24-December-2015 19:30 GMT This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
I have tested this item ✅ successfully on 61cca9a This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
I have tested this item ✅ successfully on 61cca9a This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
@rdeutz if you want to make something RTC you have to make a comment RTC at the same time or the bot will unset it This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
Also not 100% certain but if it fails the travis tests it probably cant be marked RTC either This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
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. |
I think I will remake the PR or @itbra can you make a new PR? This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
Setting to RTC This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
(headbang) seems it is above my level of knowledge to set something to RTC |
next try to set to RTC This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
Closing here so that #9848 is merged This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3190. |
closing this one because of #9848 |
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.