[2.0] Blank membergroup names on "Profile Edits" page after convert to UTF-8

Started by digger, January 29, 2019, 04:41:00 PM

Previous topic - Next topic

digger

Function fix_serialized_columns() fixes only topic subjects. There should be code for groups also.

$request = $smcFunc['db_query']('', '
        SELECT id_action, extra
        FROM {db_prefix}log_actions
        WHERE action IN ({string:id_group}, {string:additional_groups})',
    array(
        'id_group' => 'id_group',
        'additional_groups' => 'additional_groups',
    )
);


while ($row = $smcFunc['db_fetch_assoc']($request)) {
    if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:8:"previous";s:)(\d+):"(.*)"(;s:3:"new";s:)(\d+):"(.*)"(;s:10:"applicator";s:\d+:"\d+";})$~',
            $row['extra'], $matches) === 1) {
        $smcFunc['db_query']('', '
                UPDATE {db_prefix}log_actions
                SET extra = {string:extra}
                WHERE id_action = {int:current_action}',
            array(
                'current_action' => $row['id_action'],
                'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4] . strlen($matches[6]) . ':"' . $matches[6] . '"' . $matches[7],
            )
        );
    }

}
$smcFunc['db_free_result']($request);

Arantor

This is unlikely to be fixed in 2.0 but really should be added to 2.1 if it isn't already.

digger

I found some other serialized actions in smf_log_actions table which needs to be fixed after conversion. Here my version of fix_serialized_columns function.
https://github.com/realdigger/SMF-Fix-Serialized-Strings-After-Conversion

Advertisement: