Record getting 'locked' when trying to edit from front end #959

Closed
opened 2022-09-28 01:23:14 +00:00 by Chris Paschen · 5 comments
Member

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.

You are not permitted to use that link to directly access that page (#4).

(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)

  • OS Name & Version: WAMP
  • MySql Version: 5.7.31
  • Apache Version: 2.4.46
  • PHP Version: 7.4.9
  • Joomla Version: 3.10.10
  • JCB Version: 3.1.2
  • Browser: same in multiple browsers

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:

  • view.edit (both)
  • view.edit.access (both)
  • view.create (both)
  • view.edit.own (both)
  • view.access (both)
  • view.edit.state (both)
  • view.edit.created_by (both)
  • view.edit.created (both)
  • view.delete (both)

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?

### 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. > You are not permitted to use that link to directly access that page (#4). (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) - OS Name & Version: WAMP - MySql Version: 5.7.31 - Apache Version: 2.4.46 - PHP Version: 7.4.9 - Joomla Version: 3.10.10 - JCB Version: 3.1.2 - Browser: same in multiple browsers ### 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: * view.edit (both) * view.edit.access (both) * view.create (both) * view.edit.own (both) * view.access (both) * view.edit.state (both) * view.edit.created_by (both) * view.edit.created (both) * view.delete (both) 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?
Author
Member

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:

2022-09-28T18:41:07+00:00	INFO 127.0.0.1	controller	Holding edit ID com_kr_books.edit.review_content.4 Array (     [0] => 4 ) 
2022-09-28T18:41:07+00:00	CRITICAL 127.0.0.1	error	Uncaught Throwable of type Joomla\CMS\Component\Exception\MissingComponentException thrown. Stack trace: #0 [ROOT]\libraries\src\Application\SiteApplication.php(194): Joomla\CMS\Component\ComponentHelper::renderComponent(NULL)
#1 [ROOT]\libraries\src\Application\SiteApplication.php(233): Joomla\CMS\Application\SiteApplication->dispatch()
#2 [ROOT]\libraries\src\Application\CMSApplication.php(225): Joomla\CMS\Application\SiteApplication->doExecute()
#3 [ROOT]\index.php(49): Joomla\CMS\Application\CMSApplication->execute()
#4 {main}
2022-09-28T18:41:07+00:00	INFO 127.0.0.1	controller	Checking edit ID com_kr_books.edit.review_content.4: 0 Array ( ) 
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books
2022-09-28T18:41:08+00:00	WARNING 127.0.0.1	assets	No asset found for com_kr_books.author_book.16, falling back to com_kr_books

Then trying again, and the edit form opens properly, I see this in the log file:

2022-09-28T18:45:32+00:00	INFO 127.0.0.1	controller	Holding edit ID com_kr_books.edit.review_content.4 Array (     [0] => 4 ) 
2022-09-28T18:45:32+00:00	CRITICAL 127.0.0.1	error	Uncaught Throwable of type Joomla\CMS\Component\Exception\MissingComponentException thrown. Stack trace: #0 [ROOT]\libraries\src\Application\SiteApplication.php(194): Joomla\CMS\Component\ComponentHelper::renderComponent(NULL)
#1 [ROOT]\libraries\src\Application\SiteApplication.php(233): Joomla\CMS\Application\SiteApplication->dispatch()
#2 [ROOT]\libraries\src\Application\CMSApplication.php(225): Joomla\CMS\Application\SiteApplication->doExecute()
#3 [ROOT]\index.php(49): Joomla\CMS\Application\CMSApplication->execute()
#4 {main}
2022-09-28T18:45:33+00:00	INFO 127.0.0.1	controller	Checking edit ID com_kr_books.edit.review_content.4: 1 Array (     [0] => 4 ) 

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.

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: ``` 2022-09-28T18:41:07+00:00 INFO 127.0.0.1 controller Holding edit ID com_kr_books.edit.review_content.4 Array ( [0] => 4 ) 2022-09-28T18:41:07+00:00 CRITICAL 127.0.0.1 error Uncaught Throwable of type Joomla\CMS\Component\Exception\MissingComponentException thrown. Stack trace: #0 [ROOT]\libraries\src\Application\SiteApplication.php(194): Joomla\CMS\Component\ComponentHelper::renderComponent(NULL) #1 [ROOT]\libraries\src\Application\SiteApplication.php(233): Joomla\CMS\Application\SiteApplication->dispatch() #2 [ROOT]\libraries\src\Application\CMSApplication.php(225): Joomla\CMS\Application\SiteApplication->doExecute() #3 [ROOT]\index.php(49): Joomla\CMS\Application\CMSApplication->execute() #4 {main} 2022-09-28T18:41:07+00:00 INFO 127.0.0.1 controller Checking edit ID com_kr_books.edit.review_content.4: 0 Array ( ) 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books 2022-09-28T18:41:08+00:00 WARNING 127.0.0.1 assets No asset found for com_kr_books.author_book.16, falling back to com_kr_books ``` Then trying again, and the edit form opens properly, I see this in the log file: ``` 2022-09-28T18:45:32+00:00 INFO 127.0.0.1 controller Holding edit ID com_kr_books.edit.review_content.4 Array ( [0] => 4 ) 2022-09-28T18:45:32+00:00 CRITICAL 127.0.0.1 error Uncaught Throwable of type Joomla\CMS\Component\Exception\MissingComponentException thrown. Stack trace: #0 [ROOT]\libraries\src\Application\SiteApplication.php(194): Joomla\CMS\Component\ComponentHelper::renderComponent(NULL) #1 [ROOT]\libraries\src\Application\SiteApplication.php(233): Joomla\CMS\Application\SiteApplication->dispatch() #2 [ROOT]\libraries\src\Application\CMSApplication.php(225): Joomla\CMS\Application\SiteApplication->doExecute() #3 [ROOT]\index.php(49): Joomla\CMS\Application\CMSApplication->execute() #4 {main} 2022-09-28T18:45:33+00:00 INFO 127.0.0.1 controller Checking edit ID com_kr_books.edit.review_content.4: 1 Array ( [0] => 4 ) ``` 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.
Owner

Chris I don't have time right now... to look at this but soon as I get a moment I will revert back 😉

Chris I don't have time right now... to look at this but soon as I get a moment I will revert back 😉
Author
Member

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.

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.
Author
Member

I think I've resovled the issue.
I'll follow-up with details once I have a chance to test a bit further.

I think I've resovled the issue. I'll follow-up with details once I have a chance to test a bit further.
Author
Member

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.

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.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#959
No description provided.