[owncloud: 5/10] various autoloader tweaks and fixes, generally robustify class loading
Adam Williamson
adamwill at fedoraproject.org
Wed Aug 20 15:39:26 UTC 2014
commit 72c9e820323940e1aa8e5b986f3fe006aa8bb5bc
Author: Adam Williamson <awilliam at redhat.com>
Date: Tue Jul 29 13:05:07 2014 -0700
various autoloader tweaks and fixes, generally robustify class loading
...r-autoloader-not-OC-for-non-Composer-3rdp.patch | 84 ++++++++++++++++++++
owncloud-7.0.0-autoloader_paths.patch | 12 +++
owncloud-7.0.0-composer_includepath.patch | 10 +++
owncloud-7.0.0rc1-composer_includepath.patch | 12 ---
owncloud-7.0.0rc1-pimple-path.patch | 10 ---
owncloud.spec | 35 ++++++--
6 files changed, 133 insertions(+), 30 deletions(-)
---
diff --git a/0001-use-Composer-autoloader-not-OC-for-non-Composer-3rdp.patch b/0001-use-Composer-autoloader-not-OC-for-non-Composer-3rdp.patch
new file mode 100644
index 0000000..ca38efd
--- /dev/null
+++ b/0001-use-Composer-autoloader-not-OC-for-non-Composer-3rdp.patch
@@ -0,0 +1,84 @@
+From c93f0668afd0c8cca5c6f59043d3e3531a0fea04 Mon Sep 17 00:00:00 2001
+From: Adam Williamson <awilliam at redhat.com>
+Date: Mon, 28 Jul 2014 18:48:17 -0700
+Subject: [PATCH] use Composer autoloader not OC for non-Composer 3rdparty
+ (#9643)
+
+Composer's autoloader is rather better than the OwnCloud autoloader's
+handling of non-OC classes. Plus we can rely on upstream Composer to
+maintain it and not worry about it ourselves.
+
+With this change, we drop the bits of OwnCloud's autoloader that
+handled non-OC classes, and register the classes that were being
+handled by that code with Composer's autoloader instead. As these
+dependencies are converted to actually being managed by Composer,
+the explicit registrations can be dropped as they won't be needed
+any more.
+---
+ lib/autoloader.php | 8 --------
+ lib/base.php | 17 +++++++++--------
+ 2 files changed, 9 insertions(+), 16 deletions(-)
+
+diff --git a/lib/autoloader.php b/lib/autoloader.php
+index 54f01d9..b63824a 100644
+--- a/lib/autoloader.php
++++ b/lib/autoloader.php
+@@ -99,14 +99,6 @@ class Autoloader {
+ $paths[] = 'tests/lib/' . strtolower(str_replace('_', '/', substr($class, 5)) . '.php');
+ } elseif (strpos($class, 'Test\\') === 0) {
+ $paths[] = 'tests/lib/' . strtolower(str_replace('\\', '/', substr($class, 5)) . '.php');
+- } else {
+- foreach ($this->prefixPaths as $prefix => $dir) {
+- if (0 === strpos($class, $prefix)) {
+- $path = str_replace('\\', '/', $class) . '.php';
+- $path = str_replace('_', '/', $path);
+- $paths[] = $dir . '/' . $path;
+- }
+- }
+ }
+ return $paths;
+ }
+diff --git a/lib/base.php b/lib/base.php
+index afa498e..943fa3f 100644
+--- a/lib/base.php
++++ b/lib/base.php
+@@ -433,12 +433,6 @@ class OC {
+ // register autoloader
+ require_once __DIR__ . '/autoloader.php';
+ self::$loader = new \OC\Autoloader();
+- self::$loader->registerPrefix('Doctrine\\Common', 'doctrine/common/lib');
+- self::$loader->registerPrefix('Doctrine\\DBAL', 'doctrine/dbal/lib');
+- self::$loader->registerPrefix('Symfony\\Component\\Routing', 'symfony/routing');
+- self::$loader->registerPrefix('Symfony\\Component\\Console', 'symfony/console');
+- self::$loader->registerPrefix('Patchwork', '3rdparty');
+- self::$loader->registerPrefix('Pimple', '3rdparty/Pimple');
+ spl_autoload_register(array(self::$loader, 'load'));
+
+ // make a dummy session available as early as possible since error pages need it
+@@ -485,14 +479,21 @@ class OC {
+ } catch (\Exception $ex) {
+ }
+ }
+- OC_Util::isSetLocaleWorking();
+
+ // setup 3rdparty autoloader
+ $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
+ if (file_exists($vendorAutoLoad)) {
+- require_once $vendorAutoLoad;
++ $loader = require_once $vendorAutoLoad;
++ $loader->add('Pimple',OC::$THIRDPARTYROOT . '/3rdparty/Pimple');
++ $loader->add('Doctrine\\Common',OC::$THIRDPARTYROOT . '/3rdparty/doctrine/common/lib');
++ $loader->add('Doctrine\\DBAL',OC::$THIRDPARTYROOT . '/3rdparty/doctrine/dbal/lib');
++ $loader->add('Symfony\\Component\\Routing',OC::$THIRDPARTYROOT . '/3rdparty/symfony/routing');
++ $loader->add('Symfony\\Component\\Console',OC::$THIRDPARTYROOT . '/3rdparty/symfony/console');
++ $loader->add('Patchwork',OC::$THIRDPARTYROOT . '/3rdparty');
+ }
+
++ OC_Util::isSetLocaleWorking();
++
+ // set debug mode if an xdebug session is active
+ if (!defined('DEBUG') || !DEBUG) {
+ if (isset($_COOKIE['XDEBUG_SESSION'])) {
+--
+2.0.1
+
diff --git a/owncloud-7.0.0-autoloader_paths.patch b/owncloud-7.0.0-autoloader_paths.patch
new file mode 100644
index 0000000..4380f8d
--- /dev/null
+++ b/owncloud-7.0.0-autoloader_paths.patch
@@ -0,0 +1,12 @@
+--- owncloud/lib/base.php 2014-07-29 00:27:51.154263240 -0700
++++ owncloud/lib/base.php.new 2014-07-29 00:30:26.998084605 -0700
+@@ -488,6 +488,9 @@
+ $loader->add('Symfony\\Component\\Routing',OC::$THIRDPARTYROOT . '/3rdparty/symfony/routing');
+ $loader->add('Symfony\\Component\\Console',OC::$THIRDPARTYROOT . '/3rdparty/symfony/console');
+ $loader->add('Patchwork',OC::$THIRDPARTYROOT . '/3rdparty');
++ $loader->add('Pimple', '/usr/share/php/Pimple');
++ $loader->add('Sabre', '/usr/share/php');
++ $loader->add('Sabre\VObject', '/usr/share/pear');
+ }
+
+ OC_Util::isSetLocaleWorking();
diff --git a/owncloud-7.0.0-composer_includepath.patch b/owncloud-7.0.0-composer_includepath.patch
new file mode 100644
index 0000000..a401242
--- /dev/null
+++ b/owncloud-7.0.0-composer_includepath.patch
@@ -0,0 +1,10 @@
+--- owncloud/lib/base.php 2014-07-29 00:30:26.998084605 -0700
++++ owncloud/lib/base.php.new 2014-07-29 00:35:08.579372364 -0700
+@@ -491,6 +491,7 @@
+ $loader->add('Pimple', '/usr/share/php/Pimple');
+ $loader->add('Sabre', '/usr/share/php');
+ $loader->add('Sabre\VObject', '/usr/share/pear');
++ $loader->setUseIncludePath(true);
+ }
+
+ OC_Util::isSetLocaleWorking();
diff --git a/owncloud.spec b/owncloud.spec
index c35be0f..eb0f151 100644
--- a/owncloud.spec
+++ b/owncloud.spec
@@ -1,6 +1,6 @@
Name: owncloud
Version: 7.0.0
-Release: 3%{?dist}
+Release: 5%{?dist}
Summary: Private file sync and share server
License: AGPLv3+ and MIT and BSD and CC-BY and CC-BY-SA and GPLv3 and Public Domain and (MPLv1.1 or GPLv2+ or LGPLv2+) and (MIT or GPL+) and (MIT or GPLv2) and ASL 2.0 and LGPLv3
@@ -24,11 +24,23 @@ Patch0: %{name}-7.0.0rc1-config.patch
# changes 'plugins:["flash,"silverlight","youtube","vimeo"]' to
# 'plugins:["youtube","vimeo"]'
Patch1: %{name}-6.0.2-videoviewer_noplugins.patch
+# Submitted upstream: https://github.com/owncloud/core/pull/9994
+# Uses Composer's autoloader, not OC's, for loading non Composer-managed
+# 3rdparty includes: it's better at it.
+Patch10: 0001-use-Composer-autoloader-not-OC-for-non-Composer-3rdp.patch
+# Ugly way to deal with Pimple 1.x's lack of PSR-0 compliance. Also forces the
+# paths to Sabre deps: /usr/share/php for most of Sabre (to ensure php-sabre-dav
+# package, 1.8 version, is used), /usr/share/pear for Sabre\VObject (to ensure
+# php-sabredav-Sabre_VObject package, 2.1 version, is used). Please be careful
+# and *test* if changing this; test with all versions of all Sabre packages
+# installed to make sure it DTRT. Keep an eye on upstream for future changes
+# also.
+Patch11: %{name}-7.0.0-autoloader_paths.patch
# Turn on include path usage for the Composer autoloader (so it'll find
# systemwide PSR-0 and PSR-4 compliant libraries)
# Upstream wouldn't likely take this, they probably only care about their
# bundled copies
-Patch11: %{name}-7.0.0rc1-composer_includepath.patch
+Patch12: %{name}-7.0.0-composer_includepath.patch
# Submitted upstream: https://github.com/owncloud/core/pull/6618
# Makes several points where apps load 3rdparty includes better for
# unbundling, replaces older separate patches for this purpose
@@ -36,10 +48,7 @@ Patch11: %{name}-7.0.0rc1-composer_includepath.patch
# master; this version is longer as it still needs to handle the Blowfish
# library that has been dropped entirely from upstream OC between 7.x and
# 8.x
-Patch12: %{name}-7.0.0rc1-3rdparty_includes.patch
-# Ugly way to deal with Pimple 1.x's lack of PSR-0 compliance. Not upstreamable,
-# part of unbundling.
-Patch13: %{name}-7.0.0rc1-pimple-path.patch
+Patch13: %{name}-7.0.0rc1-3rdparty_includes.patch
# Be less heavy-handed about clearing the opcache after editing config.php
# Avoids triggering a crash in php-opcache: https://github.com/owncloud/core/issues/9885
# From Remi Collet, should be submitted upstream soon
@@ -49,6 +58,7 @@ Patch14: %{name}-7.0.0-opcache_invalidate.patch
Patch15: %{name}-7.0.0-contact_type.patch
+
BuildArch: noarch
# expand pear macros on install
@@ -171,9 +181,10 @@ Requires: php-sqlite3 php-pcre
sed -i 's/\r$//' apps/files_encryption/lib/crypt.php
%patch0
%patch1
-%patch11
+%patch10 -p1
+%patch11 -p1
%patch12 -p1
-%patch13
+%patch13 -p1
%patch14 -p1
%patch15 -p1
@@ -380,6 +391,14 @@ fi
%changelog
+* Tue Jul 29 2014 Adam Williamson <awilliam at redhat.com> - 7.0.0-5
+- fix up sabre paths right this time
+
+* Tue Jul 29 2014 Adam Williamson <awilliam at redhat.com> - 7.0.0-4
+- more autoloader tweaking
+- use composer not OC autoloader for legacy 3rdparty includes (core#9643)
+- specify explicit paths to Sabre deps
+
* Sun Jul 27 2014 Adam Williamson <awilliam at redhat.com> - 7.0.0-3
- update apache config for OC 7 changes
- drop unneeded isoft/mssql-bundle from 3rdparty
More information about the scm-commits
mailing list