Half a year ago I installed +ownCloud

Right now, I'm reading the source. Specifically owncloud/lib/db.php. I'd better not done that.

owncloud can use MDB2. That's a wrapper for database access and database modeling, written in PHP, with backends for many databases.

owncloud can also use PDO. That's a wrapper for database access, native to PHP, written in C, without modeling support, with backends for many databases.

db.php is a wrapper wrapping the two wrappers.

Of course, only for operation. For installation it requires MDB2 at all times, because PDO does not support modeling.

What does that mean?

In db.php are wonderful things such as createDbFromStructure().

That's reading an XML file with a schema definition and should create a schema in the SQL dialect of the target database. Because that's... well, dunno. 'more portable' it isn't.

Because: After we read the XML file, we're doing str_replace on it, because it's XML.

                $content = file_get_contents( $file );
                $content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
                $content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
                if( $CONFIG_DBTYPE === 'pgsql' || $CONFIG_DBTYPE === 'oci' ) {
                         $content = str_replace( '<default>0000-00-00 00:00:00</default>',
                                '<default>CURRENT_TIMESTAMP</default>', $content );
                file_put_contents( $file2, $content );
                $definition = self::$schema->parseDatabaseDefinitionFile( $file2 );
                unlink( $file2 );

I can't make that up.

I'll continue to read. This is better than twilight zone.

Well, after I locked access to my owncloud/ directory from the Internet, that is. Like watching Twilight Zone: First lock the door.

EDIT: Continued in

updateDbFromStructure() - the same broken XML massaging here again, duplicated. Only that the data source for dbname is not $CONFIG_DBNAME, but  $previousSchema['name'] ($previousSchema being generated from getDefinitionFromDatabase($CONFIG_DBTABLEPREFIX) though!), while  dbprefix is from $CONFIG_DBTABLEPREFIX like before.

So the code is subtly different, but does the same.

EDIT: continued in https://plus.google.com/+KristianK%C3%B6hntopp/posts/GEHPAYKzNhX
and in https://plus.google.com/+KristianK%C3%B6hntopp/posts/CP6oxFZt5pM
Shared publiclyView activity