User tests: Successful: Unsuccessful:
Pull Request resolves #39268.
canEdit() is fixed: it was reading $contentTypeTable->type_alias on a ContentType table object that was never loaded, so the value was always empty. It now correctly uses the locally built $typeAlias string, and the unused $contentTypeTable instantiation was removed.
Log in as Super User to the administrator backend
Create a test user with Author rights:
Test Authortestauthorauthor@example.comCreate an article owned by the Author:
Test Article – Version PreviewThis is version 1 content.Test AuthorEdit the article:
This is version 2 content.Versions Check:
testauthorTest Article – Version PreviewVersions, click it.The preview popup returns a 403 Access Denied error for Author-group users. The same user can open the article for editing without issue, but cannot preview historical versions.
The preview popup opens successfully and displays the historical version data. Behaviour matches Joomla 3.10.x where Authors could preview versions of their own articles.
Please select:
| Status | New | ⇒ | Pending |
| Category | ⇒ | Administration com_content com_contenthistory |
| Labels |
Added:
PR-5.4-dev
|
||
@CSGoat0 Version History works for different content type, not just article, so you cannot hard code the check to article like that. I haven't tried but I think the issue comes from this line https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L143. $contentTypeTable is just a new table object, it hasn't loaded data from database yet, so I don't think it is right to use $contentTypeTable->type_alias here. Maybe you can try to change $contentTypeTable->type_alias in that line of code to just $typeAlias (seems logical to me) to see if it solves the issue?
@CSGoat0 Version History works for different content type, not just article, so you cannot hard code the check to article like that. I haven't tried but I think the issue comes from this line https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L143. $contentTypeTable is just a new table object, it hasn't loaded data from database yet, so I don't think it is right to use $contentTypeTable->type_alias here. Maybe you can try to change $contentTypeTable->type_alias in that line of code to just $typeAlias (seems logical to me) to see if it solves the issue?
I should have posted the comment directly in the code section, but for some reasons, It could not be submitted, so I had to add new comment here.
@CSGoat0 Version History works for different content type, not just article, so you cannot hard code the check to article like that. I haven't tried but I think the issue comes from this line https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L143.
$contentTypeTableis just a new table object, it hasn't loaded data from database yet, so I don't think it is right to use$contentTypeTable->type_aliashere. Maybe you can try to change$contentTypeTable->type_aliasin that line of code to just$typeAlias(seems logical to me) to see if it solves the issue?I should have posted the comment directly in the code section, but for some reasons, It could not be submitted, so I had to add new comment here.
Nice catch, I have tried both and you are right.
I updated the code.
There are still many unrelated changes. As mentioned, I think the only change needed is modify this line of code https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L143, change change $contentTypeTable->type_alias in that line of code to just $typeAlias , all other changes could be reverted.
There are still many unrelated changes. As mentioned, I think the only change needed is modify this line of code https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L143, change change
$contentTypeTable->type_aliasin that line of code to just$typeAlias, all other changes could be reverted.
I reverted it back, I have also removed the $user->authorise('core.edit', $table->item_id) at getItem() as it's double checked.
Thanks for the help, also everything works fine.
Yes, looks good. Could you also remove these lines of code https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L137-L138 ? The variable $contentTypeTable is not used anymore, thus it should be removed.
Also, with your edit, the $user variable at this line https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L55 should also be removed because it is not used anymore. Not sure if it is github issue or my internet connection, I could not comment directly in the code area
Also, with your edit, the $user variable at this line https://github.com/joomla/joomla-cms/blob/5.4-dev/administrator/components/com_contenthistory/src/Model/PreviewModel.php#L55 should also be removed because it is not used anymore. Not sure if it is github issue or my internet connection, I could not comment directly in the code area
All set, boss.
Looks good to me now, thanks. @Rolli1962 Could you please test it again ?
Tested again with J6.1.0 - is working fine!
Tested again with J6.1.0 - is working fine!
@Rolli1962 Thank you for testing. Could you also test this PR with Joomla 5.4 and note the result in Joomla issue tracker? This would be great.
I have tested this item ✅ successfully on 932ec53
Did create user and artice, have seen the error in frontend logged in as test user .
After applying the path the error was gone
I have tested this item ✅ successfully on 932ec53
Did create user and artice, have seen the error in frontend logged in as test user .
After applying the path the error was gone
I have tested this item ✅ successfully on 932ec53
Tested successfully during PR Testing meet.
I have tested this item ✅ successfully on 932ec53
Tested successfully during PR Testing meet.
Sorry, all my sites are running with J6.1 - including test-sites. A test with J5.4 was done in the meantime by TomasFinnern (thx). Hope those will help.
| Status | Pending | ⇒ | Ready to Commit |
RTC
RTC
| Labels |
Added:
RTC
bug
|
||
| Status | Ready to Commit | ⇒ | Fixed in Code Base |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-05-10 10:05:42 |
| Closed_By | ⇒ | richard67 |
Thanks @CSGoat0 for this PR, @ThomasFinnern and @krishnagandhicode for testing, and @joomdonation for reviw and support.
Checked on a J6.1.0 System. Is working, user with author-rights now is able to open previews. Thx!