Overview
Comment: | Module data storing fixed (data update through save() call) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA3-256: |
ca62dd132dc110b53bdad7df82a73706 |
User & Date: | alinaar on 2023-01-19 19:24:11 |
Other Links: | branch diff | manifest | tags |
Context
2023-01-19
| ||
19:35 | Module data storing fix check-in: 7c2598f8d4 user: alinaar tags: dev | |
19:24 | Module data storing fixed (data update through save() call) check-in: ca62dd132d user: alinaar tags: dev | |
15:36 | Module data storing (save method) fixed check-in: cdc036d187 user: alinaar tags: dev | |
Changes
Modified src/include/lib/Garradin/UserTemplate/Functions.php from [5242638807] to [d323510a08].
︙ | ︙ | |||
89 90 91 92 93 94 95 | $table = 'module_data_' . $name; if (!empty($params['key'])) { if ($params['key'] == 'uuid') { $params['key'] = Utils::uuid(); } | | | > | | | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | $table = 'module_data_' . $name; if (!empty($params['key'])) { if ($params['key'] == 'uuid') { $params['key'] = Utils::uuid(); } $field = 'key'; $where_value = $params['key']; } elseif (!empty($params['id'])) { $field = 'id'; $where_value = $params['id']; } else { throw new Brindille_Exception('Aucun paramètre "id" ou "key" n\'a été renseigné'); } $key = $params['key'] ?? null; $id = $params['id'] ?? null; unset($params['key'], $params['id']); $validate = null; if (isset($params['validate_schema'])) { $validate = $params['validate_schema']; unset($params['validate_schema']); } $db = DB::getInstance(); if ($key == 'config') { $exists = $db->firstColumn(sprintf('SELECT config AS value FROM %s WHERE name = ?;', Module::TABLE), $name); } else { $db->exec(sprintf(' CREATE TABLE IF NOT EXISTS %s ( id INTEGER NOT NULL PRIMARY KEY, key TEXT NULL, value TEXT NOT NULL ); CREATE UNIQUE INDEX IF NOT EXISTS %1$s_key ON %1$s (key);', $table)); $exists = $db->first(sprintf('SELECT value FROM %s WHERE %s;', $table, ($field . ' = ?')), $where_value); } $exists = json_decode((string) $exists->value, true); // Merge before update if ($exists) { $params = array_merge($exists, $params); } // Remove NULL values |
︙ | ︙ | |||
162 163 164 165 166 167 168 | return; } if (!$exists) { $db->insert($table, compact('value', 'key')); } else { | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | return; } if (!$exists) { $db->insert($table, compact('value', 'key')); } else { $db->update($table, compact('value'), sprintf('%s = :match', $field), ['match' => $where_value]); } } static public function mail(array $params, Brindille $tpl, int $line) { if (empty($params['to'])) { throw new Brindille_Exception(sprintf('Ligne %d: argument "to" manquant pour la fonction "mail"', $line)); |
︙ | ︙ |