]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Addon.php
Merge pull request #10801 from annando/network-thread-view
[friendica.git] / src / Core / Addon.php
index 0462504e70a29d01457fa5a1d5ecf4fd56c011c5..a1b35471f8d162f23fddfe10946a3a788830337f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -23,6 +23,7 @@ namespace Friendica\Core;
 
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\Contact;
 use Friendica\Util\Strings;
 
 /**
@@ -163,29 +164,21 @@ class Addon
                if (function_exists($addon . '_install')) {
                        $func = $addon . '_install';
                        $func(DI::app());
+               }
 
-                       $addon_admin = (function_exists($addon . "_addon_admin") ? 1 : 0);
-
-                       DBA::insert('addon', ['name' => $addon, 'installed' => true,
-                               'timestamp' => $t, 'plugin_admin' => $addon_admin]);
-
-                       // we can add the following with the previous SQL
-                       // once most site tables have been updated.
-                       // This way the system won't fall over dead during the update.
-
-                       if (file_exists('addon/' . $addon . '/.hidden')) {
-                               DBA::update('addon', ['hidden' => true], ['name' => $addon]);
-                       }
-
-                       if (!self::isEnabled($addon)) {
-                               self::$addons[] = $addon;
-                       }
-
-                       return true;
-               } else {
-                       Logger::error("Addon {addon}: {action} failed", ['action' => 'install', 'addon' => $addon]);
-                       return false;
+               DBA::insert('addon', [
+                       'name' => $addon,
+                       'installed' => true,
+                       'timestamp' => $t,
+                       'plugin_admin' => function_exists($addon . '_addon_admin'),
+                       'hidden' => file_exists('addon/' . $addon . '/.hidden')
+               ]);
+
+               if (!self::isEnabled($addon)) {
+                       self::$addons[] = $addon;
                }
+
+               return true;
        }
 
        /**
@@ -229,8 +222,6 @@ class Addon
         */
        public static function getInfo($addon)
        {
-               $a = DI::app();
-
                $addon = Strings::sanitizeFilePathItem($addon);
 
                $info = [
@@ -246,9 +237,9 @@ class Addon
                        return $info;
                }
 
-               $stamp1 = microtime(true);
+               DI::profiler()->startRecording('file');
                $f = file_get_contents("addon/$addon/$addon.php");
-               DI::profiler()->saveTimestamp($stamp1, "file");
+               DI::profiler()->stopRecording();
 
                $r = preg_match("|/\*.*\*/|msU", $f, $m);
 
@@ -267,6 +258,12 @@ class Addon
                                        if ($type == "author" || $type == "maintainer") {
                                                $r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
                                                if ($r) {
+                                                       if (!empty($m[2]) && empty(parse_url($m[2], PHP_URL_SCHEME))) {
+                                                               $contact = Contact::getByURL($m[2], false);
+                                                               if (!empty($contact['url'])) {
+                                                                       $m[2] = $contact['url'];
+                                                               }
+                                                       }
                                                        $info[$type][] = ['name' => $m[1], 'link' => $m[2]];
                                                } else {
                                                        $info[$type][] = ['name' => $v];