Upgrade to Nextcloud 33
Front-end changes
Files API
Breaking changes in the Files API package
The nextcloud/files library was updated to version v4.0.0 in Server.
This release includes breaking API changes, so you’ll need to update your code in time for Server 33.
To improve developer experience, we’ve expanded the context object passed to file actions. It now includes additional fields such as the current folder and the current file list. Function signatures have also changed: Action handlers now use destructured parameters instead of positional array arguments.
You can find the full changelog and migration details in the repository: nextcloud-files (4.0.0 beta).
Profile app
To make the profile sections API framework agnostic, allowing us to migrate the profile app to Vue 3
while still allow external apps to use Vue 2 based profile section,
the OCA.Core.ProfileSections API was replaced with OCA.Profile.ProfileSections
which uses custom web components instead of being based on Vue components.
As of Nextcloud 33 the OCA.Profile.ProfileSections.registerSection method accepts
a section object in the following format:
interface ProfileSection {
/**
* Unique identifier for the section
*/
id: string
/**
* The order in which the section should appear (lower numbers appear first)
*/
order: number
/**
* The custom element tag name to be used for this section
*
* The custom element must have been registered beforehand,
* and must have the a `user` property of type `string | undefined`.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_components
*/
tagName: string
/**
* Static parameters to be passed to the custom web component
*/
params?: Record<string, unknown>
}
Added APIs
OCA.Profile.ProfileSectionswas added as a framework agnostic replacement forOCA.Core.ProfileSections. See section about the profile app above.
Changed APIs
TBD
Deprecated APIs
TBD
Removed APIs
The global
md5implementation is removed. It was deprecated since Nextcloud 20 and not used by Nextcloud anymore. If you still need amd5implementation you can just use some external package like crypto-browserify.OC.AppConfigwas deprecated since Nextcloud 16 and was now removed. Instead useOCP.AppConfig.The
OC.Settings.UserSettingsapi was removed.The
OC.SystemTagsapi was removed. If you need to get the list of system tags, check this merge request for how to fetch the tags directly.OC.setandOC.getwere removed. Both are deprecated since Nextcloud 19. Forget, if really needed, use lodash get. And forset, use lodash set.OC.redirectandOC.reloadwere removed. Both were deprecated since Nextcloud 17. To replaceOC.redirectdirectly usewindow.location. To replaceOC.reloaddirectly usewindow.location.reload.OC.fileIsBlacklistedwas removed. It was deprecated since Nextcloud 18. The replacement is to usevalidateFilenamefrom the @nextcloud/files package.The deprecated host methods from OC were deprecated since Nextcloud 17 and are now removed
To replace
OC.getHostusewindow.location.host.To replace
OC.getHostNameusewindow.location.hostname.To replace
OC.getPortusewindow.location.port.To replace
OC.getProtocolusewindow.location.protocol.
The
OCA.Core.ProfileSectionsAPI was removed and replaced with the framework agnosticOCA.Profile.ProfileSectionsAPI. See section about the profile app above.The
OCA.Files.SidebarAPI is removed. This was the last API using the legacyFileInfoAPI. It is now replaced with the new Node based sidebar API available from the @nextcloud/files package.The
OCA.Sharing.ExternalLinkActionsAPI was deprecated in Nextcloud 23 and is now removed. It was replaced withOCA.Sharing.ExternalShareActionwhich now have a proper API by usingregisterSidebarActionfrom @nextcloud/sharing instead.
Back-end changes
Support for PHP 8.5 added
See below section for option code changes in your app and dependency management
Support for PHP 8.1 removed
In this release support for PHP 8.1 was removed. Follow the steps below to make your app compatible.
If
appinfo/info.xmlhas a dependency specification for PHP, increase themin-versionto 8.2.
<dependencies>
<php min-version="8.2" max-version="8.5" />
<nextcloud min-version="31" max-version="33" />
</dependencies>
If your app has a
composer.jsonand the file contains the PHP restrictions frominfo.xml, adjust it as well.
{
"require": {
"php": ">=8.2 <=8.5"
}
}
If you have continuous integration set up, remove PHP 8.1 and add PHP 8.5 from the matrices of tests and linters.
Default user agent for outgoing requests changed
Starting with this release, the default user agent for requests done by the instance was changed from Nextcloud Server Crawler to Nextcloud-Server-Crawler/X.Y.Z, where X.Y.Z is the current server version.
Snowflake IDS
The following tables are now using snowflake ids:
oc_previewsoc_jobsoc_share_external
The API related to these tables are now using a string instead of a int. See Changed APIs section and Snowflake IDs.
Added Events
TBD
Added APIs
We now expose
\OCP\DB\IResult::iterateAssociative,\OCP\DB\IResult::iterateNumericfrom doctrine/dbal. These two methods returns iterators that can be directly used in a foreach to iterate over a SQL query result. For example:
$result = $qb->executeQuery();
foreach ($result->iterateAssociative() as $row) {
$id = $row['id'];
}
$result->closeCursor();
Changed APIs
The
setIdandgetIdmethods of\OCP\BackgroundJob\IJobwere changed to return/accept a string instead of an int. Same for\OCP\BackgroundJob\IJobListwere some methods (removedById,getByIdandgetDetailsById) are now taking a string instead of an int. The string is suppose to be a snowflake id.The
setObjectIdandgetObjectIdmethods of\OCP\Activity\IEventwere changed to return/accept a string in addition to an int. The string is suppose to be a snowflake id.
Deprecated APIs
The
\OCP\DB\IResult::fetchand\OCP\DB\IResult::fetchAllare soft-deprecated. Instead you can use\OCP\DB\IResult::fetchAssociative,\OCP\DB\IResult::fetchNumericand\OCP\DB\IResult::fetchOneas replacement for\OCP\DB\IResult::fetch; and\OCP\DB\IResult::fetchAllAssociative,\OCP\DB\IResult::fetchAllNumericand\OCP\DB\IResult::fetchFirstColumnas replacement for\OCP\DB\IResult::fetchAll. If you use rector, you can use the Nextcloud33 set, to automatically port most of your code to the new methods.
Removed APIs
The
\OCP\BackgroundJob\IJob::executemethod was deprecated since Nextcloud 25 and was now removed. Instead use theIJob::startmethod, available since Nextcloud 25.The
\OCP\Search\PagedProvider,\OCP\Search\Providerand\OCP\Search\Resultclasses were deprecated since Nextcloud 20 and were now removed. Instead use\OCP\Search\SearchResultand\OCP\Search\IProvider, available since Nextcloud 20.The
\OC_Util::runningOnMac()method was removed. Instead you can just checkPHP_OS_FAMILY === 'Darwin'.The
\OCP\DB\IQueryBuilder::executemethod was deprecated since Nextcloud 22 and was now removed. Instead use the\OCP\DB\IQueryBuilder::executeQuerywhen doing executing aSELECTquery and\OCP\DB\IQueryBuilder::executeStatementmethod when executing aUPDATE,INSERTandDELETEstatement, available since Nextcloud 20.Instead of catching a exceptions from the Doctrine DBAL package, you now need to catch
OCP\DB\Exceptionand check the getReason`. For example, the following old code:
try {
$qb->insert(...);
$qb->execute();
} catch (\Doctrine\DBAL\Exception\UniqueConstraintViolationException) {
// Do stuff
}
Should be replaced by the following code:
try {
$qb->insert(...);
$qb->executeStatement();
} catch (\OCP\DB\Exception $e) {
if ($e->getReason() !== \OCP\DB\Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw $e;
}
// Do stuff
}
The
\OCP\Files::buildNotExistingFileNameand related private helper\OC_Helper::buildNotExistingFileNamewere deprecated since Nextcloud 14 and were now removed. Use\OCP\Files\Folder::getNonExistingNameinstead.