Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

- Fix template generation error on update


## [1.21.26] - 2026-02-12

### Fixed
Expand Down
7 changes: 5 additions & 2 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,16 @@ public static function generateTemplate($fields)
['%%CLASSNAME%%', '%%ITEMTYPE%%', '%%CONTAINER%%', '%%ITEMTYPE_RIGHT%%'],
[
$classname,
var_export($itemtype, true),
str_replace('\'', '', var_export($itemtype, true)),
var_export($fields['id'], true),
var_export($itemtype::$rightname, true),
],
$template_class,
);

Toolbox::logDebug(str_replace('\'', '', var_export($itemtype, true)));
Toolbox::logDebug(var_export($itemtype, true));

$class_filename = basename($sysname) . '.class.php';
$filepath = rtrim(PLUGINFIELDS_CLASS_PATH, '/') . '/' . $class_filename;
if (file_put_contents($filepath, $template_class) === false) {
Expand All @@ -712,7 +715,7 @@ public static function generateTemplate($fields)
['%%CLASSNAME%%', '%%ITEMTYPE%%', '%%CONTAINER_ID%%', '%%CONTAINER_NAME%%'],
[
$classname,
var_export($itemtype, true),
str_replace('\'', '', var_export($itemtype, true)),
var_export($fields['id'], true),
var_export($fields['label'], true),
],
Expand Down
2 changes: 2 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ function plugin_init_fields()
$pluginfields_autoloader = new PluginFieldsAutoloader([PLUGINFIELDS_CLASS_PATH]);
$pluginfields_autoloader->register();

Plugin::load('genericobject', true);

if ((Session::getLoginUserID() || isCommandLine()) && Plugin::isPluginActive('fields')) {
// Init hook about itemtype(s) for plugin fields
if (!isset($PLUGIN_HOOKS['plugin_fields'])) {
Expand Down
4 changes: 2 additions & 2 deletions templates/container.class.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class %%CLASSNAME%% extends PluginFieldsAbstractContainerInstance
* This block ensures that the 'entities_id' field is created and populated if it
* associated item type requires entity assignment
*/
if (getItemForItemtype("%%ITEMTYPE%%")->isEntityAssign() && !$DB->fieldExists($table, 'entities_id')) {
if (getItemForItemtype(%%ITEMTYPE%%::class)->isEntityAssign() && !$DB->fieldExists($table, 'entities_id')) {
$migration->addField($table, 'entities_id', 'fkey', ['after' => 'plugin_fields_containers_id']);
$migration->addKey($table, 'entities_id');
$migration->executeMigration();
Expand Down Expand Up @@ -107,7 +107,7 @@ class %%CLASSNAME%% extends PluginFieldsAbstractContainerInstance
* associated item type requires recursive assignment
*/
if (
getItemForItemtype("%%ITEMTYPE%%")->maybeRecursive()
getItemForItemtype(%%ITEMTYPE%%::class)->maybeRecursive()
&& !$DB->fieldExists($table, 'is_recursive')
&& $DB->fieldExists($table, 'entities_id')) {
$migration->addField($table, 'is_recursive', 'bool', ['after' => 'entities_id']);
Expand Down