-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't bulk-update Yes/No fields to yes #914
Comments
When i setup a dropdown fields and create the value Yes and N, i can bulk update, so the issue is with Yes/No premade option |
The compatibility error is at line 1660 of file src/MassiveAction.php in GLPI (not the plugin) files. case 'update':
if (
(!isset($ma->POST['search_options']))
|| (!isset($ma->POST['search_options'][$item->getType()]))
) {
return false;
}
$index = $ma->POST['search_options'][$item->getType()];
$searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
$input = $ma->POST;
if (isset($searchopt[$index])) {
/// Infocoms case
if (Search::isInfocomOption($item->getType(), $index)) {
$ic = new Infocom();
$link_entity_type = -1;
$is_recursive = 0;
/// Specific entity item
if ($searchopt[$index]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($input[$input["field"]])) {
$link_entity_type = $ent->fields["entities_id"];
$is_recursive = $ent->fields["is_recursive"];
}
}
foreach ($ids as $key) {
if ($item->getFromDB($key)) {
if (
($link_entity_type < 0)
|| ($link_entity_type == $item->getEntityID())
|| ($is_recursive
&& in_array(
$link_entity_type,
getAncestorsOf(
"glpi_entities",
$item->getEntityID()
)
))
) {
$input2 = [
'items_id' => $key,
'itemtype' => $item->getType()
];
if ($ic->can(-1, CREATE, $input2)) {
// Add infocom if not exists
if (!$ic->getFromDBforDevice($item->getType(), $key)) {
$input2["items_id"] = $key;
$input2["itemtype"] = $item->getType();
unset($ic->fields);
$ic->add($input2);
$ic->getFromDBforDevice($item->getType(), $key);
}
$id = $ic->fields["id"];
unset($ic->fields);
if (
$ic->update(['id' => $id,
$input["field"] => $input[$input["field"]]
])
) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
} else { /// Not infocoms
$link_entity_type = [];
/// Specific entity item
$itemtable = getTableForItemType($item->getType());
$itemtype2 = getItemTypeForTable($searchopt[$index]["table"]);
if ($item2 = getItemForItemtype($itemtype2)) {
if (
($index != 80) // No entities_id fields
&& ($searchopt[$index]["table"] != $itemtable)
&& $item2->isEntityAssign()
&& $item->isEntityAssign()
) {
if ($item2->getFromDB($input[$input["field"]])) {
if (
isset($item2->fields["entities_id"])
&& ($item2->fields["entities_id"] >= 0)
) {
if (
isset($item2->fields["is_recursive"])
&& $item2->fields["is_recursive"]
) {
$link_entity_type = getSonsOf(
"glpi_entities",
$item2->fields["entities_id"]
);
} else {
$link_entity_type[] = $item2->fields["entities_id"];
}
}
}
}
}
foreach ($ids as $key) {
if (
$item->canEdit($key)
&& $item->canMassiveAction(
$action,
$input['field'],
$input[$input["field"]]
)
) {
if (
(count($link_entity_type) == 0)
|| in_array($item->fields["entities_id"], $link_entity_type)
) {
if (
$item->update(['id' => $key,
$input["field"] => $input[$input["field"]]
])
) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT)); <-- Error message from here
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
}
}
break; string(27) "item2 fields"
array(7) {
["id"]=>
int(1)
["items_id"]=>
int(4648)
["itemtype"]=>
string(8) "Computer"
["plugin_fields_containers_id"]=>
int(16)
["entities_id"]=>
int(0)
["is_recursive"]=>
int(0)
["testfield"]=>
int(0)
}
string(14) "item fields : "
array(30) {
["id"]=>
int(4648)
["entities_id"]=>
int(3)
["name"]=>
string(14) "po-b11s114-015"
["serial"]=>
string(10) "5CD221D1R5"
["otherserial"]=>
string(0) ""
["contact"]=>
string(20) "Kevin@PO-B11S114-015"
["contact_num"]=>
NULL
["users_id_tech"]=>
int(0)
["groups_id_tech"]=>
int(7)
["comment"]=>
string(5) "Kevin"
["date_mod"]=>
string(19) "2025-01-29 13:33:31"
["autoupdatesystems_id"]=>
int(1)
["locations_id"]=>
int(1632)
["networks_id"]=>
int(0)
["computermodels_id"]=>
int(201)
["computertypes_id"]=>
int(2)
["is_template"]=>
int(0)
["template_name"]=>
NULL
["manufacturers_id"]=>
int(47)
["is_deleted"]=>
int(0)
["is_dynamic"]=>
int(1)
["users_id"]=>
int(2485)
["groups_id"]=>
int(7)
["states_id"]=>
int(2)
["ticket_tco"]=>
string(6) "0.0000"
["uuid"]=>
string(36) "5B347167-A604-45EB-9416-926995D167C3"
["date_creation"]=>
string(19) "2024-03-01 16:22:07"
["is_recursive"]=>
int(0)
["last_inventory_update"]=>
string(19) "2025-01-22 16:09:52"
["last_boot"]=>
string(19) "2025-01-21 08:26:27"
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code of Conduct
Is there an existing issue for this?
GLPI Version
10.0.17
Plugin version
1.21.18
Bug description
When i try to bulk update a custom Yes/No fields on computers, i get the following error :
Relevant log output
I don't see anything happen in the logs when i update a value
Page URL
No response
Steps To reproduce
Your GLPI setup information
Information about system installation and configuration
Server
GLPI constants
Libraries
LDAP directories
SQL replicas
Notifications
Plugins list
Anything else?
No response
The text was updated successfully, but these errors were encountered: