Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Deprecation error report when running with php 8.1

Status Resolved
Add-on / Version Publisher 3.8.2
Severity
EE Version 6.4.5

Gavin @ JCOGS

Feb 08, 2023

When running under php 8.1.14 am seeing this deprecation error reported:

Deprecated
Automatic conversion of false to array is deprecated
user/addons/publisher/legacy/models/publisher_site_pages.php, line 1219
  Severity: E_DEPRECATED

It might have been fixed in more recent version, but nothing about this in Changelog.

#1

BoldMinded (Brian)

Feb 08, 2023

Can you try changing lines 1215 and 1217 to this?

$pageUriVars = $this->cache->get('page_uri_vars') ?? [];

if (empty($pageUriVars)) {
#2

Gavin @ JCOGS

Feb 08, 2023

Yep - that would clear the deprecation error, but unfortunately triggers an exception a couple of lines later ... ;(

TypeError Caught
array_merge(): Argument #2 must be of type array, bool given

user/addons/publisher/legacy/models/publisher_site_pages.php:1226
Stack Trace: Please include when reporting this error

    #0 user/addons/publisher/legacy/models/publisher_site_pages.php(1226): array_merge(Array, false)
    #1 user/addons/publisher/Service/Session.php(261): Publisher_site_pages->create_page_uri_vars()
    #2 user/addons/publisher/ext.publisher.php(265): BoldMinded\Publisher\Service\Session->start()
    #3 ee/legacy/libraries/Extensions.php(203): Publisher_ext->sessions_start(Object(EE_Session))
    #4 ee/legacy/libraries/Extensions.php(108): EE_Extensions->call_class('Publisher_ext', 'sessions_start', Array, Array)
    #5 ee/legacy/libraries/Session.php(124): EE_Extensions->call('sessions_start', Object(EE_Session))
    #6 ee/legacy/core/Loader.php(942): EE_Session->__construct(Array)
    #7 ee/legacy/core/Loader.php(873): EE_Loader->_ci_init_class('session', '', Array, NULL)
    #8 ee/legacy/core/Loader.php(160): EE_Loader->_ci_load_class('Session', NULL, NULL)
    #9 ee/legacy/libraries/Core.php(350): EE_Loader->library('session')
    #10 ee/legacy/core/Controller.php(77): EE_Core->run_ee()
    #11 ee/ExpressionEngine/Core/Core.php(255): EE_Controller->__construct()
    #12 ee/ExpressionEngine/Core/Core.php(122): ExpressionEngine\Core\Core->runController(Array)
    #13 ee/ExpressionEngine/Boot/boot.php(161): ExpressionEngine\Core\Core->run(Object(ExpressionEngine\Core\Request))
    #14 public_html/index.php(164): require_once('...')
    #15 .composer/vendor/laravel/valet/server.php(250): require('...')
    #15 .composer/vendor/laravel/valet/server.php(250): require('...')
#3

BoldMinded (Brian)

Feb 08, 2023

I guess try wrapping that merge line with this conditional

if (is_array($pageUriVars)) {
                ee()->config->_global_vars = array_merge(ee()->config->_global_vars, $pageUriVars);
            }
#4

BoldMinded (Brian)

Feb 14, 2023

Gavin did the suggested change resolve the issue for you?

I’m going to go ahead and close this ticket. If that change didn’t resolve the issue please feel free to re-open it.

#5

Gavin @ JCOGS

Mar 04, 2023

So I changed the block of code in the create_page_uri_vars() function thusly (which I *think* is what you suggested…

/**
     * Create {page_uri:XX} variables. Can be used in start_from param
     * in Structure nav, or another module.
     *
     * @return void
     */
    public function create_page_uri_vars()
    {
        $sitePages = $this->get(false, true);

        // Only do this if there is page data, and we're not within the control panel
        if (!empty($sitePages) && REQ == 'PAGE') {
            $pageUriVars = $this->cache->get('page_uri_vars') ?? [];

            if (is_array($pageUriVars)) {
                ee()->config->_global_vars = array_merge(ee()->config->_global_vars, $pageUriVars);
            }

            if (empty($pageUriVars)) {
                foreach ($sitePages as $id => $url) {
                    $pageUriVars['page_uri:'. $id] = $this->addTrailingSlash($url);
                    $pageUriVars['page_url:'. $id] = $this->addTrailingSlash(
                        $this->urlService->addPrefixToUrl($url, $url, $this->currentLanguageCode)
                    );
                }

                $this->cache->save('page_uri_vars', $pageUriVars);
            }

            if (is_array($pageUriVars)) {
                ee()->config->_global_vars = array_merge(ee()->config->_global_vars, $pageUriVars);
            }
        }
    }

This removes the first issue, but generates a new one ... this deprecation warning:

Deprecated
Automatic conversion of false to array is deprecated

user/addons/publisher/legacy/models/publisher_site_pages.php, line 1223

    Severity: E_DEPRECATED

where line 1223 is

$pageUriVars['page_uri:'. $id] = $this->addTrailingSlash($url);

Bit of 8.1 whack-a-mole to go I guess.
This using publisher-3.9.1-develop-84169571 build.

#6

BoldMinded (Brian)

Mar 08, 2023

Change line 1215 to this

$pageUriVars = $this->cache->get(‘page_uri_vars’) ?: [];

instead of this

$pageUriVars = $this->cache->get(‘page_uri_vars’) ?? [];

Should fix it.

#7

Gavin @ JCOGS

Mar 08, 2023

Super - that’s sorted it. Thanks.

Login to reply