Problem/Motivation
The Drupal.toolbar.collapsed is always set taking into account the $base_path, but the test does not take this into account and only checks for /, so if you run the tests in a subdirectory, the testToolbarCollapsedCookie fails.
These are the instances where the cookie can be set:
- toolbar.module
drupal_setcookie('Drupal.toolbar.collapsed', !_toolbar_is_collapsed(),
array(
'samesite' => 'Lax',
'path' => $base_path,
)
);
- toolbar.js
$.cookie(
'Drupal.toolbar.collapsed',
0,
{
// Workaround lack of support for the SameSite attribute in jQuery Cookie.
path: Drupal.settings.basePath + '; SameSite=Lax',
// The cookie should "never" expire.
expires: 36500
}
);
The base path is always set, so the test should match this too.
We are migrating DrupalCI to GitlabCI for Drupal 7, and if this is one of the blockers.
Steps to reproduce
See the failed run here in GitlabCI: https://git.drupalcode.org/project/gitlab_ci_testbed_for_drupal_core/-/j...
I added additional output messages here to see what was the reason: https://git.drupalcode.org/project/gitlab_ci_testbed_for_drupal_core/-/j...
Proposed resolution
Add the check for the base path in the tests.
Remaining tasks
MR to follow.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
Issue fork drupal-3386055
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3386055-cookie-base-path
changes, plain diff MR !4723
Comments
Comment #3
fjgarlin commentedNote how the issue is fixed here https://git.drupalcode.org/project/gitlab_ci_testbed_for_drupal_core/-/j... after applying the same change that is in the MR.
This is a fix to the test, the code is totally fine.
The MR is here: https://git.drupalcode.org/project/drupal/-/merge_requests/4723/diffs
We've been setting the issues that are blockers for GitlabCI as critical.
Please review.
Comment #4
fjgarlin commentedComment #5
poker10 commentedI have checked this and yes, the
Drupal.toolbar.collapsedis being set on two places:1. in
toolbar.js(two times)2. in
toolbar_toggle_pageOn both places the
base_pathis used when setting the cookie. So it seems to be correct that thetestToolbarCollapsedCookie()should use thebase_pathinstead of hardcoded forward slash as well.D7 on DrupalCI does not seems to run in a subdirectory (see the snippet from DrupalCI console:
You are about to create a /var/www/html/sites/default/settings.php file and DROP all tables in your 'jenkins_drupal_d7_274437' database.), so this is probably the case why this was not failing in tests until now.The changes looks good to me and passes all tests, so moving to RTBC. Thanks!
Comment #6
mcdruid commentedThis makes sense; I think it's ready to commit. Thanks!
Comment #8
poker10 commentedCommitted, thanks everyone!