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