[6.2] Fix unpublished articles preview - #47569
Conversation
'6a commit message to explain why this merge is necessary, Merge upstream/main into problem-branch
|
As you can see from the test this breaks on postgres as you have only updated the installation sql for mysql - you need to do the same change for postgres You also need to have update sql for existing installations |
Hello, thanks for the help! |
That would need to be fixed with this issue |
…e\DatabaseInterface::class)
Hello, could you please confirm if the accessibility check is not working as it is for me now? (please check my last comment). |
|
the jooa11y error was unrelated to the changes here and is fixed with #47579 |
|
I will leave it to others with more architecture experience to comment on the code. From a user experiece this works well and is a good and useful addition to Joomla |
Thanks! I appreciate that. I have also fixed another bug yesterday |
|
I have tested this item 🔴 unsuccessfully on 8e6789b Unfortunately, after applying Patch, and trying to test Scenario 1, I get a Joomla crash/error: An error has occurred. Mentioned to Abdelrahman. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47569. |
Yes, you are right. It is because I created the table manually as i've mentioned in the pr. didn't test it without the table back then, but now i tried it now and it doesn't work. |
|
@exlemor Hi, It seems like we had to update structure at |
Remove unnecessary extension trail. Co-authored-by: Quy Ton <quy@nomonkeybiz.com>
…/CSGoat0/joomla-cms into fix-unpublished-articles-preview adding imports
|
Update, Accessibility check (jooa11y) is now working perfectly for unpublished Articles✅. |
|
I have tested this item ✅ successfully on caa1fe7 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/47569. |
|
imho |
|
There are few things which we need to decide:
This should be discussed by maintainers for further improvements to current code. As this current state, the PR could not be merged. |
|
@joomdonation for every new token generated (regardless of which article), all expired tokens in the table About the expiration time, I'm fine adding whatever value is agreed on. I'm just not sure how you'd That's what I have in mind for these two points for now. |
Are you open for an alternative implementation which does not require storing tokens in database table as I mentioned earlier? If Yes, maybe we can find sometime to chat about it on Mattermost. |
|
@joomdonation, of course! |
|
Alternative PR #48030. |
|
Hi @CSGoat0 This PR does not need/ should not be closed because there is no final decision yet. I prefer the alternative PR because it is simpler, does not need extra database table but your PR is also a good one(although it is not yet completed). We can have two PRs open and maintainers will make final decision. |




Pull Request resolves #47370
Summary of Changes
This PR implements a secure, time-limited token-based preview system that allows administrators to preview articles regardless of their publishing date or published state, even when "Shared Sessions" is disabled in Global Configuration.
Key changes:
#__content_preview_tokensto store preview tokens with expiration&preview=1and a unique tokenisAdminPreview()validation method in the frontendArticleModelto verify valid preview requestsTesting Instructions
Prerequisites:
System -> Maintenance -> Database. Select the6.2.0-2026-04-11 Database Versionand clickUpdate Structure. Otherwise, you will get1146 Table 'lights_db.j62a1_content_preview_tokens' doesn't existTest Scenario 1: Future-dated article preview
Test Scenario 2: Unpublished article preview
Actual result BEFORE applying this Pull Request
When "Shared Sessions" is disabled:
Expected result AFTER applying this Pull Request
When "Shared Sessions" is disabled:
Implementation Details
1. New Database Table (
#__content_preview_tokens)2. Token Generation (
administrator/components/com_content/src/View/Article/HtmlView.php)random_bytes(16)&preview=1&preview_token={token}to both standard preview and accessibility (jooa11y) preview links3. Token Validation (
components/com_content/src/Model/ArticleModel.php)preview=1parameter in the requestcore.edit.statepermissiontrueonly if all validation passes4. Filter Bypass Logic
publish_up/publish_down) are skipped whenisAdminPreview()returnstrueisAdminPreview()returnstrueisAdminPreview()returnstrueSecurity Considerations
core.edit.statepermissionAdditional Notes
Testing performed:
Database installation:
The table creation query was tested via phpMyAdmin on an existing Joomla installation.
Note on branch targeting:
I understand that bug fixes are typically made against the
5.4branch, while new features target6.2. However, since my solution introduces a new database table and implements a token-based preview system (which adds new functionality to the core), I believe this could be a feature rather than a pure bug fix. Therefore, I have developed this against the6.2branch. If the maintainers prefer this to be backported or handled differently, I'm happy to adjust accordingly.Link to documentations
Please select: