Skip to content

Commit 84c29f0

Browse files
authored
Fix isntall (#1134)
* Fix(Install): fix template generation error * adapt changelog * force genericobject load * fix CLI install
1 parent 0f8ff9c commit 84c29f0

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [UNRELEASED]
9+
10+
- Fix template generation error on update
11+
12+
813
## [1.21.26] - 2026-02-12
914

1015
### Fixed

inc/container.class.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,16 @@ public static function generateTemplate($fields)
687687
['%%CLASSNAME%%', '%%ITEMTYPE%%', '%%CONTAINER%%', '%%ITEMTYPE_RIGHT%%'],
688688
[
689689
$classname,
690-
var_export($itemtype, true),
690+
str_replace('\'', '', var_export($itemtype, true)),
691691
var_export($fields['id'], true),
692692
var_export($itemtype::$rightname, true),
693693
],
694694
$template_class,
695695
);
696696

697+
Toolbox::logDebug(str_replace('\'', '', var_export($itemtype, true)));
698+
Toolbox::logDebug(var_export($itemtype, true));
699+
697700
$class_filename = basename($sysname) . '.class.php';
698701
$filepath = rtrim(PLUGINFIELDS_CLASS_PATH, '/') . '/' . $class_filename;
699702
if (file_put_contents($filepath, $template_class) === false) {
@@ -712,7 +715,7 @@ public static function generateTemplate($fields)
712715
['%%CLASSNAME%%', '%%ITEMTYPE%%', '%%CONTAINER_ID%%', '%%CONTAINER_NAME%%'],
713716
[
714717
$classname,
715-
var_export($itemtype, true),
718+
str_replace('\'', '', var_export($itemtype, true)),
716719
var_export($fields['id'], true),
717720
var_export($fields['label'], true),
718721
],

setup.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ function plugin_init_fields()
8686
$pluginfields_autoloader = new PluginFieldsAutoloader([PLUGINFIELDS_CLASS_PATH]);
8787
$pluginfields_autoloader->register();
8888

89+
Plugin::load('genericobject', true);
90+
8991
if ((Session::getLoginUserID() || isCommandLine()) && Plugin::isPluginActive('fields')) {
9092
// Init hook about itemtype(s) for plugin fields
9193
if (!isset($PLUGIN_HOOKS['plugin_fields'])) {

templates/container.class.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class %%CLASSNAME%% extends PluginFieldsAbstractContainerInstance
5151
* This block ensures that the 'entities_id' field is created and populated if it
5252
* associated item type requires entity assignment
5353
*/
54-
if (getItemForItemtype("%%ITEMTYPE%%")->isEntityAssign() && !$DB->fieldExists($table, 'entities_id')) {
54+
if (getItemForItemtype(%%ITEMTYPE%%::class)->isEntityAssign() && !$DB->fieldExists($table, 'entities_id')) {
5555
$migration->addField($table, 'entities_id', 'fkey', ['after' => 'plugin_fields_containers_id']);
5656
$migration->addKey($table, 'entities_id');
5757
$migration->executeMigration();
@@ -107,7 +107,7 @@ class %%CLASSNAME%% extends PluginFieldsAbstractContainerInstance
107107
* associated item type requires recursive assignment
108108
*/
109109
if (
110-
getItemForItemtype("%%ITEMTYPE%%")->maybeRecursive()
110+
getItemForItemtype(%%ITEMTYPE%%::class)->maybeRecursive()
111111
&& !$DB->fieldExists($table, 'is_recursive')
112112
&& $DB->fieldExists($table, 'entities_id')) {
113113
$migration->addField($table, 'is_recursive', 'bool', ['after' => 'entities_id']);

0 commit comments

Comments
 (0)