Nextcloud 20 to 21 Update Error

Hi community,

I tried to update my Nextcloud 20 to Nextcloud 21 (doesnā€™t matter if 21.0.0 or 21.0.1). I always get this error. I suspect, it has something todo with my mysql table, but I cannot find out whats the problem. I also tried googling this error but found nothing, so I am posting here.

I am running ngxinx and mysql8. The php version doesnā€™t matter. I have tried 7.3, 7.4 and 8.0.

OC\DB\Exceptions\DbalException: Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information.

Do you have any Idea what could be wrong?

Thanks a lot in advance

Chris

1 Like

Hi,

did you find a solution for your problem? I have the same issue.

Thanks.

Urly

Hi Urly,

unfortunately not. I did a clean install and then manually moved the files to the new installation.

When I ran the update, I received an installation error #26490. The next day while I was doing some maintenance on the MySQL server, I noticed the oc_filecache was taking awhile to load when the data was getting restored.

I went in and ran: sudo -u www-data php occ db:add-missing-indices

oc_filecache was updated to work with Nextcloud 21.

This in ran: sudo -u www-data php occ app:update to make sure that app apps werenā€™t compatbile with Nextcloud 21 were off.

Nextcloud 21 is working after those two commands were processed.

When running the security check, I did have trouble with webfinger and nodeinfo even with the following .htaccess configuration file:

ā€œā€
RewriteEngine on
RewriteRule ^.well-known/host-meta /media/external/nextcloud/public.php?service=host-meta [QSA,L]
RewriteRule ^.well-known/host-meta.json /media/external/nextcloud/public.php?service=host-meta-json [QSA,L]
RewriteRule ^.well-known/carddav /media/external/nextcloud/remote.php/dav [R=301,L]
RewriteRule ^.well-known/caldav /media/external/nextcloud/remote.php/dav [R=301,L]
RewriteRule ^.well-known/nodeinfo /media/external/nextcloud/public.php?service=nodeinfo [QSA,L]
RewriteRule ^.well-known/webfinger /media/external/nextcloud/public.php?service=webfinger [QSA,L]
ā€œā€

Same issue here updating NC 20 to 21 (Debian buster, php 7.3, mariadb, everything up to date).

Iā€™m interested in a solution without manually migrating the data (large volume, internet, multiple users), I guess Iā€™ll give @Tim_Babcock1ā€™s solution a try. Any other ideas?

Hi, have you try this command ?
sudo -u www-data php /var/www/html/nextcloud/occ db:add-missing-columns

Yes. It didnā€™t work at first, leaving me in maintenance mode, which I disabled with:
occ maintenance:mode --off
Then I went ahead and logged in and in the admin accountā€™s overview I got the recommendation to run:
occ db:add-missing-indices

It helped, leaving me with

A background job is pending that checks for user imported SSL certificates. Please check back later.

Summary: Thanks, I made some progress, still leaving me with a not so great feeling. I will update.

edit/update:
Hahaha, I was too impatient. After waiting for ten minutes, the cron job ran, and everything was fine again. Successfully running NC 21 now with minor warnings that Iā€™ll manage. Thanks @Mageunic , you motivated me to try again!

1 Like

I am still facing OPā€™s error message OC\DB\Exceptions\DbalException: Unknown column type "json_array" requested. when trying to update from 20.0.11.1 to 21.0.3 using the web based updater.

I have tried to disable incompatible apps as @Tim_Babcock1 had suggested. I first listed out my apps with occ app:list and then disable those apps that throw error OC\DB\Exceptions\DbalException: Unknown column type "json_array" requested. with occ app:disable. However after disabling those apps, the updater still throws the error.

I have also done occ db:add-missing-columns and occ db:add-missing-indices but with no success.

My system

Installed in iocage (FreeBSD 11.4-RELEASE)
MariaDB 10.4
PHP 7.4

Searched high and low for solutions all day but couldnā€™t find any. Please help.

Hi @envizion , have you try this command ?
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-columns

Yes I did. It didnā€™t work.

I suspect the issue is beyond what can be solved with occ commands.

After hours of investigation, I suspect the most likely source of error is the json_decode() functions from the doctrine/dbal library. In recent doctrine versions (especially after v2.6+), json_array had been deprecated in favor of json. Perhaps the upgrade scripts had missed this detail of making json_array compatible with json?

Iā€™m not very sure since Iā€™m not a PHP developerā€¦

@envizion I donā€™t know for this ā€¦ maybe someone else can help you.

I managed to solve this problem after having a second attempt at it!

Reason

Nextcloud uses DBAL to translate between the column types of various databases. From Nextcloud 21 onwards, the DBAL dependency has been updated and with that the legacy ā€˜json_arrayā€™ type is deprecated (link). However, the underlying source code (not sure how) still uses ā€˜json_arrayā€™ instead of the new ā€˜jsonā€™ type, thus throwing these errors that we see.

Solution

We need to manually edit the Type mappings in DBAL to what our old Nextcloud code understands. This affects the integrity of downloaded nextcloud ZIP file, so you cannot go through the ā€˜Upgrade via built-in updaterā€™ path. Instead, we are only forced to go the ā€˜Upgrade manuallyā€™ path.

Follow the steps in Manual upgrade guide, with changes after Step 6.

After Step 6, open the nextcloud/3rdparty/doctrine/dbal/src/Types/Types.php file with a text editor.

In line 29

public const JSON = 'json';

change ā€˜jsonā€™ to ā€˜json_arrayā€™. Save.

Proceed with the next steps and your upgrades should run smoothly.

Final notes

You will find that Nextcloud is not happy with you editing the DBAL Types.php file. It throws an error in your Admin dashboard under Administration > Overview > Security & setup warnings, saying

Some files have not passed the integrity check. Further information on how to resolve this issue can be found in the documentation. (List of invalid filesā€¦ / Rescanā€¦)

Unfortunately this is unavoidable. Otherwise the version upgrade and some apps that use the ā€˜json_arrayā€™ type simply wonā€™t work.

I would very much like to find a permanent solution to this, i.e., update the Nextcloud source code at relevant places to ā€˜jsonā€™. Iā€™ll try to work on this and contact the Nextcloud developers as well. Will update again on this thread.

1 Like

Thanks! for this workaround, I only just upgraded 20 to 21 and had exactly the same problem. After editing the Types.php file as you showed, I was able to run occ upgrade on the command line without errors.

Do you have any hints for future updates/upgrades - e.g. my nextcloud instance now recommends I upgrade to 22. Ideally Iā€™d like to get back to a state where files donā€™t fail the integrity check.

Is there any way to find the offending app/plugin that asks for json_arrayā€¦

[Just for info: I initially tried just removing facerecognition as suggested in Upgrade from 20 to 21 fails with dbalexception ā€œUnknown column type ā€œjson_arrayā€ requestedā€ - :construction: Installation - Nextcloud community but this did not solve the problem in my case ā†’ the upgrade failed to complete (perhaps I should have somehow restarted itā€¦)]