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: Breaking deprecation error on switching languages

Status Resolved
Add-on / Version Publisher 3.10
Severity
EE Version 7.2.17

Hop Studios

May 08, 2023

Clicking the change language button presents a deprecation error, and breaks the page reload if debugging is turned on.
EE: 7.2.17
Publisher: 3.10
PHP: 8.1.18

Example code:

{exp:publisher:languages show_current="no"}
    <a  href="{switch_language_url}">{if publisher:current_language_id == 1}Français{if:else}English{/if}</a>
{/exp:publisher:languages}

In case that href tag doesn’t render properly, it’s the standard language switch tag: {switch_language_url}

https://i.gyazo.com/99ff7ecd77dbb1d3679e7475f2fbebce.png

Quick fix:
/publisher/Service/Url/Url.php:660

public function addTrailingSlash($url, $compareUrl = '', $siteIndex = null)
#1

BoldMinded (Brian)

Thanks for pointing this out. I think I’m going to update the whole function to this if you want to try it:

public function addTrailingSlash(string $url, string $compareUrl = '', string $siteIndex = '') :string
    {
        if (!$siteIndex) {
            $siteIndex = ee()->config->item('site_index');
        }

        if ($siteIndex && strpos($url, $siteIndex) !== false && strpos($url, '.php/') === false) {
            $url = str_replace($siteIndex, $siteIndex.'/', $url);
        }

        $uriParts = explode('?', $compareUrl);
        $compareUrl = $uriParts[0];

        if ($url && $compareUrl && substr($compareUrl, -1) === '/') {
            $url .= '/';
        }

        return reduce_double_slashes($url);
    }

Login to reply