Closed (duplicate)
Project:
Drupal core
Version:
11.x-dev
Component:
language system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 May 2015 at 10:36 UTC
Updated:
4 Aug 2024 at 10:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
joshi.rohit100Unable to find base_path() in LanguageNegotiationUrlTest. Looks like its already fixed.
Comment #2
wim leersThe usage is not in the test, but in the code itself.
Comment #3
afedoruk commentedComment #5
afedoruk commentedI'm a novice and I'm not sure what should I do if test passes on my local installation but fails during d.o test.
BTW, failed LanguageUILanguageNegotiationTest itself uses base_path()
Comment #6
dileepmaurya commentedreplaced rtrim(base_path(), '/'); with $request->getBasePath();
Comment #7
dileepmaurya commentedComment #9
wim leersIt may be passing locally because it only works for sites installed in the root (i.e.
http://example.com/), not in a subdirectory (i.e.http://example.com/subdir/).These tests can indeed be tricky/frustrating to get right. Don't let yourself become demotivated!
Comment #10
izus commentedhi,
hopefully this one passes :)
Comment #12
izus commentedWhat about this !
Comment #13
izus commentedComment #14
cilefen commentedComment #16
izus commentedComment #18
izus commenteddon't give up !
Comment #20
izus commentedComment #26
izus commented#16 seems to make it but there is something wrong with the "// Test HTTPS via current URL scheme." in Drupal\language\Tests\LanguageUILanguageNegotiationTest
that's the only failing test
Comment #27
neetu morwani commentedLast Patch does not apply anymore.
Comment #28
neetu morwani commentedComment #29
neetu morwani commentedComment #30
plachSomething went wrong with reroll, the patch contains only an empty line now.
Comment #31
joshi.rohit100Comment #33
borisson_The failure in the tests can be traced back to the
Request::createin LanguageUILanguageNegotiationTest::testLanguageDomain.This only happens when running drupal from a sub-folder (something like http://example.com/drupal/), as far as I can see this is because the
request::getBaseUrlmethod can't correctly generate a base url inRequest::prepareBaseUrl.I'm assuming the best way to fix this is to change the Request::create code to include one (or more) of the needed server variables (SCRIPT_NAME, SCRIPT_FILENAME, PHP_SELF) to make sure that the base url is getting returned correctly.
I can't seem to figure out what combination of those variables should work though.
Attached patch does remove the base_path function from the test. The LanguageNegotiationUrlTest still passes without this.
Comment #34
znerol commentedMaybe take a look at #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service, but I'm not sure whether the changes over there are isolatable and portable to this issue.
Comment #35
znerol commentedTwo problems here.
The first one: Use
getBasePath()(notgetBaseUrl()). Also the Symfony version does not add a slash, therefore I expect thertrimto be superflous.The second one:
$request->getBaseXXX()is always relative to the front controller (i.e.index.php). If this is executed from within a nested front controller (e.g. core/authorize.php), then/coreis appended to the base path to the drupal root. This is what the other issue is trying to resolve.Comment #36
borisson_Using
getBasePath()overgetBaseUrl()doesn't make a difference.In the testing I've done, the request come from /index.php as front controller, so the change in the other issue doesn't seem relevant here.
I've added a patch that uses the
getBasePath()and introduces 2 new debug statements so it's clearer what the actual problem is. The tests will still fail with the attached patch.Comment #40
borisson_Postponing this issue until #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service lands.
Comment #41
borisson_This is included in the current patch in #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service. I think this can be closed.
Comment #42
tr commentedNo, the problem in this issue is NOT fixed by the patch in #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service. Maybe it should be, but none of the above information was posted to that other issue so the existing patch in that issue doesn't even try to remove base_path() from the unit test. Closing this issue just hides the problem and assures it won't be fixed.
This remains a valid, unaccomplished task that still needs to be addressed. If you think that #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service should handle this problem, then this information needs to be added to that issue and the patch in that issue needs to be re-rolled to include the changes from #36 above.
Comment #48
quietone commentedI just read the MR over in #2529170: [PP-1] Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service and it now includes updating the Unit test. I am closing this as a duplicate and transferring credit.