User tests: Successful: Unsuccessful:
Pull Request for Issue #46211 and #46213.
Custom field data is not part of the item data we get from getItem(), we get this data from the form. I have added form handeling into the prozess to decide if the data has changed and what is the currently used version.
Check the issues for instructions
Not expected behaviour
Works as expected.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_content com_contenthistory Libraries |
Title |
|
I will try and get some more tests on this tomorrow at jd nl. Thank you for your prompt action @rdeutz and @tecpromotion for testing
So, i've tested, but an issue.
Info: tested by applying this patch only on a 6.0.0-rc1 install.
If i only edit custom field, and click on Save, the new value is not stored in history com_fields and no star next to last store.
If i click again on save, without other change, then the star is displayed and the custom field is stored.
i've found a way to make it work, but needs review to check if it's the best way, as issue is the new hash with com_fields is not stored in the item on first save.
i've added your code form HistoryModel
and adapted it in libraries/src/Versioning/VersionableModelTrait.php
after line 380 in storeHistory()
This way, the hash is updated in $item
on save with custom fields included in the hash.
$model = Factory::getApplication()->bootComponent($extension)->getMVCFactory()->createModel($type, 'Administrator');
if ($model instanceof VersionableModelInterface) {
$path = JPATH_BASE . '/components/' . $extension;
Form::addFormPath($path . '/forms');
Form::addFormPath($path . '/models/forms');
Form::addFieldPath($path . '/models/fields');
Form::addFormPath($path . '/model/form');
Form::addFieldPath($path . '/model/field');
// This is needed to make sure the model has called populateState
$tmp = $model->getState();
// Now we can set the article.id and it is not overwritten later by populateState
$model->setState('article.id', $id);
$item = $model->getItem();
$form = $model->getForm();
$cf = $form->getData()->get('com_fields', null);
if (!empty($cf)) {
$item->com_fields = $cf;
}
$hash = $model->getSha1($item);
}
And now, it's working prefectly.
The star is present as well.
@RobertDeutz I'm testing this PR and I noticed this behavior which is probably not correct.
I create an article and a custom field and add content to both and save
Next create a new custom field, open the same article, fill a value in the new custom field and save.
If I the go back to the version which did not have the second custom field, the value of the second custom field will still be there.
It probably should be empty as the field was not there before.
Labels |
Added:
Release Blocker
bug
PR-6.0-dev
|
@RickR2H good finding, I am not sure if this is a bug. There might be arguments to say not existing is not the same as empty. I will not change it for now. I want to hear some more ideas what is the expected behaivour.
Thanks @RobertDeutz I'll ignore the behavior for now as I get that it's not clear in what the behavior should be.
I have tested this item ✅ successfully on 11989e3
The star is now working when a custom field value is changed. Values are present in history table.
I have added the suggestion from @cyrez. retest would be great.
I realize that in my version, i've added use Joomla\CMS\Versioning\VersionableModelInterface;
in libraries/src/Versioning/VersionableModelTrait.php
but it seems not needed when VersionableModelTrait is called from the librairie... Good to know.
@RobertDeutz I'm testing this PR and I noticed this behavior which is probably not correct.
I create an article and a custom field and add content to both and save Next create a new custom field, open the same article, fill a value in the new custom field and save. If I the go back to the version which did not have the second custom field, the value of the second custom field will still be there. It probably should be empty as the field was not there before.
It seems to me that with update PR, this issue is fixed as well? At least, i don't have it.
I have tested this item ✅ successfully on 11989e3
Updated PR is working fine!
Thanks @rdeutz
Status | Pending | ⇒ | Ready to Commit |
RTC
I have tested this item ✅ successfully on 11989e3
I have tested this item ✅ successfully on fd764b5
In general, it now works as expected.
What is not displayed is the star in the current version when I only change custom field values.

However, if I change something in the content or the alt text of the intro image, I get a star in the current entry.

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46221.