Problem/Motivation
I noticed this while working on https://www.drupal.org/project/admin_toolbar/issues/3407845, where a test in the newly set-up CI fails. This is because the test just extends ToolbarAdminMenuTest, where drupalGet is called thusly:
$this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']);
Resulting in this pipeline-error:
TypeError: Behat\Mink\Session::setRequestHeader(): Argument #1 ($name) must be of type string, int given, called in /builds/issue/admin_toolbar-3407845/web/core/tests/Drupal/Tests/UiHelperTrait.php on line 235
As the documentation for drupalGet() states:
An array containing additional HTTP request headers, the array keys are the header names and the array values the header values.
So in the above case it would be
$this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']);
Proposed resolution
Try and find all spots in the code where drupalGet() is called with headers where only one string per header instead of a key-value pair is used, and split them up.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3440169-nr-bot.txt | 90 bytes | needs-review-queue-bot |
Issue fork drupal-3440169
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:
Comments
Comment #3
marcoliverSee MR.
Basically just Ctrl-Shift-F'ed Core for
drupalGet\(.*,.*,.*and then manually combed through the results to find any offending calls.Comment #4
marcoliverComment #5
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #6
dydave commentedThanks a lot Marc-Oliver (@marcoliver) for raising this issue and for your code contributions, it's greatly appreciated!
Just a quick comment to confirm the core module Toolbar test:
Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest::testSubtreesJsonRequestcurrently seems to be failing 🔴 (10.3.x/10.4.x), see:
https://git.drupalcode.org/project/drupal/-/blob/10.3.x/core/modules/too...
I haven't had the time to look any further than that or really test the changes from the merge request (MR!7445), but we would definitely appreciate some reviews, testing and feedback.
Thanks in advance!
Comment #7
marcoliverComment #8
smustgrave commentedHave not reviewed but MR should be against 11.x as the latest dev branch.
Comment #9
dydave commented@marcoliver, when you get a moment, could you please change the target branch of the merge request to 11.x, as requested at #8 ?
It seems I'm unable to edit the merge request, even with push access to the issue fork.
Otherwise if we need to create a new MR, let me know I would be glad to do so.
Thanks!
Comment #14
marcoliverSure thing! I created a new MR (8257) targeting 11.0.x.
Comment #15
smustgrave commentedSo MR should be against 11.x not 11.0.x
Comment #19
marcoliverOops, my bad! MR 8277 now targets 11.x
Comment #20
smustgrave commentedThanks, seems like a good refactor.
Comment #21
alexpottThis is a duplicate of #3421105: Add deprecations for update to behat/* dependencies - it's fine if we continue in this issue as we've start here and not there. But we need to trigger a deprecation in \Drupal\Tests\UiHelperTrait::drupalGet() when
if (is_int($header_name)) {.If this issue does not add the deprecation then we cannot prove we've fixed this in core.
Comment #29
pooja_sharma commentedAddressed the mentioned changes, fixed the test failures case as well
Please review, moved NR
Comment #30
pooja_sharma commentedComment #31
smustgrave commentedLeft some comments about the link. Not sure if the intention is to point to https://www.drupal.org/node/3408184 but currently it's pointing to a drupal issues vs CR.
Comment #33
pooja_sharma commentedUpdated the change record nid
Please review , moved NR
Comment #38
smustgrave commentedComment #31 was a suggestion/question. But if that is the CR it needs to be updated as the CR doesn't match what is being done in the code. Either that's suppose to be the one used or a new one needs to be written.
Comment #39
pooja_sharma commentedThis is something I'm uncertain about.
@alexpott, I have reused change request https://www.drupal.org/node/3408184
can you please confirm is this correct or needs to be written new one?
Comment #40
pooja_sharma commentedI have added change record for respective deprecations & updated change record nid in MR.
Rebased MR, Please review , moved NR
Comment #41
pooja_sharma commentedComment #42
smustgrave commentedWould need to deprecate in 10.4 so this can be backported too.
Comment #43
pooja_sharma commentedUpdated deprecate message version in 10.4
Please review, moved NR
Comment #44
smustgrave commentedThanks believe this one is good to go.
Comment #45
pooja_sharma commentedRebased the MR with latest code, seems fine
Comment #46
pooja_sharma commentedRebased the MR with latest code, seems fine
Comment #47
alexpottCommitted ebe942c and pushed to 11.x. Thanks!
Committed and pushed 519cafc4ab to 11.0.x and 72ea6d707b to 10.4.x and 5ac4362491 to 10.3.x. Thanks!
I've moved the deprecation to 11.1.0 (less disruptive) but backported the changes to 10.3.x as a test-only fix to keep everything aligned and make for easier backports.