Php 8 & 8.1

Pankaj Singh

Active Member
Hello Folks,

Anyone having any experience Mailwizz installation with php 8 or php8.1 ?
I can see that Mailwizz is fine with php8 or 8.1, but not sure about their performance or any type of issue compared to php7.4!
 
Hey,

I still have some older version (1.9.x) running with PHP 7.4 and a lot of customisations. I have already updated the vendor scripts to be compatible with PHP 8.1+ but Mailwizz has a problem with some alias paths of extensions. PHP 7.4.33 works very well, but something with resolving the alias path in extensions seems to be incompatible. I don't know if it is a problem of Yii or MailWizz. In MailWizz 2.x it's solved to load the class' models a bit different…

Is there an easy way to work around such an error:
Code:
[error] [exception.CException] [::1] CException: The alias "ext-search.common.models.*" is invalid.

Stack trace:
#0 /mailwizz/htdocs/apps/common/extensions/search/SearchExt.php(78): YiiBase::import('ext-search.comm...')
#1 /mailwizz/htdocs/apps/common/components/managers/ExtensionsManager.php(170): SearchExt->run()
#2 /mailwizz/htdocs/apps/common/components/init/SystemInit.php(86): ExtensionsManager->loadAllExtensions()
#3 /mailwizz/htdocs/apps/common/framework/base/CComponent.php(559): SystemInit->_runOnBeginRequest(Object(CEvent))
#4 /mailwizz/htdocs/apps/common/framework/base/CApplication.php(212): CComponent->raiseEvent('onbeginrequest', Object(CEvent))
#5 /mailwizz/htdocs/apps/common/framework/base/CApplication.php(183): CApplication->onBeginRequest(Object(CEvent))
#6 /mailwizz/htdocs/apps/init.php(230): CApplication->run()
#7 /mailwizz/htdocs/backend/index.php(18): require_once('/Users/slackero...')
#8 {main}
REQUEST_URI=/backend/index.php/update

Thanks
 
If I remember correctly, there were quite some issues related to the extensions system and php 8.x, so really, if you're keen to still using 1.x then you should stay on php 7.x
 
Thanks for your answer,

It really seems to be related to how the extension system in PHP 8.x is working – just hoped you know how I might work around this, because yes, the alias path is correct. It seems the caching of required classes/files mixes things – also hard linking using require hasn't helped. I have no problem to patch the code if I just get a hint were to look at.

The dilemma with sticking to PHP 7.4 is that the provider will stop to support it very soon on the current, managed system.

If there is no other solution I might need to move the installation to another host.
 
@slackero - I don't remember much, BUT, you can open /apps/common/components/init/ExtensionInit.php and for a start look for:
PHP:
public final function getReflection()
    {
        static $_reflection;
        if ($_reflection) {
            return $_reflection;
        }
        return $_reflection = new ReflectionClass($this);
    }
And make it:
PHP:
public final function getReflection()
    {
        return new ReflectionClass($this);
    }

Then look for:
PHP:
public final function getDirName()
    {
        static $_dirName;
        if ($_dirName) {
            return $_dirName;
        }

        $reflection = $this->getReflection();
        return $_dirName = basename(dirname($reflection->getFilename()));
    }

And make it:
PHP:
public final function getDirName()
    {
        $reflection = $this->getReflection();
        return basename(dirname($reflection->getFilename()));
    }

Then save the file and reload the page, this might do it.
 
Finally the update to 1.9.48 has worked and after some smaller changes regarding phpseclib it seems to be stable:
Bash:
/apps/common/components/db/behaviors/RemoteServerPasswordHandlerBehavior.php
Change the function if phpseclib was upgraded to v3
PHP:
/**
 * @return Crypt_AES
 */
protected function getCipher()
{
    if ($this->_cipher !== null) {
        return $this->_cipher;
    }

    if (!MW_COMPOSER_SUPPORT) {
        $classes = array('Base', 'Rijndael', 'AES');
        foreach ($classes as $class) {
            if (!class_exists('Crypt_' . $class, false)) {
                require_once Yii::getPathOfAlias('common.vendors.PHPSecLib.Crypt.' . $class) . '.php';
            }
        }
        $this->_cipher = new Crypt_AES();
        $this->_cipher->iv = null;
        $this->_cipher->setKeyLength(128);
    } else {
        $this->_cipher = new phpseclib3\Crypt\AES('ctr');
        $this->_cipher->setIV(str_repeat("\0", $this->_cipher->getBlockLength() >> 3));
        $this->_cipher->setKeyLength(256);
    }
    $this->_cipher->setKey('abcdefghqrstuvwxyz123456ijklmnop');
    return $this->_cipher;
}
 
Back
Top