Repository navigation
Closed
Labels
Description
The discussion was started in #1214
At the moment app developers have to configure their app settings in various different places . This includes: navigation entry settings, versions for schema updates, classloader and checks for enabled apps, etc
Sometimes you have to do this using PHP, sometimes its XML and sometimes its just a plain file with a number in it. This is inconsistent and takes more energy to document and understand. Also by using PHP for things that get loaded before all apps, the risk is high that one syntax error in one app can break every app.
We came up with the following additions to the info.xml file
<?xml version="1.0"?>
<app>
<id>myapp</id>
<name>My App</name>
<description>My App description</description>
<version>1.0</version>
<licences>
<licence>AGPL</licence>
</licences>
<authors>
<author>
<name>myname</name>
<email>[email protected]</email>
</author>
</authors>
<require>5.0</require>
<admin linkType="route">myapp_index</admin>
<search>
<provider>\OCA\MyApp\SearchProvider</provider>
</search>
<share>
<backend>\OCA\MyApp\ShareBackend</backend>
</share>
<backgroundjobs>
<job runType="worker">\OCA\MyApp\BackgroundJob</job>
</backgroundjobs>
<dependencies>
<app>appframework</app>
</dependencies>
</app>Heres my schema file which validates the xml:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- types -->
<xs:simpleType name="notEmpty">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="version">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]+(\.[0-9]+)*"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="email">
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-\.]+\..+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="loweralpha">
<xs:restriction base="xs:string">
<xs:pattern value="[a-z]+"/>
</xs:restriction>
</xs:simpleType>
<!-- actual xml -->
<xs:element name="app">
<xs:complexType>
<xs:all>
<xs:element name="id" type="loweralpha" />
<xs:element name="name" type="notEmpty" />
<xs:element name="description" type="notEmpty" />
<xs:element name="version" type="version" />
<!-- allow one or more licences -->
<xs:element name="licences">
<xs:complexType>
<xs:sequence>
<xs:element name="licence" minOccurs="1" maxOccurs="unbounded" type="notEmpty" />
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- allow one or more authors -->
<xs:element name="authors">
<xs:complexType>
<xs:sequence>
<xs:element name="author">
<xs:complexType>
<xs:all>
<xs:element name="name" type="notEmpty" />
<xs:element name="email" type="email" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- minimum owncloud version -->
<xs:element name="require" type="version" />
<!-- if the app can be used as a webapp for instance by gnome web -->
<xs:element name="webapp" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<!-- if the app is in the installed tar, 3rdparty apps must set false -->
<xs:element name="shipped" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<!-- if the app should be enabled by default -->
<xs:element name="default-enable" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<!-- types can be given and be only of value:
* filesystem
* prelogin
* authentication
* logging
-->
<xs:element name="types" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="type" minOccurs="1" maxOccurs="unbounded">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="filesystem" />
<xs:enumeration value="prelogin" />
<xs:enumeration value="authentication" />
<xs:enumeration value="logging" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- contains the link to the admin settings page and can specify a
link or a route -->
<xs:element name="admin" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="notEmpty">
<xs:attribute name="linkType" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="file" />
<xs:enumeration value="route" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<!-- Can be specified and contains a list of search provider classes-->
<xs:element name="search" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="provider" type="notEmpty" minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Can be specified and contains a list of share backend classes-->
<xs:element name="share" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="backend" type="notEmpty" minOccurs="1" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Allows to specify app dependencies -->
<xs:element name="dependencies" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="app" type="notEmpty" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Allows to specify background jobs of type:
* worker
* regular
* queue
-->
<xs:element name="backgroundjobs" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="job" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="notEmpty">
<xs:attribute name="runType" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="regular" />
<xs:enumeration value="worker" />
<xs:enumeration value="queue" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
Activity
tanghus commentedon Jan 19, 2013
The appinfo/version files was originally introduced to speed up reading owncloud-archive/apps@121c5f4
I don't know if this is still an issue /cc @icewind1991
BernhardPosselt commentedon Jan 19, 2013
sounds a lot like premature optimization. If this really is an issue (which i highly doubt) caching should solve the problem.
DeepDiver1975 commentedon Jan 19, 2013
What about routes?
Please explain the two index and icon elements in navigation.
I'm not too sure about the elements reflecting the register calls/elements. Let me think about it.
Thx
BernhardPosselt commentedon Jan 19, 2013
Im not sure if everyone wants to use routes. For those that still want the OC method linkTo
can be used. The icon uses imagePath which takes two arguments: appname and filename.
should be better in that case. Basically there will be only one element, this is just for demonstrating the choices
Edit:
As for routes: I've tried to put this into config files before but it lost a huge amount of configurability. Also the way how the routes.php is parsed (required inside the router class so you use $this) makes it REALLY hard to decouple, if not impossible.
icewind1991 commentedon Jan 19, 2013
Before I split the version number to a separate file, reading all the xml files took nearly 50% of the page load time.
Version number is the only thing that we can't cache from the config file since the version number is used to check if we need to update the cache.
I agree with moving all the other things to the xml file (and cache them in the database)
BernhardPosselt commentedon Jan 19, 2013
Can we store the file change date in the database and recache when it changed?
http://php.net/manual/en/function.filectime.php
icewind1991 commentedon Jan 19, 2013
That could be a solution, as long as we can guaranty that every change is detected
BernhardPosselt commentedon Jan 19, 2013
Oh sry, this should be guaranteed by using http://php.net/manual/en/function.filemtime.php :
This function returns the time when the data blocks of a file were being written to, that is, the time when the content of the file was changed.
bartv2 commentedon Jan 19, 2013
stating files also takes time, but i'm not sure how it compares with reading version files. also dbversion could just be a int, no need to have that minor there, when it is only for database schema changes.
BernhardPosselt commentedon Jan 20, 2013
Well we cant say anything for sure without performance tests. Another solution would be to hash the content of file and compare it with a hash in the database, although I'm not sure how performant that will be.
BernhardPosselt commentedon Jan 20, 2013
Just tested filemtime vs file_get_contents with 10000 empty files:
filemtime is roughly 3-4 times faster.
karlitschek commentedon Jan 20, 2013
It's a common misunderstanding that databases are fast. Most of the time the local filesystem is significantly faster then a database so caching things in a database doesn't always make sense. So it would be great if you could do a brief check of the old and new codepath before merging this. I just commited a small trivial tool that I did years ago to compare the performance of an old and a new codepath. Perhaps this is helpful to you. https://github.com/owncloud/administration/blob/master/dev-tools/benchmark.php
icewind1991 commentedon Jan 20, 2013
The main cost here isn't reading the file from the filesystem, but parsing the xml
karlitschek commentedon Jan 20, 2013
@icewind1991 True. XML parsing is also famous for being slow. :-) would be great to have some performance numbers for both options.
BernhardPosselt commentedon Jan 20, 2013
What about serialized classes? If that is possible in PHP at all.
BernhardPosselt commentedon Mar 11, 2013
bump
houqp commentedon Mar 11, 2013
If it's parsing xml that takes time, can we just search the
<version>1.0</version>tag from the file and read the version number? I mean treat it as a normal palintext file instead of XML during page load.BernhardPosselt commentedon Mar 11, 2013
@houqp caching is the answer ;)
houqp commentedon Mar 11, 2013
cool, would like to see it adopted since it will be very helpful for app developers :)
VicDeo commentedon Jun 20, 2013
@Raydiation it would be great to implement PHP extensions dependency check.
BernhardPosselt commentedon May 7, 2014
Closing this since I've given up on finding a solution in core. I have a working version of all the proposed stuff in news in JSON format, if someone is interested in that please open another issue and mention me.