]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Include PHP libraries from system if not packaged and they are installed.
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 3 Sep 2015 15:52:04 +0000 (17:52 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 3 Sep 2015 15:56:11 +0000 (17:56 +0200)
Thanks to:
    "Bhuvan Krishna" <bhuvan@swecha.net>
    "Sunil Mohan" <sunil@medhas.org>

lib/framework.php

index 1834c3e786ca8d0c5870bd8d3fc52f9d17b3d6e4..d749d23bdff32c8e3144ffb4322f7ebd232dc3c2 100644 (file)
@@ -137,9 +137,18 @@ spl_autoload_register('GNUsocial_class_autoload');
  * and is available here: http://www.php-fig.org/psr/psr-0/
 */
 spl_autoload_register(function($class){
-    $file = INSTALLDIR.'/extlib/'.preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
+    $class_path = preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
+    $file = INSTALLDIR.'/extlib/'.$class_path;
     if (file_exists($file)) {
         require_once $file;
+        return;
+    }
+
+    # Try if the system has this external library
+    $file = '/usr/share/php/'.$class_path;
+    if (file_exists($file)) {
+        require_once $file;
+        return;
     }
 });