Commit Graph
3 Commits
Author SHA1 Message Date
Thomas Vincent 2a40f44d21 fix(database): accept string-form key columns in db_update_table() refresh (#8737)
* fix(database): accept string-form key columns in db_update_table() refresh

db_update_table() passed each declared key's columns straight to
array_diff() when the table already existed. Plugins conventionally declare
those columns as a string, either a single column or the backtick-joined
'col1`,`col2' form, so a refresh through api_plugin_db_table_create()
raised a TypeError under PHP 8 and aborted the plugin install or upgrade.

Add db_index_columns_to_array() and normalize both the key columns and the
primary key before diffing them against SHOW INDEX. A matching index is no
longer rebuilt, and a backtick-joined primary key is compared per column
instead of as one name.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs(changelog): note the db_update_table() key column fix (#8736)

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-11-17 13:24:56 -05:00
TheWitness 7b551eea72 chore: normalize CRLF line endings to LF across Cacti-owned files (#8156)
Excludes vendored packages, third-party JS, patches, and the Win32 probe fixture. Pure EOL change; guards pass and php -l is clean.
2026-10-02 17:22:42 -04:00
TheWitness d4f2bd1f3b Restore legacy unique_keys[] support in the schema API (#8116)
* Restore legacy unique_keys[] support in the schema API

develop expresses a unique index as a `keys[]` entry with `'unique' => true`,
and both db_table_create() and db_update_table() were rewritten to only read
that form. Plugins that still use the legacy `unique_keys[]` definition style
(supported on 1.2.x) therefore get no UNIQUE index created, and any existing
one dropped on the next schema refresh.

Fold a legacy `unique_keys[]` definition into `keys[]` with the unique flag at
the top of both functions, so the existing unique-aware key handling applies
to it. New-style `keys[]` with `'unique' => true` continues to work unchanged.

* CHANGELOG: reference PR #8116

* Fix CHANGELOG format and add unique_keys[] regression coverage

CHANGELOG: use the -issue#8116 entry form (the -bug prefix and trailing (#NNNN) failed the CHANGELOG format check) and place it in the issue block so the security-issue-feature ordering holds. Adds DbUpdateTableUniqueKeysTest covering db_table_create() emitting the UNIQUE index and db_update_table() adding a missing one and preserving an existing one for a legacy unique_keys[] definition. FakeMySQLPDO now projects Seq_in_index/Column_name/Non_unique for named secondary indexes so the reconciliation path can be exercised.
2026-09-29 23:08:41 -04:00