User tests: Successful: Unsuccessful:
Our versioning works on databse table level, this leads to situations that we save an article with custom fields but the CF are not included in the history. This is unexpected from a user perspective. This PR starts to change this behaviour so that releated information are also saved.
I have added an interface VersionableModelInterface, if a model implements this interface then in AdminModel the save of the histroy data is done in the save method (calls saveHistory) of the Model. This is the first step and we have now the data with releated information in the history table.
If you want to restore a version then in loadHistory (VersionableModelTrait) set the data from the history table as session data and loadForm use this data when you edit an item.
It works for CF so far. At the moment not for Tags (tags is a pain, we might change more on tags for 6 so I haven't looked into the details why not).
This is a b/c break and I don't know how many are affected but I think that it can't be too much hassle and what we get when we finish this is worth the work for extensions developers.
It is now done for all core extensions and item whitch supports versions
Custom fields have always the last saved value
Custom fields have the value from the saved version, Tags get restored
Documentation will be provided at a later stage.
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_contact com_content com_contenthistory Libraries Front End Plugins |
Labels |
Added:
PR-6.0-dev
|
Labels |
Added:
b/c break
|
I have tested this item β
successfully on eb8533b
Successful tested with a text-, integer-, list- and checkboxfield(s).
B.t.w.
Comparing versions is throwing an error:
https://prnt.sc/bvWwN0TaKwSq
with or without this patch
Title |
|
Labels |
Added:
Feature
|
Category | Administration com_contact com_content com_contenthistory Libraries Front End Plugins | ⇒ | Administration com_banners com_categories com_contact com_content com_contenthistory com_newsfeeds com_tags com_users Libraries Front End Plugins |
I now know why the tests are failing, when creating a banner over the api only the table class is used and not the model. So the problem is "only" an API problem.
I also got the An error has occurred. 0 htmlspecialchars(): Argument #1 ($string) must be of type string, array given
error when comparing with or without, but the PR certainly restores the custom fields and tags restored, really nice feature
I now know why the tests are failing, when creating a banner over the api only the table class is used and not the model. So the problem is "only" an API problem.
@rdeutz Then the failing API test should be commented out with a to do comment so that system tests are passing. Merging this PR as it is would mean to break system tests in the 6.0-dev branch.
Category | Administration com_contact com_content com_contenthistory Libraries Front End Plugins com_banners com_categories com_newsfeeds com_tags com_users | ⇒ | Administration com_banners com_categories com_contact com_content com_contenthistory com_newsfeeds com_tags com_users Language & Strings Libraries Front End Plugins |
Labels |
Added:
Language Change
|
Title |
|
I have tested this item π΄ unsuccessfully on 541f78e
I installed the blog sample data
I edited the content of the typography article
I entered some data in the author field of the typography article
Then I clicked ion the versions button and selected the two versions and clicked on compare
An error has occurred.
htmlspecialchars(): Argument #1 ($string) must be of type string, array given
Function | Location | |
---|---|---|
1 | () | JROOT\administrator\components\com_contenthistory\tmpl\compare\compare.php:105 |
2 | htmlspecialchars() | JROOT\administrator\components\com_contenthistory\tmpl\compare\compare.php:105 |
3 | include() | JROOT\libraries\src\MVC\View\HtmlView.php:416 |
4 | Joomla\CMS\MVC\View\HtmlView->loadTemplate() | JROOT\libraries\src\MVC\View\HtmlView.php:204 |
5 | Joomla\CMS\MVC\View\HtmlView->display() | JROOT\administrator\components\com_contenthistory\src\View\Compare\HtmlView.php:64 |
6 | Joomla\Component\Contenthistory\Administrator\View\Compare\HtmlView->display() | JROOT\libraries\src\MVC\Controller\BaseController.php:697 |
7 | Joomla\CMS\MVC\Controller\BaseController->display() | JROOT\libraries\src\MVC\Controller\BaseController.php:730 |
8 | Joomla\CMS\MVC\Controller\BaseController->execute() | JROOT\libraries\src\Dispatcher\ComponentDispatcher.php:143 |
9 | Joomla\CMS\Dispatcher\ComponentDispatcher->dispatch() | JROOT\libraries\src\Component\ComponentHelper.php:361 |
10 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT\libraries\src\Application\AdministratorApplication.php:150 |
11 | Joomla\CMS\Application\AdministratorApplication->dispatch() | JROOT\libraries\src\Application\AdministratorApplication.php:205 |
12 | Joomla\CMS\Application\AdministratorApplication->doExecute() | JROOT\libraries\src\Application\CMSApplication.php:315 |
13 | Joomla\CMS\Application\CMSApplication->execute() | JROOT\administrator\includes\app.php:58 |
14 | require_once() | JROOT\administrator\index.php:32 |
Test and the compare view is fixed, so this here is ready to test again.
@exlemor could you give some more information what you did. As you can see it is working for other people, so it would be good to know more details.
Hi Robert, I'll try to remember but to be honest, after the medication I have been on due to hospital visit on Monday, not entirely sure my memory will recollect 100%, but basically I tested your PR as you instructed and with your PR activated, I would try to restore an article and I would get a blank page (i.e. code view = blank), and at other times not but no error or console messages but now that a bunch of work has been done on it. I will retest it for you sometime today, I'm not 100% yet and with the heat wave not helping, but I'll do my best.
Thanks for testing @brianteeman I think I have missed a case. I made a change and pushed it. I tried to check locally but -funny enough- the sampledata plugins are not working here. Please retest if I have made the correct change.
I like this so much. I will test it later as soon as I find the time and would be very happy if we could get it in for the Release.
The only thing that strikes me right away is that we definitely need an addition to the documentation for developers. Previously, everything that was saved directly via $table->store
for example was also versioned, but that is no longer the case and, in my experience, is sometimes used to bend data. We should at least issue a note about this.
Applied the latest changes and did the exact same check
Now the page is full with this warning
Warning: Array to string conversion in D:\repos\j6\administrator\components\com_contenthistory\tmpl\compare\compare.php on line 102
@brianteeman thanks I will try to get sampledata installed and try on my own.
@LadySolveig The only thing you need to do, if you have used versioning in your component, is in the model add "implements VersionableModelInterface". That's all. But I agree we need documentation and I will write it, when it works without errors.
I have tested this item π΄ unsuccessfully on 5d68b82
I have test this unsuccessfully. ;( Sorry @rdeutz
I downloaded the Update Package from the Download button built on Thu Aug 14 18:28:10 UTC 2025
When comparing 2 versions of the article, I get the same error Brian got:
An error has occurred.
0 htmlspecialchars(): Argument #1 ($string) must be of type string, array given
Going further, and this MAY be beyond this PR, I apologize as I rarely restore older versions of Articles,
when I preview an article that has an image in it, the image preview is broken?
when having added/removed tags from a version, I do see a newTags ["5","4"] and Tags ["5","4"] section in the popup preview window but those are numbers not the Tags themselves? (perhaps expected but not very user friendly)
At the moment it is more important to test if the functionallity works. So can you restore an older version of an article, banner etc.
The problem with the compare/preview view is that you have a structure to show that is not fixed, it is array of array ... of array and to have the diff between it you need to convert this into a flat table. I have made a fix to show the data without error but it is not pretty.
@exlemor do you know the line where the error was?
I have tested this item β
successfully on 5d68b82
Article, tags and custom fields tested with different versions and restore - works for me.
I have tested this item β
successfully on 5d68b82
I was able to successfully. Thanks to @rdeutz, @LadySolveig, @softforge, @Bodge-IT !
I have tested this item π΄ unsuccessfully on 5d68b82
I have tested this item π΄ unsuccessfully on 5d68b82Version Note
not working
@exlemor @LadySolveig did you not get these errors
@LadySolveig thank you for your time explaining the need to push this through (because of its b/c breaking changes) and that the visual display will be fixed before final release or it will have to be reverted
Confirmed the problem with the version note and fixed it.
Didn't get the button disappear problem reproduced, but will try later.
I have tested this item β
successfully on c027b4d
I have re-tested this successfully. Thanks @rdeutz! Keep up the great work!
When you restore to the initial version the buttons disappear AND you cannot save the article
See video
I have tested this item π΄ unsuccessfully on c027b4d
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2025-08-17 10:35:17 |
Closed_By | ⇒ | softforge |
Thank you to @rdeutz for his work on this and to @LadySolveig and @richard67 for the work they did fixing this to the point we could merge. Thank you to all the testers and also for the work done by @brianteeman to make sure deficiencies were noted and documented so we have a clear measure of what must be done to get this ready before RC
I have tested this item π΄ unsuccessfully on c027b4d
@heelc29 Could you open a new issue with your findings? Maybe @brianteeman could then add his findings, too.
Thank you all for testing and pointing out the issues. I know there are still issues and I will do my best to fix them asap.
At the bottom of the Preview of Version form there is a com_fields
label that looks like an untranslated string, along with two others above and one below. Is that a bug? And the current version is not marked! The Help screen says it is.
I have tested this item β successfully on eb8533b
Successful tested with a text-, integer-, list- and checkboxfield(s).
B.t.w.
Comparing versions is throwing an error:
https://prnt.sc/bvWwN0TaKwSq
with or without this patch
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45515.