adventistchurch / alps-wordpress

This Wordpress theme is an implementation of the Adventist Living Pattern System (ALPS) designed to support the work of the Seventh-day Adventist Church.
Other
43 stars 38 forks source link

Fix issue caused by 3.14.0 in Media Cloud #641

Closed hans-olson closed 1 year ago

hans-olson commented 1 year ago

WordPress version 6.1.1 Active theme: ALPS for WordPress (version 3.14.0) Current plugin: Media Cloud (Premium) (version 4.5.20) PHP version 8.2.3

Error Details

An error of type E_ERROR was caused in line 58 of the file /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/plugins/ilab-media-tools-premium/lib/mcloud-illuminate/support/Env.php. Error message: Uncaught Error: Call to private Dotenv\Repository\Adapter\EnvConstAdapter::__construct() from scope MediaCloud\Vendor\Illuminate\Support\Env in /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/plugins/ilab-media-tools-premium/lib/mcloud-illuminate/support/Env.php:58 Stack trace:

0 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/plugins/ilab-media-tools-premium/lib/mcloud-illuminate/support/Env.php(81): MediaCloud\Vendor\Illuminate\Support\Env::getRepository()

1 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/plugins/ilab-media-tools-premium/lib/mcloud-illuminate/support/helpers.php(275): MediaCloud\Vendor\Illuminate\Support\Env::get()

2 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/themes/alps-wordpress-v3/vendor/roots/acorn/config/broadcasting.php(18): env()

3 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/themes/alps-wordpress-v3/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/LoadConfiguration.php(66): require('/mnt/data/home/...')

4 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/themes/alps-wordpress-v3/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/LoadConfiguration.php(37): Roots\Acorn\Bootstrap\LoadConfiguration->loadConfigurationFiles()

5 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/themes/alps-wordpress-v3/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(237): Roots\Acorn\Bootstrap\LoadConfiguration->bootstrap()

6 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/themes/alps-wordpress-v3/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(208): Illuminate\Foundation\Application->bootstrapWith()

7 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-content/themes/alps-wordpress-v3/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(181): Roots\Acorn\Bootloader->app()

8 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-includes/class-wp-hook.php(308): Roots\Acorn\Bootloader->__invoke()

9 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()

10 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()

11 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-settings.php(526): do_action()

12 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-config.php(87): require_once('/mnt/data/home/...')

13 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-load.php(50): require_once('/mnt/data/home/...')

14 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-admin/admin.php(34): require_once('/mnt/data/home/...')

15 /mnt/data/home/896449.cloudwaysapps.com/nfpqwdabmx/public_html/wp-admin/plugins.php(10): require_once('/mnt/data/home/...')

16 {main}

thrown

YauheniKapliarchuk commented 1 year ago

Hi @hans-olson

Could you please add to this conversation contact person of this plugin?

Let do some quick review of our theme:

I am going to add comments below about fixes in plugin.

Thanks, Best Regards!

YauheniKapliarchuk commented 1 year ago

The error which you getting in the begging of activation the plugin you can fix using this approach:

public static function getRepository() {

        if (static::$repository === null) {

            $adapters = array_merge(
                [EnvConstAdapter::create(), ServerConstAdapter::create()],
                static::$putenv ? [PutenvAdapter::create()] : []
            );

            static::$repository = RepositoryBuilder::create()
                ->withReaders($adapters)
                ->withWriters($adapters)
                ->immutable()
                ->make();
        }

        return static::$repository;
    }

in the Env file:

app/public/wp-content/plugins/ilab-media-tools-premium/lib/mcloud-illuminate/support/Env.php.

And other issues also you can fix use this method and you can see available methods for this in the corresponding files:

EnvConstAdapter -> /app/public/wp-content/themes/alps-wordpress-v3/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php PutenvAdapter -> /app/public/wp-content/themes/alps-wordpress-v3/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php RepositoryBuilder -> /app/public/wp-content/themes/alps-wordpress-v3/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php

After this preparations I got expected result with our last theme version 3.14.1: Screenshot 2023-03-28 at 17.26.54.png

It was just investigation and if you need I can provide my fixed Env file for you. Perhaps this problem with non valid versions of our projects.

I reckon we need synchronize plugin and theme with correct dependencies versions which we are using.

Thanks, Best Regards!

hans-olson commented 1 year ago

@YauheniKapliarchuk

Here are two methods to contact the plugin developer.

CREATE SUPPORT TICKET https://docs.mediacloud.press/support/

FORUM https://wordpress.org/support/plugin/ilab-media-tools/

johnrbeckett commented 1 year ago

Here is the code from iLab....You can see I commented out their corresponding code and put in changes from Yauheni. It still doesn't work. What am I missing? The code looks equivalent.

    /**
     * Get the environment repository instance.
     *
     * @return \Dotenv\Repository\RepositoryInterface
     */
    public static function getRepository()
    {
        if (static::$repository === null) {
            $adapters = array_merge(
                [EnvConstAdapter::create(), ServerConstAdapter::create()],
                static::$putenv ? [PutenvAdapter::create()] : []
//                [new EnvConstAdapter, new ServerConstAdapter],
//                static::$putenv ? [new PutenvAdapter] : []
            );

            static::$repository = RepositoryBuilder::create()
                ->withReaders($adapters)
                ->withWriters($adapters)
                ->immutable()
                ->make();
        }

        return static::$repository;
    }
YauheniKapliarchuk commented 1 year ago

Hi @johnrbeckett I put here just Example of code and source where you can find correct methods.

Please use this code of the function below

`public static function getRepository() {

    if (static::$repository === null) {
        $adapters = array_merge(
            [EnvConstAdapter::create(), ServerConstAdapter::create()],
            static::$putenv ? [PutenvAdapter::create()] : []
        );

        static::$repository = RepositoryBuilder::createWithDefaultAdapters()
            ->allowList($adapters)
            ->immutable()
            ->make();
    }

    return static::$repository;
}`

Thanks, Best Regards!

YauheniKapliarchuk commented 1 year ago

Hi everyone,

for resolving this issue, we need to get some updates from dev team of this plugin.

I tried to update this code in our side and code missing flexibility.

These changes were added in the core of our theme.

Ticket was created to mediacloud and moved this ticket to HOLD column

Thanks, Best Regards!

YauheniKapliarchuk commented 1 year ago

Answer from Media cloud team:

Private Zenhub Image

I think we can create new ticket for resolve this issue.

Thanks, Best Regards!

hans-olson commented 1 year ago

What's our next step?

YauheniKapliarchuk commented 1 year ago

Hi @hans-olson

Our next steps:

Why I propose to do this, because in this ticket we did a lot of investigations, and we need to find different approach.

Thanks, Best Regards!

hans-olson commented 1 year ago

Excellent. Thank you.