- Issue created by @project update bot
This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.
It is important that any automated tests available are run and that you manually test the changes.
Drupal 11 Compatibility
According to the Upgrade Status module β , even with these changes, this module is not yet compatible with Drupal 11.
Currently Drupal Rector, version 0.20.1, cannot fix all Drupal 11 compatibility problems.
Therefore, these changes did not update the
info.yml
file for Drupal 11 compatibility.The compatibility issues that Upgrade Status found after the Drupal Rector fixes were applied are attached to help you resolve them manually.
Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot β to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.
Debug information
Bot run #11-137198These packages were used to generate the fixes:
- drupal/upgrade_status: 4.1.0
- mglaman/phpstan-drupal: 1.2.10
- palantirnet/drupal-rector: 0.20.1
This is an automated patch generated using Upgrade Status and Drupal Rector. Please see the issue summary for more details. A merge request (MR) is also openend and updated.
It is important that any automated tests available are run and that you manually test the changes.
Drupal 11 Compatibility
According to the Upgrade Status module β , even with these changes, this module is not yet compatible with Drupal 11.
Currently Drupal Rector, version 0.20.3, cannot fix all Drupal 11 compatibility problems.
Therefore, these changes did not update the
info.yml
file for Drupal 11 compatibility.The compatibility issues that Upgrade Status found after the Drupal Rector fixes were applied are attached to help you resolve them manually.
Leaving this issue open, even after committing the current patch or merging the MR, will allow the Project Update Bot β to post additional Drupal 11 compatibility fixes as they become available in Drupal Rector.
Debug information
Bot run #11-199781These packages were used to generate the fixes:
- drupal/upgrade_status: 4.3.2
- mglaman/phpstan-drupal: 1.2.11
- palantirnet/drupal-rector: 0.20.3
- First commit to issue fork.
- π§πͺBelgium flyke
I only added the D11 version requirements to the MR for now.
I was not sure what to do with this error:
Call to deprecated method getEmbedCode() of class Drupal\oembed_lazyload_youtube\Plugin\oembed_lazyload\ProviderEnhancer\YoutubeEnhancer. Deprecated in oembed_lazyload:2.1.0 and is removed from oembed_lazyload:3.0.0. Switch to using regex based code extraction instead.
So for now, I just left getEmbedCode(), made a copy of that function and then used that alternative function:
/** * Attempts to parse out an embed code from the provided url. * * @param string $url * The url to attempt to parse. * * @return false|string|null * The embed code, or a falsy value if the embed code cannot be parsed. * * @deprecated in oembed_lazyload:2.1.0 and is removed from oembed_lazyload:3.0.0. Switch to using regex based code extraction instead. * * @see https://www.drupal.org/node/3415047 */ protected function getEmbedCode($url) { $embed_code = NULL; if (strpos($url, 'youtube.com/watch') !== FALSE) { $embed_code = substr($url, strpos($url, '?v=') + 3); } elseif (strpos($url, 'youtube.com/v/') !== FALSE) { $embed_code = substr($url, strpos($url, '/v/') + 3); } elseif (strpos($url, 'youtu.be/') !== FALSE) { $embed_code = substr($url, strpos($url, 'youtu.be/') + 9); } elseif (strpos($url, 'youtube.com/playlist?list=') !== FALSE) { $embed_code = substr($url, strpos($url, 'youtube.com/playlist?list=') + 26); } elseif (strpos($url, 'youtube.com/shorts/') !== FALSE) { $embed_code = substr($url, strpos($url, 'youtube.com/shorts/') + 19); } // Cut off any query parameters and fragments. return preg_replace('/[?&#].*/', '', $embed_code); } /** * Attempts to parse out an embed code from the provided url. * * @param string $url * The url to attempt to parse. * * @return false|string|null * The embed code, or a falsy value if the embed code cannot be parsed. * * @see https://www.drupal.org/node/3415047 */ private function getYoutubeEmbedCode($url) { $embed_code = NULL; if (strpos($url, 'youtube.com/watch') !== FALSE) { $embed_code = substr($url, strpos($url, '?v=') + 3); } elseif (strpos($url, 'youtube.com/v/') !== FALSE) { $embed_code = substr($url, strpos($url, '/v/') + 3); } elseif (strpos($url, 'youtu.be/') !== FALSE) { $embed_code = substr($url, strpos($url, 'youtu.be/') + 9); } elseif (strpos($url, 'youtube.com/playlist?list=') !== FALSE) { $embed_code = substr($url, strpos($url, 'youtube.com/playlist?list=') + 26); } elseif (strpos($url, 'youtube.com/shorts/') !== FALSE) { $embed_code = substr($url, strpos($url, 'youtube.com/shorts/') + 19); } // Cut off any query parameters and fragments. return preg_replace('/[?&#].*/', '', $embed_code); } /** * {@inheritdoc} */ public function getPlaceholder($url, Resource $resource, array $settings) { $placeholder = parent::getPlaceholder($url, $resource, $settings); if ($settings['placeholder_asset_type'] === 'remote_asset' && $embed_code = $this->getYoutubeEmbedCode($url)) {
I'm guessing this would need to be dealt with another way ?
Lastly, I'm not sure how to deal with these kind of notices:
Call to deprecated method getEmbedCode() of class Drupal\oembed_lazyload_youtube\Plugin\oembed_lazyload\ProviderEnhancer\YoutubeEnhancer. Deprecated in oembed_lazyload:2.1.0 and is removed from oembed_lazyload:3.0.0. Switch to using regex based code extraction instead.
- πΊπΈUnited States luke.leber Pennsylvania
Yes - thank you. The call to `::getEmbedCode` is an internal deprecation to this module. It looks like there are some automated test fails in HEAD that need to be addressed, but this module is on my task list this week to bring up to speed and get the issue queue flushed.
- π§πͺBelgium flyke
@luke.leber that's great, because I have a project that I'm trying to update to Drupal 11 and this is the only blocker left, I mean the only module in /admin/reports/upgrade-status that I was unable to make D11 compatible.
So it would be okay to move the regex code from my new function getYoutubeEmbedCode() into the getEmbedCode() function and remove the deprecated tag from that function, and use getEmbedCode() again and remove getYoutubeEmbedCode().
Then I think the only issues left to address are these:
The 'oembed_lazyload_youtube/youtube' library is not defined because the defining extension is not installed. Cannot decide if it is deprecated or not.
- πΊπΈUnited States luke.leber Pennsylvania
You shouldn't need to do anything with the regex deprecation :-). That'll work in D11.
That deprecation message is one that I added to let any users that are customizing this module with their code that some interfaces will be changing in 3.0.x (which I don't have a timeline for yet).
I'm hoping to get a release cut this week with d11 support.
- πΊπΈUnited States luke.leber Pennsylvania
Re-targeted against 2.0.x - looks like there was some core shiftage that impacts the 2.1.x dev branch that will take more effort.
Plan is to ship D11 compat for 2.0.x and follow up for 2.1.x...
- πΊπΈUnited States luke.leber Pennsylvania
NR for MR !33 for 2.0.x.
I have tested manually against 10.3.x. Merge request !33 still requires manual testing against a Drupal 11.x site to land.
-
luke.leber β
committed fc32471b on 2.0.x
Issue #3438529: Automated Drupal 11 compatibility fixes for...
-
luke.leber β
committed fc32471b on 2.0.x
- πΊπΈUnited States luke.leber Pennsylvania
Tested against 11.0.4 - seems to work fine. Given there were test only changes, I'm going to merge this now and cut a release for 2.0.x in the morning.
If there are any issues discovered for 11.x, we'll fix 'em with all haste, but I'm confident in my testing.
- Status changed to Fixed
3 months ago 12:35am 13 September 2024 - πΊπΈUnited States luke.leber Pennsylvania
Opened https://www.drupal.org/project/oembed_lazyload/issues/3474030 π Add D11 support for 2.1.x-dev Active to follow-up on the 2.1.x failures.
Automatically closed - issue fixed for 2 weeks with no activity.