Problem/Motivation
OEmbed\Endpoint::buildResourceUrl() incorrectly appends a second question mark if the provider endpoint already contains a query string.
A similar bug exists in UpdateFetcher::buildFetchUrl(), which appends the project-specific URL suffix and optional usage information after an existing fragment, preventing them from being transmitted to the update server.
Steps to reproduce
The oEmbed provider hearthis.at uses an endpoint that already contains a query parameter:
https://hearthis.at/oembed/?format=json
- Enable the Media module.
- Add
hearthis.atto the providers array inOEmbedDeriver::getDerivativeDefinitions(), clear caches and make sure the provider is allowed in the Remote video media type settings. - Add a Remote video media item using https://hearthis.at/dj-molotov/siamo-tutti-antifa-set-mix/ as the source URL.
- Save the media item.
The generated request URL contains ?format=json?url= instead of ?format=json&url=.
When adding a new media item in the UI, Drupal therefore reports:
The provided URL does not represent a valid oEmbed resource.
When created programmatically, bypassing validation, a 400 Bad Request response is displayed instead of the embedded media player:

The loosely related UpdateFetcher bug can be reproduced programmatically by providing a base URL containing a fragment.
Proposed resolution
- Introduce
UrlHelper::appendQueryString()to centralize query string assembly, which is currently handled inconsistently, to ensure existing query strings and fragments are handled correctly across Core. - Use it in both affected methods.
- Ensure the project-specific URL suffix in
UpdateFetcher::buildFetchUrl()is also appended before the fragment.
Remaining tasks
Review.
User interface changes
Previously failing oEmbed resources can now be added and displayed correctly:

Introduced terminology
None.
API changes
Added UrlHelper::appendQueryString().
Data model changes
None.
Release notes snippet
Fixed oEmbed resource fetching for provider endpoints containing existing query parameters and corrected fragment handling in update URLs by introducing a common helper to ensure consistency.
| Comment | File | Size | Author |
|---|---|---|---|
| oEmbed_after.png | 45.47 KB | pancho | |
| oEmbed_before.png | 30.5 KB | pancho |
Issue fork drupal-3641566
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
pancho