{"id":9701,"date":"2016-03-10T13:35:52","date_gmt":"2016-03-10T13:35:52","guid":{"rendered":"https:\/\/owncloud.com\/?p=9701"},"modified":"2016-03-10T13:35:52","modified_gmt":"2016-03-10T13:35:52","slug":"owncloud-9-0-for-developers","status":"publish","type":"post","link":"https:\/\/owncloud.com\/de\/blogs\/owncloud-9-0-for-developers\/","title":{"rendered":"ownCloud 9.0 for developers"},"content":{"rendered":"<p><a href=\"https:\/\/owncloud.com\/nine\" rel=\"attachment wp-att-9667\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/owncloud.com\/wp-content\/uploads\/2016\/02\/ownCloud-9.0-round-300x283.png\" alt=\"ownCloud 9.0 round\" width=\"300\" height=\"283\" class=\"alignright size-medium wp-image-9667\" \/><\/a><br \/>\nThe public developer API of ownCloud aims to be stable over different releases, which allows developers to have their applications work across ownCloud releases. To enable developers writing more diverse applications and to make their life easier, for this release ownCloud has gained 408 public API methods. 20 functions were deprecated, which means they will be removed in future versions of ownCloud (in 3 years, as a rule). Read on to find out what\u2019s new and how to use it!<\/p>\n<p>Much of the work around the 9.0 release was aimed at making ownCloud even more scalable for the needs of big organizations that are using ownCloud, such as CERN. This is also reflected in the public API changes which were mostly aimed at providing functionality to enable this.<\/p>\n<p>However, for regular application developers we\u2019ve also made adjustments and added new functionality. In the following we cover some of the changes introduced by the 9.0 release.<\/p>\n<h2>Polyfills for Older PHP Versions<\/h2>\n<p>While not necessarily a change to the public API, we believe that it is time to allow developers to use some of the functionality of newer PHP versions, as well as in older releases.<\/p>\n<p>This has been done by adding the Symfony Polyfills for PHP 5.5, PHP 5.6 and PHP 7.0. The polyfills basically check whether a function exists in this PHP version, and if not, a generic fallback is used.<\/p>\n<p>Effectively this makes the following PHP functions accessible to developers of ownCloud:<\/p>\n<ul>\n<li><code><a href=\"http:\/\/php.net\/boolval\" target=\"_top\" rel=\"noopener noreferrer\">boolval<\/a><\/code><\/li>\n<li><code><a href=\"http:\/\/php.net\/json_last_error_msg\" target=\"_top\" rel=\"noopener noreferrer\">json_last_error_msg<\/a><\/code><\/li>\n<li><code><a href=\"http:\/\/php.net\/array_column\" target=\"_top\" rel=\"noopener noreferrer\">array_column<\/a><\/code><\/li>\n<li><code><a href=\"http:\/\/php.net\/hash_pbkdf2\" target=\"_top\" rel=\"noopener noreferrer\">hash_pbkdf2<\/a><\/code><\/li>\n<li><code>password_*<\/code> functions (from <a href=\"https:\/\/github.com\/ircmaxell\/password_compat\" target=\"_top\" rel=\"noopener noreferrer\">ircmaxell\/password_compat<\/a>)<\/li>\n<li><code><a href=\"http:\/\/php.net\/hash_equals\" target=\"_top\" rel=\"noopener noreferrer\">hash_equals<\/a><\/code> (part of <a href=\"http:\/\/php.net\/hash\" target=\"_top\" rel=\"noopener noreferrer\">hash<\/a> extension)<\/li>\n<li><code><a href=\"http:\/\/php.net\/ldap_escape\" target=\"_top\" rel=\"noopener noreferrer\">ldap_escape<\/a><\/code> (part of <a href=\"http:\/\/php.net\/ldap\" target=\"_top\" rel=\"noopener noreferrer\">ldap<\/a> extension)<\/li>\n<li><code><a href=\"http:\/\/php.net\/intdiv\" target=\"_top\" rel=\"noopener noreferrer\">intdiv<\/a><\/code><\/li>\n<li><code><a href=\"http:\/\/php.net\/preg_replace_callback_array\" target=\"_top\" rel=\"noopener noreferrer\">preg_replace_callback_array<\/a><\/code><\/li>\n<li><code><a href=\"http:\/\/php.net\/error_clear_last\" target=\"_top\" rel=\"noopener noreferrer\">error_clear_last<\/a><\/code><\/li>\n<li><code>random_bytes<\/code> and <code>random_int<\/code> (from <a href=\"https:\/\/github.com\/paragonie\/random_compat\" target=\"_top\" rel=\"noopener noreferrer\">paragonie\/random_compat<\/a>)<\/li>\n<li><code><a href=\"http:\/\/php.net\/Error\" target=\"_top\" rel=\"noopener noreferrer\">*Error<\/a><\/code><a href=\"http:\/\/php.net\/Error\" target=\"_top\" rel=\"noopener noreferrer\"> throwable classes<\/a><\/li>\n<\/ul>\n<p>Being able to use newer PHP functions like this has removed the need for us to provide generic fallbacks and, thus, makes our code easier to maintain. For example <code>\\OCP\\Security\\StringUtils::equals<\/code> can now simply be replaced by <code>hash_equals<\/code>.<\/p>\n<h2>New APIs<\/h2>\n<p>When it comes to new APIs, most are focused on providing the new features in ownCloud 9.0 to application developers, such as tagging or commenting. This way people with the need for customized solutions can adjust these, just like with the file cache. Scalability, by integrating deeper into underlying storage systems, is one reason why you\u2019d want to do that, and some other important public API changes are also included below for this specific purpose.<\/p>\n<h3>Commenting<\/h3>\n<p>ownCloud 9.0 introduces the ability to comment on files. Huge installations may want to store this information in another way, which is possible using these public APIs:<\/p>\n<ul>\n<li><code>\\OCP\\Comments\\ICommentsManager<\/code><\/li>\n<li>Abstracts the access and creation of comments.<\/li>\n<li><code>\\OCP\\Comments\\IComment<\/code><\/li>\n<li>Allows custom implementations of storages for comments<\/li>\n<\/ul>\n<div id=\"attachment_8550\" style=\"width: 217px\" class=\"wp-caption alignright\"><a href=\"https:\/\/owncloud.com\/blog\/making-owncloud-faster-through-caching\/\" rel=\"attachment wp-att-8550\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8550\" src=\"https:\/\/owncloud.com\/wp-content\/uploads\/2015\/07\/caching-207x300.gif\" alt=\"The principle of caching - animated\" width=\"207\" height=\"300\" class=\"size-medium wp-image-8550\" \/><\/a><p id=\"caption-attachment-8550\" class=\"wp-caption-text\">The principle of caching &#8211; animated<\/p><\/div>\n<h3>File Cache<\/h3>\n<p>The file cache is a huge part of ownCloud, and by using the new public APIs, it is possible to integrate it in a file system like, for example, CERN is doing:<\/p>\n<ul>\n<li><code>\\OCP\\Files\\Cache\\ICache<\/code> \/ <code>\\OCP\\Files\\Cache\\ICacheEntry<\/code><\/li>\n<li>Allows custom integrations of metadata for storages.<\/li>\n<li><code>\\OCP\\Files\\Cache\\IPropagator<\/code><\/li>\n<li>Allows a custom implementation for the ETag and MTime propagation.<\/li>\n<li><code>\\OCP\\Files\\Cache\\IScanner<\/code><\/li>\n<li>Allows custom file scanners for a storage<\/li>\n<li><code>\\OCP\\Files\\Cache\\IUpdater<\/code><\/li>\n<li>Allows custom implementations for cache updates<\/li>\n<li><code>\\OCP\\Files\\Cache\\IWatcher<\/code><\/li>\n<li>Allows custom implementations for watching a storage for changes<\/li>\n<\/ul>\n<h3>Shares<\/h3>\n<p>We have completely rewritten the sharing code to make it easier to maintain, more reliable and to avoid surprises for users \u2013 the user-visible changes are minimal, but important. Developers, you will benefit from the fact that the sharing information can now be completely stored on any storage system.<\/p>\n<ul>\n<li><code>\\OCP\\Share\\IManager<\/code> \/ <code>\\OCP\\Share\\IProviderFactory<\/code> \/ <code>\\OCP\\Share\\IShare<\/code><\/li>\n<li>Allows custom implementations for storing share information<\/li>\n<\/ul>\n<h3>Locking<\/h3>\n<p>Locking information can now also be stored in anywhere.<\/p>\n<ul>\n<li><code>\\OCP\\Files\\Storage\\ILockingStorage<\/code><\/li>\n<li>Allows custom implementations for storing locks<\/li>\n<\/ul>\n<h3>Tagging<\/h3>\n<p>Tagging information can also be stored however you like:<\/p>\n<ul>\n<li><code>\\OCP\\SystemTag\\ISystemTag<\/code> \/ <code>\\OCP\\SystemTag\\ISystemTagManager<\/code> \/ <code>\\OCP\\SystemTag\\ISystemTagManagerFactory<\/code><\/li>\n<li>Allows custom implementations for storing tags<\/li>\n<\/ul>\n<h2>Notifications<\/h2>\n<p>ownCloud 9.0 allows application developers to integrate our notification API. This API also allows you to define custom actions like accepting or denying an event.<\/p>\n<ul>\n<li><code>\\OCP\\Notification\\IAction<\/code> \/ <code>\\OCP\\Notification\\IManager<\/code> \/ <code>\\OCP\\Notification\\INotification<\/code> \/ <code>\\OCP\\Notification\\INotifier<\/code><\/li>\n<li>Allows integration with the notification app<\/li>\n<\/ul>\n<h2>More Security Through an Even Stricter CSP<\/h2>\n<p>Security is a key requirement for ownCloud. To prevent Cross-Site Scripting vulnerabilities, we\u2019re employing a strict Content-Security-Policy. This means that we\u2019re basically instructing the browser to only communicate with trusted endpoints and not to execute inline Javascript.<\/p>\n<p>While this is a great thing, and applications could already modify their policies, this is only applied to their own views. So if, for example, a Chat application was hooking into any other view, it could not modify the policy.<\/p>\n<p>In ownCloud 9.0 we have hardened the CSP again and have given people the possibility to inject a default policy using <code>\\OCP\\Security\\IContentSecurityPolicyManager::addDefaultPolicy<\/code>.<\/p>\n<h2>Some More Niceness<\/h2>\n<p>In addition, some missing methods have been added to the API. It is now, for example, possible to escape like parameters or use ILIKE in the query builder.<\/p>\n<ul>\n<li><code>\\OCP\\IDBConnection::escapeLikeParameter<\/code><\/li>\n<li>Escapes a parameter in a way to be used safely in a LIKE query. Prevents \u201cLIKE\u201d injections.<\/li>\n<li><code>\\OCP\\DB\\QueryBuilder\\IExpressionBuilder::iLike<\/code><\/li>\n<li>Adds the case insensitive LIKE parameter to the public API of the query builder.<\/li>\n<li><code>\\OCP\\Files\\FileInfo::getChecksum<\/code><\/li>\n<li>Allows getting the checksum for a file<\/li>\n<\/ul>\n<h2>Deprecated APIs<\/h2>\n<p>Note that ownCloud has a policy of supporting deprecated APIs for three years after we notify users of deprecation. This gives developers enough time to properly port their applications in order to use the new API, and should keep applications working for a long time.<\/p>\n<p>Deprecations can, in this release, be mostly found within functions that we consider to have a negative impact on performance, as well as in areas which didn\u2019t turn out to be useful for external developers or overly simplified APIs.<\/p>\n<p>For example, <code>\\OCP\\BackgroundJob\\IJobList::getAll<\/code> has been deprecated as well as some methods in <code>\\OCP\\Files\\Cache\\ICache,<\/code> which turned out not to scale properly due to missing pagination.<\/p>\n<p>Furthermore, <code>\\OCP\\Route\\IRouter<\/code> has been deprecated since this API turned out not to be used by external developers, and was very implementation specific. This limited us in core to enhance the performance of ownCloud even further since we\u2019re bound to this implementation.<\/p>\n<p><code>\\OCP\\Security\\ISecureRandom<\/code> is also now easier to use than before. Instead of specifying the strength manually, one can now call <code>\\OCP\\Security\\ISecureRandom::generate<\/code> directly and strong secure random strings are generated.<\/p>\n<p>Combined, these changes show a further maturing of the ownCloud public API, strengthening our ecosystem. We hope you will enjoy writing apps with the new API and your feedback is more than welcome, either here, in <a href=\"https:\/\/github.com\/owncloud\/core\/issues\" target=\"_top\" rel=\"noopener noreferrer\">github<\/a> or on our <a href=\"https:\/\/mailman.owncloud.org\/mailman\/listinfo\/devel\" target=\"_top\" rel=\"noopener noreferrer\">developer mailing list<\/a>!<\/p>\n<p>Thanks to Lukas Reschke for providing content for this blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The public developer API of ownCloud aims to be stable over different releases, which allows developers to have their applications work across ownCloud releases. To enable developers writing more diverse applications and to make their life easier, for this release ownCloud has gained 408 public API methods. 20 functions were deprecated, which means they will [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":78665,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"categories":[341,354],"tags":[],"class_list":["post-9701","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news-from-owncloud","category-release"],"acf":[],"_links":{"self":[{"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/posts\/9701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/comments?post=9701"}],"version-history":[{"count":0,"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/posts\/9701\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/media\/78665"}],"wp:attachment":[{"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/media?parent=9701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/categories?post=9701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/owncloud.com\/de\/wp-json\/wp\/v2\/tags?post=9701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}