-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In magento 2.2 Changing language twice gives error [bug] #11379
Comments
@rigu12 thank you for your report. |
Hi
I from Magento downloaded ver.2.2, tried to reproduce this issue on a clean installation, in the Luma theme too.
My php is 7.1
Magento Community Engineering <notifications@github.com<mailto:notifications@github.com>> :
@rigu12<https://github.com/rigu12> thank you for your report.
We were not able to reproduce this issue by following the steps you provided. Please provide more detailed steps to reproduce or try to reproduce this issue on a clean installation.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#11379 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ae3hV17NtdgPANz8Pk5ZY1L1jRzi8D-sks5srnr_gaJpZM4P16f6>.
|
The issue is in the url building. To fix this problem, I added the following method to the Store class (Download the Complete Code): public function cleanUrlQueryString($url){
if(preg_match("/\?/", $url)){
$arr = explode('?', $url);
$queryArray = false;
if(isset($arr[1])){
$strArr = parse_str(html_entity_decode($arr[1]), $queryArray);
}
$cleanedUrl = $arr[0];
$cleanedUrl .= ($queryArray) ? '?'.http_build_query($queryArray, '', '&') : '';
return $cleanedUrl;
}
return $url;
} Then I modified the function getCurrentUrl substituting the original lines from 1174 to 1182: $currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString
. ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
return $currentUrl; with this $currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString;
if( preg_match("/\?/",$currentUrl) ){
$currentUrl .= ($storeParsedQuery ? '&'.http_build_query($storeParsedQuery, '', '&') : '');
} else {
$currentUrl .= ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
}
return $this->cleanUrlQueryString($currentUrl); By this way the function return a cleaned query string withouth error. IMPORTANT: howewer this solution does not solve the bug interly, because if you change the language on page of the product details or on a category page the app give a not found page, because does not translate the urlrewrite. In the previous version Magento 2.1.9 the switcher worked fine. |
HI,
I can't find (((Store.php)))) in vendor/magento/module-store/
^^""
…________________________________
寄件者: selusi <notifications@github.com>
寄件日期: 2017年10月13日 下午 08:33:15
收件者: magento/magento2
副本: rigu12; Mention
主旨: Re: [magento/magento2] In magento 2.2 Changing language twice gives error [bug] (#11379)
The issue is in the url building.
Precisly in the file vendore/magento/module-store/Store.php the function getCurrentUrl($fromStore = true).
In fact, so as it showed in your example file, if you click the language switch more times the result query string is: ?___store=en?___store=de that obviously get server error because the
store code "en?___store=de" doesn't exist.
To solve the issue I added the below method to the class Store (Download the Complete Code<https://github.com/magento/magento2/files/1382403/Store.txt>):
public function cleanUrlQueryString($url){
if(preg_match("/?/", $url)){
$arr = explode('?', $url);
$queryArray = false;
if(isset($arr[1])){
$strArr = parse_str(html_entity_decode($arr[1]), $queryArray);
}
$cleanedUrl = $arr[0];
$cleanedUrl .= ($queryArray) ? '?'.http_build_query($queryArray, '', '&') : '';
return $cleanedUrl;
}
return $url;
}
Then I modified the function getCurrentUrl substituting the original lines from 1174 to 1182:
$currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString
. ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
return $currentUrl;
with this
$currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString;
if( preg_match("/?/",$currentUrl) ){
$currentUrl .= ($storeParsedQuery ? '&'.http_build_query($storeParsedQuery, '', '&') : '');
} else {
$currentUrl .= ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
}
return $this->cleanUrlQueryString($currentUrl);
By this way the function return a cleaned query string withouth error.
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#11379 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ae3hV4P5X3p2QsM8gVz6968aTWJCt35Iks5sr0p7gaJpZM4P16f6>.
|
HI
Is work now..thank you!!! i changed it in module-store\model\store.php
And i want to say have new bug too.
i from magento downloaded 2.2 sample_data installed.
and then go to Setup Wizard->Extension Manager->Ready to Install->u will see magento/module-shared-catalog extensions,but can't install.i think maybe is sample_data problem.
…________________________________
寄件者: selusi <notifications@github.com>
寄件日期: 2017年10月13日 下午 08:33:15
收件者: magento/magento2
副本: rigu12; Mention
主旨: Re: [magento/magento2] In magento 2.2 Changing language twice gives error [bug] (#11379)
The issue is in the url building.
Precisly in the file vendore/magento/module-store/Store.php the function getCurrentUrl($fromStore = true).
In fact, so as it showed in your example file, if you click the language switch more times the result query string is: ?___store=en?___store=de that obviously get server error because the
store code "en?___store=de" doesn't exist.
To solve the issue I added the below method to the class Store (Download the Complete Code<https://github.com/magento/magento2/files/1382403/Store.txt>):
public function cleanUrlQueryString($url){
if(preg_match("/?/", $url)){
$arr = explode('?', $url);
$queryArray = false;
if(isset($arr[1])){
$strArr = parse_str(html_entity_decode($arr[1]), $queryArray);
}
$cleanedUrl = $arr[0];
$cleanedUrl .= ($queryArray) ? '?'.http_build_query($queryArray, '', '&') : '';
return $cleanedUrl;
}
return $url;
}
Then I modified the function getCurrentUrl substituting the original lines from 1174 to 1182:
$currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString
. ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
return $currentUrl;
with this
$currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString;
if( preg_match("/?/",$currentUrl) ){
$currentUrl .= ($storeParsedQuery ? '&'.http_build_query($storeParsedQuery, '', '&') : '');
} else {
$currentUrl .= ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
}
return $this->cleanUrlQueryString($currentUrl);
By this way the function return a cleaned query string withouth error.
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#11379 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ae3hV4P5X3p2QsM8gVz6968aTWJCt35Iks5sr0p7gaJpZM4P16f6>.
|
@rigu12 Right! The path of source code is vendor/magento/module-store/model/Store.php I understand they want to improve the structure, but for now serious bugs are so many that it's difficult to use Magento version 2.2.0 for a site in production. |
@rigu12 To install sample data you can use the command line: |
This is a duplicate of #10908 btw 😉 |
But I have some extensions not support 2.2 or php7.1 ,so can’t setup upgrade install but can’t delete in the list ,if I disconnect ,the Magento extension can’t see too.but ..if I don’t disconnect to setup upgrade install other extensions will be error.so how can I do or how can delete don’t need extensions on the list?thank you!!
selusi <notifications@github.com<mailto:notifications@github.com>> 於 2017年10月14日 01:42 寫道:
To install sample data you can use the command line:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex
php bin/magento cache:clean
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#11379 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ae3hV67gEwwjdQj7JGcxmOLFM-zM1D9Vks5sr6EFgaJpZM4P16f6>.
|
@rigu12
Alternativly you can uninstall modules manually:
Before It is better if you make an application and database backup. |
The discussion continues at the following link: |
HI
Sorry sir,can i ask you something about Index Management.
Because Product Price, Stock, Catalog Search PROCESSING.
Don't know what happened not ready.
thank you^^""
…________________________________
寄件者: selusi <notifications@github.com>
寄件日期: 2017年10月14日 下午 11:56
收件者: magento/magento2
副本: rigu12; Mention
主旨: Re: [magento/magento2] In magento 2.2 Changing language twice gives error [bug] (#11379)
For the final solution to the problem please read the following link:
#10908<#10908> #10908<#10908>
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#11379 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ae3hVz6Akl1eY7pU86xqCl7Swz-fcsanks5ssMuDgaJpZM4P16f6>.
|
HI
I only can inside to mysql change the Indexer State (catalog_product_price,cataloginventory_stock,catalogsearch_fulltext: working to valid)
…________________________________
寄件者: selusi <notifications@github.com>
寄件日期: 2017年10月14日 下午 11:56:03
收件者: magento/magento2
副本: rigu12; Mention
主旨: Re: [magento/magento2] In magento 2.2 Changing language twice gives error [bug] (#11379)
For the final solution to the problem please read the following link:
#10908<#10908> #10908<#10908>
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#11379 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/Ae3hVz6Akl1eY7pU86xqCl7Swz-fcsanks5ssMuDgaJpZM4P16f6>.
|
@rigu12 |
Yes, i'm confirm this error, it happen by replace language on end of link |
@rigu12 public function getCurrentUrl($fromStore = true)
{
$sidQueryParam = $this->_sidResolver->getSessionIdQueryParam($this->_getSession());
$requestString = $this->_url->escape(ltrim($this->_request->getRequestString(), '/'));
$storeUrl = $this->getUrl('', ['_secure' => $this->_storeManager->getStore()->isCurrentlySecure()]);
if (!filter_var($storeUrl, FILTER_VALIDATE_URL)) {
return $storeUrl;
}
$storeParsedUrl = parse_url($storeUrl);
$storeParsedQuery = [];
if (isset($storeParsedUrl['query'])) {
parse_str($storeParsedUrl['query'], $storeParsedQuery);
}
$currQuery = $this->_request->getQueryValue();
if (isset($currQuery[$sidQueryParam])
&& !empty($currQuery[$sidQueryParam])
&& $this->_getSession()->getSessionIdForHost($storeUrl) != $currQuery[$sidQueryParam]
) {
unset($currQuery[$sidQueryParam]);
}
foreach ($currQuery as $key => $value) {
$storeParsedQuery[$key] = $value;
}
if (!$this->isUseStoreInUrl()) {
$storeParsedQuery['___store'] = $this->getCode();
}
if ($fromStore !== false) {
$storeParsedQuery['___from_store'] = $fromStore ===
true ? $this->_storeManager->getStore()->getCode() : $fromStore;
}
$currentUrl = $storeParsedUrl['scheme']
. '://'
. $storeParsedUrl['host']
. (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '')
. $storeParsedUrl['path']
. $requestString;
if( preg_match("/\?/",$currentUrl) ){
$currentUrl .= ($storeParsedQuery ? '&'.http_build_query($storeParsedQuery, '', '&') : '');
} else {
$currentUrl .= ($storeParsedQuery ? '?' . http_build_query($storeParsedQuery, '', '&') : '');
}
return $this->cleanUrlQueryString($currentUrl);
}
/**
* To clean URL from wrong query string
*
* @return Cleaned url
*/
public function cleanUrlQueryString($url)
{
if(preg_match("/\?/", $url)){
$arr = explode('?', $url);
$queryArray = false;
if(isset($arr[1])){
$strArr = parse_str(html_entity_decode($arr[1]), $queryArray);
}
$cleanedUrl = $arr[0];
$cleanedUrl .= ($queryArray) ? '?'.http_build_query($queryArray, '', '&') : '';
return $cleanedUrl;
}
return $url;
} |
@rigu12 , thank you for your report. |
@selusi Before you give me the code not working on 2.2.3 for hide/remove the code url "?___store=" |
If you change the language twice in a store this system won't redirect you back to the right store. Instead it gives a server error with the message: Requested store is not found
Preconditions
Steps to reproduce
Expected result
Actual result
The text was updated successfully, but these errors were encountered: