HelPHP

repair_csseditor_source.php

Puts the stored paths of csseditor_source in their canonical form and removes duplicated sources.

The stored path is the identity of a source beside its type and side: a block and a document have one row per (type, admin), a module and a theme one per (type, admin, path). Two rows on the same identity make every scalar subquery on that pair return more than one row, which takes the preview of a block down with it. Csseditor::ensure_source() holds that identity for the sources it writes; this tool repairs a table where it is already broken, and can be run again without effect.

First pass: an absolute path is reduced to its relative form — the form the resolver expects, and the only one that keeps its meaning when the instance or the toolkit moves. Two rows naming one file two ways then carry the same path and appear as the duplicate they are.

To call from CLI, inside the container as www-data: php repair_csseditor_source.php /path/to/my/instance # report only, no write php repair_csseditor_source.php /path/to/my/instance --apply # delete the lossless ones php repair_csseditor_source.php /path/to/my/instance --apply --force # also delete those # whose rules differ

A row is only deleted when its rules are identical to the kept row's (same selector, properties, media, active state) and it owns no variables/fonts/keyframes. Otherwise the group is reported and left alone, unless --force.

Table of Contents

Functions

rules_signature()  : array<string|int, mixed>
Signature of the rules of one source, to tell whether two sources carry the same CSS.
count_rows()  : mixed
duplicate_groups()  : array<string|int, mixed>
Duplicated sources, grouped by their identity.

Functions

rules_signature()

Signature of the rules of one source, to tell whether two sources carry the same CSS.

rules_signature(mixed $DB, string $t_rules, int $id_source) : array<string|int, mixed>
Parameters
$DB : mixed
$t_rules : string
$id_source : int
Return values
array<string|int, mixed>

count_rows()

count_rows(mixed $DB, string $table, int $id_source) : mixed
Parameters
$DB : mixed
$table : string
$id_source : int

duplicate_groups()

Duplicated sources, grouped by their identity.

duplicate_groups(mixed $DB, string $t_source) : array<string|int, mixed>

A block and a document are one source per (type, admin), whatever their path says: the pair is the identity, the path only says where the file is. A module and a theme are one source per file, so the path completes the identity.

Parameters
$DB : mixed
$t_source : string
Return values
array<string|int, mixed> —

One entry per group: type, admin, ids (comma separated), nb, and path for a module or a theme.

On this page

Search results