mirror of
https://github.com/VladPolskiy/dokuwiki.git
synced 2025-07-23 00:44:52 +00:00
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.
This commit is contained in:
@ -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">';
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user