View Issue Details

IDProjectCategoryView StatusLast Update
0028918mantisbtupgradepublic2023-10-31 16:32 Assigned Todregad  
PriorityhighSeveritymajorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version2.16.0 
Target Version2.26.0Fixed in Version2.26.0 
Summary0028918: Improve handling of unserialize->json conversion during upgrade

MantisBT 2.16.0 introduced improved reporting of unserialize -> JSON conversion errors during upgrade from 1.2.x versions (see PR

As discussed below, this reporting is not optimal, as the installer stops after each error, forcing the admin to run the upgrade N+1 times (N being the number of conversion errors), which can be quite tedious when there is a large number of errors.

It would be more convenient to go through the entire process, and provide the admin with a list of errors at the end.

Additional Information

This is the original bug report:

upgrade mantis 1.2.4 to 2.25.2

'd tried to upgrade and got some errors. I have attached a picture of the error shown. Could you please tell me what is the issue?

After my research, I deleted some rows from mantis_config_table and mantis_filters_table
delete from mantis_config_table where type=3
It worked but found bugs in workflow transitions (can't see the statuses) .

Please share what is the exact way to fix this issue.

TagsNo tags attached.
Attached Files
DELETED ROWS.JPG (66,685 bytes)   
DELETED ROWS.JPG (66,685 bytes)   
Schema 193 error.JPG (206,323 bytes)   
Schema 193 error.JPG (206,323 bytes)   




2021-07-15 17:47

developer   ~0065692

delete from mantis_config_table where type=3

This removes all "complex" types from your config, which is like using a nuke to kill a mosquito... probably explains the workflow transition errors you're experiencing too. Don't do that.

The upgrade process is normally quite specific about the config which is causing a problem during upgrade; looking at the provided screenshot, the issue is with the private_bug_threshold record for all projects/all users, which apparently contains a json-encoded array of values, while the installer expects serialized data (a:4:{i:0;i:10;i:1;i:55;i:2;i:70;i:3;i:90;}). You can delete the record or manually fix it as appropriate, then re-run the upgrade.

2021-07-16 05:26

reporter   ~0065693

As you said, I deleted the 'private_bug_threshold' record for all projects/all users.

But, after that, it is shown the next error, and I deleted another record, and it continued for 15+ records. So I deleted all complex type values.

Now I imported the deleted rows into the mantis_config_table after the upgrade, it seems to work fine but still some of the complex values are showing NULL and in the database, these items have values.

ARRAY VALUES.JPG (64,021 bytes)   
ARRAY VALUES.JPG (64,021 bytes)   
NULL.JPG (49,031 bytes)   
NULL.JPG (49,031 bytes)   


2021-07-16 19:03

developer   ~0065694

Now I imported the deleted rows into the mantis_config_table after the upgrade

Thus undoing the upgrade script's processing, which as you can imagine, is there for a reason - in this case converting complex values storage, from legacy PHP serialized data, to JSON.

You get NULLs, because Mantis is not able to interpret the serialized data as JSON.

So either keep going through the iterative process as you've been doing 15 times, until the installer continues, or devise your own conversion script based on install_check_config_serialization() function (in install_helper_functions_api.php).

I'll check if the upgrade process can be improved to process all data and report errors at the end, instead of aborting after the first error.



2021-08-07 09:58

developer   ~0065734 it may be a bit late for you by now, but I have been working on an improved reporting mechanism, which allows you to download a CSV file with a list of all conversion errors found for a given upgrade steps. This should make the process less painful.

The updated code is available under PR

Feel free to review and test, your feedback would be appreciated.

Related Changesets

MantisBT: master 581754b9

2021-08-24 08:33


Details Diff
Upgrading: improve unserialize->json conversion

Let the Admin download a CSV file with a list of errors when converting
unserialized data to JSON during upgrade, instead of forcing them to
fix issues one-by-one and run the upgrade N+1 times (N being the number
of conversion errors).

Also includes some code cleanup / improvements

- Conversion from legacy Database API to DbQuery
- PHPStorm static analysis warnings
- unused parameter in db_unixtimestamp()

Fixes 0028918, PR
Affected Issues
mod - core/install_helper_functions_api.php Diff File