diff options
author | Andreas Gohr <andi@splitbrain.org> | 2024-12-17 12:07:22 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2024-12-17 12:11:21 +0100 |
commit | 01b2a2823dcc82af6193cb9ea39d835e2a85f9e2 (patch) | |
tree | 6292863654c42c57119e13ed1c41fd70abba4cda /lib/plugins/extension | |
parent | dc19220032f21053c2bd43e0c265c24a51c90f33 (diff) | |
download | dokuwiki-01b2a2823dcc82af6193cb9ea39d835e2a85f9e2.tar.gz dokuwiki-01b2a2823dcc82af6193cb9ea39d835e2a85f9e2.zip |
initialize remote data in one go
Previously each extension was fetched separately from the API, this
fetches all installed ones in one go, speeding up the first open on cold
cache significantly.
Diffstat (limited to 'lib/plugins/extension')
-rw-r--r-- | lib/plugins/extension/GuiAdmin.php | 12 | ||||
-rw-r--r-- | lib/plugins/extension/Repository.php | 4 | ||||
-rw-r--r-- | lib/plugins/extension/cli.php | 6 |
3 files changed, 19 insertions, 3 deletions
diff --git a/lib/plugins/extension/GuiAdmin.php b/lib/plugins/extension/GuiAdmin.php index 8480f7553..74499632b 100644 --- a/lib/plugins/extension/GuiAdmin.php +++ b/lib/plugins/extension/GuiAdmin.php @@ -64,6 +64,12 @@ class GuiAdmin extends Gui $html .= '</div>'; $plugins = (new Local())->getPlugins(); + try { + // initialize remote data in one go + Repository::getInstance()->initExtensions(array_keys($plugins)); + } catch (Exception $e) { + msg($e->getMessage(), -1); // this should not happen + } $html .= '<div id="extension__list">'; $html .= '<form action="' . $this->tabURL('plugins') . '" method="post">'; @@ -91,6 +97,12 @@ class GuiAdmin extends Gui $html .= '</div>'; $templates = (new Local())->getTemplates(); + try { + // initialize remote data in one go + Repository::getInstance()->initExtensions(array_keys($templates)); + } catch (Exception $e) { + msg($e->getMessage(), -1); // this should not happen + } $html .= '<div id="extension__list">'; $html .= '<form action="' . $this->tabURL('templates') . '" method="post">'; diff --git a/lib/plugins/extension/Repository.php b/lib/plugins/extension/Repository.php index 20130f8fb..2cda2480d 100644 --- a/lib/plugins/extension/Repository.php +++ b/lib/plugins/extension/Repository.php @@ -135,7 +135,7 @@ class Repository // first get all that are cached foreach ($ids as $id) { $data = $this->retrieveCache($id); - if ($data === null) { + if ($data === null || $data === []) { $toload[] = $id; } else { $result[$id] = Extension::createFromRemoteData($data); @@ -147,7 +147,7 @@ class Repository $this->fetchExtensions($toload); foreach ($toload as $id) { $data = $this->retrieveCache($id); - if ($data === null) { + if ($data === null || $data === []) { $result[$id] = null; } else { $result[$id] = Extension::createFromRemoteData($data); diff --git a/lib/plugins/extension/cli.php b/lib/plugins/extension/cli.php index 956f43859..e163b362e 100644 --- a/lib/plugins/extension/cli.php +++ b/lib/plugins/extension/cli.php @@ -258,7 +258,11 @@ class cli_plugin_extension extends CLIPlugin */ protected function cmdList($showdetails, $filter) { - $this->listExtensions((new Local())->getExtensions(), $showdetails, $filter); + $extensions = (new Local())->getExtensions(); + // initialize remote data in one go + Repository::getInstance()->initExtensions(array_keys($extensions)); + + $this->listExtensions($extensions, $showdetails, $filter); return 0; } |