-
-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make authority a unique index on modUserGroupRole (#16587)
### What does it do? Adds a unique index to the modUserGroupRole.authority field. ### Why is it needed? modUserGroupRole records are linked to ACLs via the authority value, so those MUST be unique or referential integrity is lost. ### How to test Run the transport build, execute the setup, and verify that after adding a modUserGroupRole record with a non-unique authority value, the upgrade stops with a failure describing what you need to do in order to resolve the situation before re-running the setup. After removing the non-unique record, verify that setup then runs successfully and a unique index is added to the authority column. ### Related issue(s)/PR(s) This is related to and should be adopted along with #16568 — see discussion on that PR.
- Loading branch information
Showing
5 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
setup/includes/upgrades/common/3.1.0-modify-usergrouprole-authority-index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* convert the authority index to be unique on modUserGroupRole */ | ||
|
||
/** | ||
* @var modX $modx | ||
* @var modInstallVersion $this | ||
*/ | ||
|
||
$class = \MODX\Revolution\modUserGroupRole::class; | ||
$table = $modx->getTableName(\MODX\Revolution\modUserGroupRole::class); | ||
|
||
$description = $this->install->lexicon('drop_index', ['index' => 'authority', 'table' => $table]); | ||
$this->processResults($class, $description, [$modx->manager, 'removeIndex'], [$class, 'authority']); | ||
$description = $this->install->lexicon('add_index', ['index' => 'authority', 'table' => $table]); | ||
if (!$this->processResults($class, $description, [$modx->manager, 'addIndex'], [$class, 'authority'])) | ||
{ | ||
$this->runner->addResult(modInstallRunner::RESULT_FAILURE, $this->install->lexicon('authority_unique_index_error')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters