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: Toggling to another language takes you to the last page that the user is on

Status Resolved
Add-on / Version Publisher 2.7.5
Severity
EE Version 3.5.15

Mighty Citizen

Feb 22, 2018

Description: Our client thought it was weird that whenever they click to change a language, they aren’t taken to the translated version of the page that they’ve clicked the Translation button on - if they happened to have navigated to another page in a different tab or window. I do think it’s a bit odd, but it also seems like a bit of a weird case for a user who happens to have multiple windows/tabs open. I figured I’d reach out to you in case you had any recommendations or if there were any settings that I could update to alter that behavior.

Detailed steps to reproduce the issue:
1. Open an internal link in a new tab/window
2. On the first tab/window, click to change languages

 

 

 

#1

BoldMinded (Brian)

Do you mean in the CP or on the front-end?

Also, I just got the demo site working again, so is this something you can replicate on demo.boldminded.com?

#2

Mighty Citizen

I’m referring to the frontend. Interesting, I’m not getting that behavior on the demo site. The demo site has the links hardcoded like http://demo.boldminded.com/en/shards/jund

The URLs that I’m getting in my links are [SITE_URL]/?ACT=31&site_id=1&lang_id=2&url=aHR0cHM6Ly9nb3YudGV4YXMubG9jYWwvZmlyc3QtbGFkeQ==

Is there a setting that I can update to use the URLs that you have or am I using the wrong variable?

#3

Mighty Citizen

I see the {translated_url} variable now vs. the {switch_language_url} - I switched to that but I’m getting some inconsistent behavior. I’m going to try uninstalling Publisher completely from my test site and then reinstall and see if that does anything

#4

Mighty Citizen

Comment has been marked private.

#5

BoldMinded (Brian)

What does the template code look like that is rendering the button you’re referring to?

#6

Mighty Citizen

I only have two languages, so it’s rendering just the one button {exp:publisher:languages show_current=”no”} {long_name} {/exp:publisher:languages}

#7

Mighty Citizen

Oops, sorry - here’s the formatted code

{exp:publisher:languages show_current="no"}
                  <a href="http://{translated_url}" class="button hollow button--light m-b-0">{long_name}</a>
                {/exp:publisher:languages}
#8

BoldMinded (Brian)

I haven’t logged into that site yet, but are you using Structure?

Try one thing for me… go to the Service/Url/Url.php file around line 900 and comment out this if statement and let me know if it works after that.

if ($fromLanguageId === $toLanguageId) {
            return $this->addPrefixToUrl($url);
        }
#9

Mighty Citizen

Not using Structure - I commented that out, and it’s still having the same issue

#10

BoldMinded (Brian)

I just tried the FTP info from the other ticket and it didn’t work.

BTW, I like the new company name and website 😊

#11

Mighty Citizen

Did you try SFTP - it’ll only work with SFTP for me. I’ve resaved the password in case that was incorrect.

And thank you! We’re really excited about our rebrand too 😊

#12

Mighty Citizen

Quick question that I can throw into a separate ticket if needed - should the date text be getting translated on the frontend of the site? I have the Spanish language pack in the /system/user/languages/ folder (which definitely is old, but it looks like EE is using the same language file at least for the Month language.) I have the language pack chosen in the Publisher language settings.

#13

BoldMinded (Brian)

I’m not sure if the language packs affect the front-end translation of date variables to be honest. The language packs are usually to translate the CP pages. I’ve handled it in the past by making phrases for each month, and if the format is different, e.g. day/month/year or month/day/year then you can make those phrases too, e.g. {some_date format=”{phrase:date_format}”} and the translation would have the %m/%d/%Y or %d/%m/%Y in it depending on how the language or region displays dates.

#14

BoldMinded (Brian)

Would it possible for you to create a reduction template that has that languages tag and nothing else in it to replicate the issue? There are a ton of other things happening on that page and it makes it difficult to debug over FTP b/c of all the noise.

#15

Mighty Citizen

Comment has been marked private.

#16

BoldMinded (Brian)

Soooo, what is up with your server? Any time I use var_dump(), echo, or print_r() it just returns a white screen. This isn’t normal 😊

#17

Mighty Citizen

Might be because gzip compression is turned on? Sometimes if I have that disabled and there are PHP errors, the page will output a 503 error. I’ve disabled gzip and enabled debugging.

Let me know if that helps!

#18

BoldMinded (Brian)

I found the problem and fixed it on your dev server. The next comment will include a link to the full build. Note that this change is in a place that may have an impact on how translated urls are handled. Any time I make a change to this part of the code, it makes me nervous because there is a lot going on. I’ll test this on my demo site and another production site to see if the change has any adverse side effects. If not then we’ll call this fix good, but it something comes up in the other two sites I may need to revisit this change.

#19

BoldMinded (Brian)

Comment has been marked private.

#20

Mighty Citizen

Awesome - I’ve added that latest build to their environment and so far so good.

Btw, I did notice that on another site of ours with Publisher installed, the date text would get updated based on the language pack selected when the user toggled between the languages - however this was an EE 2 site. I could get this current site to use the Spanish date text, but only if I updated my user profile settings to Spanish - not by toggling with the frontend button. Not a huge concern of ours at the moment, but figured I’d let you know.

#21

Mighty Citizen

May have spoken too soon - the translated URLs seem to be working for every page except the homepage. We can toggle to Spanish, but can’t toggle back to English.

#22

BoldMinded (Brian)

Take a look at comment #8 above. Is that if statement still commented out or not? If not, does commenting it out fix the problem? I’ve determined that that conditional is not necessary so I’m removing it from the next release.

#23

Mighty Citizen

It isn’t commented out - I went ahead and commented out and the problem still exists. I tried this on the dev environment that I gave you access to and also the one on the client’s staging environment

#24

Mighty Citizen

Sorry to add to this while we have the other issue still being looked at, but wanted to mention it in case you had any ideas off the top of your head:

For some reason, every 5 or so consecutive clicks/page changes on the frontend or the backend of the site, the user will get either a 500 error (on the backend) or a “Too many redirects” error that eventually redirects properly (on the frontend). - It only seems to happen if the page clicks are consecutive within a relatively short amount of time - It isn’t happening on our LAMP environment - just on the Windows environment - The issue goes away when I uninstall Publisher

I was thinking there may be a session limit that we’re hitting somewhere - there aren’t any relevant errors in the log so I’m not sure what could possibly be happening

#25

BoldMinded (Brian)

The CP login in the other ticket doesn’t appear to be working. What are the URL Translations settings set to? (screenshot?)

#26

Mighty Citizen

The “Edit Ticket” button was missing from the other ticket, but I went ahead and added the CP credentials to this ticket. I also added a screenshot of those URL translation settings

#27

BoldMinded (Brian)

Regarding the LAMP vs Windows environment, I’m not even sure what to think about that. I also changed my local settings to try to replicate the switching issue and can’t replicate it. The next comment will have the latest build, just so we’re on the same page.

#28

BoldMinded (Brian)

Comment has been marked private.

#29

Mighty Citizen

Regarding the redirect issue on the frontend, it seemed to go away when I switched the redirect to a 302 so we’re calling it a day on that issue. Regarding the 500 error, they were getting “Aborted connection 3009 to db (Got an error reading communication packets)” - I told them to take a look at their my.ini file and compare to their other working environment, but they’re still looking into it.

Alright for the button toggling issue on the homepage, I grabbed that latest build and upgraded, and I’m still getting the issue on my local, dev (the one you have access to), and their staging environment.

#30

Mighty Citizen

Forgot to mention that the Aborted connection error was in their MySQL logs

#31

Mighty Citizen

Seems like in /Service/Url/Url.php, the conditional at line 1016 is incorrectly processing the first conditional as true for me, instead of processing as true at line 1051 where it should be. For some reason, the $toLanguage model isn’t being passed properly to the shouldAddPrefix function so at line 658 in that same file, it instead is grabbing the current language ID

#32

Mighty Citizen

Actually even in line 369 in mod.publisher.php, the third parameter where the $language model is being passed to $this->url->getTranslatedUrl, in /Service/Url/Url.php, the actual getTranslatedUrl function doesn’t actually get passed the $language model properly, and is instead getting set to the $currentLanguage on line 904

Not sure what that all means in terms of a solution, and hope this helps in any way

#33

BoldMinded (Brian)

This absolutely helps. Thanks. I’ll take a look at those lines locally and it gives me a place to start if I login to your FTP.

#34

BoldMinded (Brian)

I’m not sure what you mean by the 3rd parameter doesn’t get passed in line 369. I did some logging and it appears to be passing the language with the id of 2 every time.

line 369: $translatedUrl = $this->url->getTranslatedUrl(NULL, $this->request->getCurrentLanguage(), $language);
#35

Mighty Citizen

Hey Brian - you’re right. I was looking at that line incorrectly

#36

BoldMinded (Brian)

I think I fixed the issue. Please test other urls on your site to make sure it didn’t have any side effects.

#37

BoldMinded (Brian)

Comment has been marked private.

#38

Mighty Citizen

That seeeeems to be working so far - I’ll let you know if anything comes up. Thanks again!

Btw the 500 error seems to have gone away after upgrading their PHP from 7.1.3 to 7.1.13, which I didn’t think would help but so far so good.

#39

BoldMinded (Brian)

Comment has been marked private.

#40

Mighty Citizen

Yeah, who knows, but at this point I’m just happy it’s working 😊

One thing that I forgot to mention - after the upgrade, the Control Panel was spinning on every page load and I looked at the Network panel of developer tools and saw that it was stalling loading the following: /eewebadmin.php?S=0&D=cp&C=javascript&M=load&file=ext_scripts

That led me to this post: https://expressionengine.stackexchange.com/questions/4848/slow-control-panel-js-and-css-loads - I tried disabling the HTTPS headers like one of the comments recommended, but then I read the last comment on the page, which definitely seemed like the source:

I had the very same problem attempting to load the ext_scripts entry as well. It would work on developer’s machines but not on the actual test / production servers. In our situation it turned out to be because the actual servers were in a DMZ zone where the firewalls did not permit outbound HTTP / HTTPS traffic and one EE plugin (Publisher) was attempting a phone home HTTPS request to check to see if updates were available. Worked around this by putting a /etc/hosts entry in place for the requested domain (boldminded.com) and pointing it to 127.0.0.1.

They added in that hosts entry and it resolved the issue but wanted to let you know.

Thanks for all of your help again! Kristine

#41

BoldMinded (Brian)

You can turn off the phone home option. Miscellaneous Settings > Enable Version Fetching

#42

Mighty Citizen

D’oh - thanks!

Login to reply