Short description of the issue
Commit 6a1aa2b2 added name support to PagesVersions with a UNIQUE KEY name_pages_id (name, pages_id) constraint. Two call paths can violate the constraint without graceful handling:
renamePageVersion($page, $version, 'draft') when another version of the same page already has name 'draft'.
savePageVersion($page, $newVersion, ['name' => 'draft']) when another version already has name 'draft'.
Expected behavior
A clear WireException (or an indication that the caller should pick a different name), not a raw PDO 1062 duplicate-key exception.
Actual behavior
renamePageVersion issues a bare UPDATE pages_versions SET name = ? WHERE ... with no pre-check and no try/catch on the unique-key constraint violation.
savePageVersion's upsert uses INSERT ... ON DUPLICATE KEY UPDATE keyed on the primary key (version, pages_id), not on the (name, pages_id) unique key — so it fails outright when the name already exists on a different version of the same page.
Optional: Suggestion for a possible fix
Pre-check or catch with friendly error:
try {
// ... existing rename/save logic ...
} catch(\PDOException $e) {
if($e->errorInfo[1] === 1062) {
throw new WireException("A version named '$name' already exists for this page.");
}
throw $e;
}
Setup/Environment
- ProcessWire version:
dev @ 15c749ed
- File:
wire/modules/PagesVersions/PagesVersions.module.php
- Introduced in commit 6a1aa2b2
Short description of the issue
Commit 6a1aa2b2 added name support to PagesVersions with a
UNIQUE KEY name_pages_id (name, pages_id)constraint. Two call paths can violate the constraint without graceful handling:renamePageVersion($page, $version, 'draft')when another version of the same page already has name'draft'.savePageVersion($page, $newVersion, ['name' => 'draft'])when another version already has name'draft'.Expected behavior
A clear
WireException(or an indication that the caller should pick a different name), not a raw PDO 1062 duplicate-key exception.Actual behavior
renamePageVersionissues a bareUPDATE pages_versions SET name = ? WHERE ...with no pre-check and no try/catch on the unique-key constraint violation.savePageVersion's upsert usesINSERT ... ON DUPLICATE KEY UPDATEkeyed on the primary key(version, pages_id), not on the(name, pages_id)unique key — so it fails outright when the name already exists on a different version of the same page.Optional: Suggestion for a possible fix
Pre-check or catch with friendly error:
Setup/Environment
dev@15c749edwire/modules/PagesVersions/PagesVersions.module.php