We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To get around this I created a migration task. Not sure if this could be useful for others
<?php use NSWDPC\Utilities\ContentSecurityPolicy\Directive; use SilverStripe\Dev\BuildTask; use SilverStripe\ORM\DB; /** * Migrates CSP directives due to changed structure on upgrade */ class MigrateCSPDirectives extends BuildTask { protected $title = 'Migrate CSP directives'; protected $description = 'Migrate CSP directives from <= v0.2.1 to >= v0.2.2'; public function run($request) { echo "Migrating directives. \n"; echo "If this throws an error regarding the Value column then no migration is available. \n"; $updated = 0; $invalidSkipped = 0; $alreadySetSkipped = 0; foreach (Directive::get() as $directive) { if (!$directive->dbObject('RulesValue')->getValue()) { $values = DB::query("SELECT `Value` FROM CspDirective WHERE ID = {$directive->ID} ")->column('Value'); if (isset($values[0])) { $newValues = []; foreach (explode(' ', $values[0]) as $value) { if (trim($value)) { $newValues[$value] = $value; } } $directive->RulesValue = json_encode($newValues); $directive->write(); $updated += 1; } else { $invalidSkipped += 1; } } else { $alreadySetSkipped += 1; } } if ($invalidSkipped) { echo "Skipped $invalidSkipped values that were empty or invalid? \n"; } if ($alreadySetSkipped) { echo "Skipped $alreadySetSkipped values that already had a value in the new field. \n"; } echo "Done - updated $updated items. \n"; } }
The text was updated successfully, but these errors were encountered:
Thanks for providing that. I'm planning an update and can incorporate this after testing in a v0.2 release along with v0.3.
Wrapping the query in a try/catch should automatically deal with the Value column not being available.
Value
Sorry, something went wrong.
No branches or pull requests
To get around this I created a migration task. Not sure if this could be useful for others
The text was updated successfully, but these errors were encountered: