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
Original file line number Diff line number Diff line change
Expand Up @@ -9271,6 +9271,9 @@ msgstr "Fehler beim Erstellen eines Tasks"
msgid "The current user is invalid."
msgstr "Task-Typ ist nicht gültig"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9280,6 +9280,9 @@ msgstr "Failed to create task"
msgid "The current user is invalid."
msgstr "Task type is not valid"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9443,6 +9443,9 @@ msgstr "No se pudo crear la tarea"
msgid "The current user is invalid."
msgstr "tipo de tarea no es válida"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9272,6 +9272,9 @@ msgstr "Fehler beim Erstellen eines Tasks"
msgid "The current user is invalid."
msgstr "Task-Typ ist nicht gültig"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9265,6 +9265,9 @@ msgstr "Impossible de créer la tâche"
msgid "The current user is invalid."
msgstr "Type de tâche n'est pas valide"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8986,6 +8986,9 @@ msgstr "Impossibile creare un'attività"
msgid "The current user is invalid."
msgstr "Tipo di attività non è valido"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8929,6 +8929,9 @@ msgstr "タスクの作成に失敗しました"
msgid "The current user is invalid."
msgstr ""

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
3 changes: 3 additions & 0 deletions packages/web/management/languages/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -7905,6 +7905,9 @@ msgstr ""
msgid "The current user is invalid."
msgstr ""

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9267,6 +9267,9 @@ msgstr "Falha ao criar tarefa"
msgid "The current user is invalid."
msgstr "tipo de tarefa não é válido"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9267,6 +9267,9 @@ msgstr "无法创建任务"
msgid "The current user is invalid."
msgstr "任务类型无效"

msgid "The database refused the update; nothing was changed"
msgstr ""

msgid "The default printer for hosts in this group. A host that has its own default keeps it."
msgstr ""

Expand Down
25 changes: 22 additions & 3 deletions packages/web/src/Pages/HostManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -4226,9 +4226,18 @@ private function massEditSelection()
private function massEditCoreFields()
{
return [
// NULL, not 0. `hosts`.`hostImage` carries a foreign key to
// `images`.`imageID` (ADR 0031, schema-constraints.php:145) and
// 0 is not exempt from a constraint just because it looks like
// an absence -- there is no image with id 0, so clearing to 0 is
// rejected outright and the whole mass edit fails. The column is
// nullable and the reconciler already swept every legacy 0 to
// NULL, so NULL is what "no image" actually IS on any 1.6
// database. Verified against a live install: 77 hosts hold NULL
// and none holds 0.
'image' => [
'field' => 'imageID',
'empty' => 0,
'empty' => null,
'label' => _('Image'),
'kind' => 'image',
'tab' => 'general'
Expand Down Expand Up @@ -5143,8 +5152,18 @@ public function massEditPost()
// non-empty because an UPDATE with no assignments is either
// a syntax error or, worse, a statement whose WHERE is the
// only part left.
self::getClass('HostManager')
->update(['id' => $hosts], '', $updates);
// The return value is CHECKED. perform_update() answers
// false and writes a fault rather than throwing, so ignoring
// it reported "Updated 1 field(s) on 86 host(s)" for a write
// the database had refused -- which is how a clear that
// never landed reads as a clear that did.
if (!self::getClass('HostManager')
->update(['id' => $hosts], '', $updates)
) {
throw new \Exception(
_('The database refused the update; nothing was changed')
);
}
$affected = count($hosts);
}
// Row-backed fields count toward the same affectedCount: one
Expand Down
29 changes: 22 additions & 7 deletions packages/web/src/Util/MassEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@ public static function resolveComposite(array $keys, $actions, $values)
* @param array $resolved output of resolve()
* @param array $spec key => ['field' => <FOGController field name>,
* 'empty' => <what CLEAR writes, default ''>].
* A key absent from the spec is skipped: the spec
* is what says a key may touch a column at all.
* `empty` may be null, and null is written as
* NULL rather than treated as absent -- that is
* what a column with a foreign key needs. A key
* absent from the spec is skipped: the spec is
* what says a key may touch a column at all.
*
* @return array field name => value, ready for a manager update(). EMPTY
* when nothing was set or cleared -- and an empty map must
Expand Down Expand Up @@ -260,11 +263,23 @@ public static function columnUpdates(array $resolved, array $spec)
$updates[$spec[$key]['field']] = $instruction['value'];
} elseif (self::CLEAR === $action) {
// Per field, because "empty" is not one value. A varchar
// column clears to '', an int foreign key to 0; writing ''
// into an int column stores 0 on a permissive server and
// errors on a strict one, so the answer belongs in the spec
// rather than in a cast here.
$updates[$spec[$key]['field']] = $spec[$key]['empty'] ?? '';
// column clears to '', a plain int to 0, and a column
// carrying a FOREIGN KEY to null -- 0 is not exempt from a
// constraint, so clearing `hosts`.`hostImage` to 0 is
// rejected outright unless an image with id 0 exists, which
// none does. The answer belongs in the spec rather than in a
// cast here.
//
// array_key_exists, NOT `?? ''`. Null is the whole point for
// the foreign-key case and `??` treats it as absent, so the
// coalesce silently turned every intended NULL back into ''
// -- which an int column then stores as 0, i.e. exactly the
// value that fails. A spec that genuinely omits `empty`
// still gets ''.
$updates[$spec[$key]['field']] =
array_key_exists('empty', $spec[$key])
? $spec[$key]['empty']
: '';
}
}

Expand Down
Loading
Loading