-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
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
Migrate breaks Fred / ContentBlocks and others #144
Comments
For reference for anyone else that runs into this issue, I'm providing my migration fix file here: <?php
use modmore\VersionX\VersionX;
require_once dirname(__DIR__, 3) . '/config.core.php';
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
require_once MODX_CONNECTORS_PATH . 'index.php';
/** @var \modX|modX $modx */
$versionX = new VersionX($modx);
$c = $modx->newQuery('vxDeltaField');
$c->leftJoin('vxDelta', 'Delta', ['Delta.id = vxDeltaField.delta']);
$c->where([
'Delta.principal_class' => 'modResource',
'vxDeltaField.field' => 'properties',
[
'vxDeltaField.before:LIKE' => 'a:%',
'OR:vxDeltaField.after:LIKE' => 'a:%'
]
]);
$c->limit(10000);
$collection = $modx->getIterator('vxDeltaField', $c);
$fix = 0;
foreach($collection as $df) {
$save = false;
if (str_starts_with($df->before, 'a:')) {
$before = json_encode(unserialize($df->before));
$df->set('before', $before);
$df->set('before_type', 'array');
$save = true;
}
if (str_starts_with($df->after, 'a:')) {
$after = json_encode(unserialize($df->after));
$df->set('after', $after);
$df->set('after_type', 'array');
$save = true;
}
if ($save) {
$df->save();
$fix++;
}
}
print_r("\r\nDone fixing $fix!\r\n"); I have a "limit" set to keep it from killing the server, and it can be run as many times as needed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just noticed that the migration script is serializing the properties, similar to issue #137
This is making it impossible to revert ContentBlocks or Fred resources that were pre-migration. I've got a tiny workaround to json_encode(unserialize($after)) and set the type to "array", but this should maybe be fixed in the migration script.
The text was updated successfully, but these errors were encountered: