Record getting 'locked' when trying to edit from front end #959
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#959
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Steps to reproduce the issue
Create an admin view that is used from the front end
Add a button with a link on the front-end (a manually created button on another front-end view)
index.php?option=com_kr_books&view=review_content&task=review_content.edit&id=" . $review->review_id;
(Where review_id IS a valid id in the table.
Expected result
Whenever you click that link it should open the record in the review_content table/view and allow editing.
Actual result
After clicking to edit once, and using the SAVE & CLOSE, then clicking the link again to edit the record once again, the record is locked (to the existing front-end user) and can't be opened.
On the front-end the error is displayed.
(where 4 is the id of the record that is being edited)
HOWEVER, sometimes you can click the edit link a 2-3 times before you get that error.
System information (as much as possible)
Additional comments
When checking the status of the record (via the admin) I can see that the record (#4) is showing that it is checked out to the current front-end user after the erorr is displayed; however, it is NOT checked out prior to clicking the edit link. So the record is getting locked at some point when the edit form is being initiated.
It 'appears' that it might be due to the fact that the record is checked out; however, it's checked out the active user - so that shouldn't give a problem.
The admin view has settings>> permission added for:
The Joomla user group that the front-end user is assigned to has their permissions set to ALLOWED for all of the above view actions. That group also has ALL of the core actions set to ALLOWED as well.
Additionally, if the front-end user is given super-admin access, the error never happens.
This admin view has no added PHP code, JavaScript, Custom Buttons, Class Headers, or anything else 'custom' to this form (other than the fields associated to the view). And none of the fields have anything really very special.
It sure appears that there is something on the edit form that is being restricted related to user ACL (as the superadmin setting makes it all work), but I can't find anything that might be causing this. There isn't any special code for this admin view - just what JCB generates.
I've doen a trace through that JCB code and can't see where it might be causing the record to be opened and then abandoned (while remaining locked).
And I'm really perplexed why the system is not allowing the user who has it locked out to edit it.
I've been testing and tracing this for several hours.
Any ideas what might be causing this or other tips on how to track this down?
Did some more testing - like trying to access the edit link both with standard user group settings as well as with superuser settings.
SuperUser - even when the test user was set as a superuser the access error was happening at times.
Re-trying after getting that error, the user was then let back in to the form (as either superuser or just as the standard user group).
So, it appears it's not specifically a user permission ACL issue.
After spending another hour searching online I found a post on the Joomla Stack Exchange where someone has a similar issue and one reponse mentioned that it could be "associated with race conditions associated with Joolma setting 'edit ids'"
Doing another test, getting the error, and checking the logs, I see the following errors in the joomla log file:
Then trying again, and the edit form opens properly, I see this in the log file:
I've taken a look at the files mentioned in this last log file and can't seem to identify what might be causing a critical error when just trying to access this form.
Line 194 of the SiteApplication.php file is just trying to renderComponent.
Any ideas on how to track this down further would be most welcome as I've never run into anything like this with JCB or Joomla.
Chris I don't have time right now... to look at this but soon as I get a moment I will revert back 😉
Thanks. I'm still trying to do some digging and trying to find out what is going on.
I'm also going to try the latest tag version of JCB (I'm at least one tag behind) to see if that has any effect on anything.
Also, I've read several other posts that this sort of thing might be at least contributed to by server issues - and because this is WAMP running on Windows, I am also trying to reproduce on production-level LAMP systems.
I'll update as I find any other clues in this process.
I think I've resovled the issue.
I'll follow-up with details once I have a chance to test a bit further.
I have finally found a solution.
We were linking to the edit form via a button in a module.
When the link has a .button class applied:
<a href="<?php echo $review->edit_link ?>" class="button complete_review_button"><?php echo jText::_('MOD_KR_BOOKS_DASHBOARD_REVIEWERSTATS_REVIEW_BUTTON_SUBMIT'); ?></a>
the link causes the access errors (around 75% of the time, but works other times)
If we drop the .button class:
<a href="<?php echo $review->edit_link ?>" class="complete_review_button"><?php echo jText::_('MOD_KR_BOOKS_DASHBOARD_REVIEWERSTATS_REVIEW_BUTTON_SUBMIT'); ?></a>
It works fine.
I have NO idea how a CSS class added to a link can cause an access issue, but at least we know how to resolve it.
BTW this component has a LOT of edit forms on the front end all being called from lots of buttons in various modules (and from component views) and none of the rest have this issue.
I've spent hours trying to resolve this so I'm not going to spend more time; however, if anyone knows (or has an idea) why this might be happening, or if it could somehow be a problem in JCB, I'll leave this open for a few days. Otherwise I'll just close it shortly.