Skip to content

Commit d85d75c

Browse files
authored
[6.0] Optimise checks in plg_behaviour_versionable (#46360)
* remove model from versionable plugin * remove use of VersionableModelInterface * Further clean up to Versionable plugin * add token to strtok()
1 parent 3175e39 commit d85d75c

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

plugins/behaviour/versionable/src/Extension/Versionable.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Joomla\CMS\Event\Table\BeforeDeleteEvent;
1616
use Joomla\CMS\Helper\CMSHelper;
1717
use Joomla\CMS\Plugin\CMSPlugin;
18-
use Joomla\CMS\Versioning\VersionableModelInterface;
1918
use Joomla\CMS\Versioning\VersionableTableInterface;
2019
use Joomla\CMS\Versioning\Versioning;
2120
use Joomla\Event\SubscriberInterface;
@@ -107,24 +106,14 @@ public function onTableAfterStore(AfterStoreEvent $event)
107106

108107
$result = $event['result'];
109108

110-
$typeAlias = $table->getTypeAlias();
111-
[$component, $modelName] = explode('.', $typeAlias);
112-
113-
$model = $this->getApplication()->bootComponent($component)->getMVCFactory()->createModel($modelName, 'Administrator');
114-
115-
if ($model instanceof VersionableModelInterface) {
116-
return;
117-
}
118-
119109
if (!$result) {
120110
return;
121111
}
122112

123-
if (!(\is_object($table))) {
124-
return;
125-
}
113+
$typeAlias = $table->getTypeAlias();
114+
$component = strtok($typeAlias, '.');
126115

127-
// Get the Tags helper and assign the parsed alias
116+
// Do not store version if version history is not enabled for the component
128117
if ($component === '' || !ComponentHelper::getParams($component)->get('save_history', 0)) {
129118
return;
130119
}

0 commit comments

Comments
 (0)