Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily fix for using multisites #2824

Open
trianity opened this issue Feb 14, 2020 · 3 comments
Open

Temporarily fix for using multisites #2824

trianity opened this issue Feb 14, 2020 · 3 comments

Comments

@trianity
Copy link

I have a well functioning subdomain type multisite multilingual (9 language) Grav system.

The only problem is updating the plugins.

The good solution here in this system was that all sites (in the multisite system) use a common set of plugins and templates.

This can be set up nicely by specifying streams in the setup.php

In the Grav Core there is a Temporarily fix for using multisites in system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php
in AbstractPackageCollection constructor from line 58-62.

            // Temporarily fix for using multisites
            if (isset($data['install_path'])) {
                $path = preg_replace('~^user/~i', 'user://', $data['install_path']);
                $data['install_path'] = Grav::instance()['locator']->findResource($path, false, true); //Overwrite the $data['install_path']
            }

This Temporarily fix is suitable for the such type of setup where all of the sites has own plugin setup instead of the common.

It would be good to use a condition which type of multisite setup applied in the system.
One of the ways (may it is not the best) to apply a condition is read from setup.php some data related to the plugins (common or own for every sites).

        $this->fetch($refresh, $callback);
+        //Get schemes defined in setup.php -> To make possiblity to use different multisite setups
+        $schemes = Grav::instance()['locator']->getSchemes();
        foreach (json_decode($this->raw, true) as $slug => $data) {
            // Temporarily fix for using multisites
            if (isset($data['install_path'])) {
-                $path = preg_replace('~^user/~i', 'user://', $data['install_path']);
-                $data['install_path'] = Grav::instance()['locator']->findResource($path, false, true);
+               $path = preg_replace('~^user/~i', 'user://', $data['install_path']);
+               if (!in_array("pluginupdates", $schemes)) {
+                  $data['install_path'] = Grav::instance()['locator']->findResource($path, false, true);
+               }
            }
            $this->items[$slug] = new Package($data, $this->type);
        }

Or any other way that can be used for the condition overwrite of the $data['install_path'] variable.

If this small modification is not there in the core then after every Grav update I need to hack the 'system/src/Grav/Common/GPM/Remote/AbstractPackageCollection.php' to put back the plugin update folder place.

@mahagr
Copy link
Member

mahagr commented Feb 24, 2020

See also #2820

@trianity
Copy link
Author

@mahagr @rhukster
Hello, is there any better solution for the conditional override of the $data['install_path'] (for plugins) ?

@trianity
Copy link
Author

Other temporary solution is comment out the unnecessary line after every Grav core update
2020-03-27_2111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants