wrav / oembed

A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.
MIT License
37 stars 35 forks source link

Vimeo URLs not working in any environment #154

Open angieherrera opened 1 month ago

angieherrera commented 1 month ago

Hi!

oEmbed seems to have stopped working with Vimeo URLs. Similar to this issue but environment doesn't make a difference and oEmbed is up to date as far as I can tell.

YouTube URLs work without issue. For Vimeo URLs, in the CP we get a "Please check your URL." error message and on the front-end the video just doesn't show up.

Not sure how else to troubleshoot.

Thank you!

d-simon commented 1 month ago

Experiencing the same since circa yesterday!

The site in question is on Craft 3.9 and oEmbed 1.13.19 as well

reganlawton commented 1 month ago

@angieherrera @d-simon

If you're using v1.*, the issue is most likely with the core package embed/embed, currently set to "embed/embed": "^3.3". This branch is quite old and the core package has not been updated since then.

If running composer update embed/embed doesn't resolve the issue, you might need to reach out to the maintainers, as this plugin mainly serves as an interface for that package.

However, it could also be the plugin itself causing problems. I suggest checking the log files to see what might be causing the issue and then reporting here.

I'm currently swamped with work, but I can help if you provide more information about your specific problem. Once the logs offer some insight into where things are going wrong we can start working on a solution for you both.

d-simon commented 1 month ago

Thank you @reganlawton for taking the time to respond! Unfortunately, my logs don't reveal anything. I'm simply getting a 200 OK and a "Please check your URL.".

I did try override embed/embed to ^4.4 but that resulted in all urls producing "Please check your URL."

One thing that would really help is if you could you point me to the location in the codebase where the "Please check your URL." error is produced? And where the embed/embed is invoked so I can try bumping the version on a fork 🙏

EDIT: I suppose this is the file on V1 https://github.com/wrav/oembed/blob/v1/src/services/OembedService.php

AndyVohm commented 1 month ago

We are experiencing the same issue as of this morning on a CraftCMS 3 site running:

Craft Pro 3.9.13 oEmbed 1.13.19

Not currently getting any useful errors.

CassadyTransom commented 1 month ago

Same issue here as well:

Craft Pro 3.0.13 oEmbed 1.13.19

Same Error "Please check your URL."

angieherrera commented 1 month ago

Thanks for the response @reganlawton. I'm unfortunately not seeing any specific errors in the logs either.

reganlawton commented 1 month ago

@d-simon if we would to use more updated embed/embed version aka v4 you'll have to update the plugin and in that case the CMS.

It seems that the core package is no longer working with the service, this is most likely due to VIMEO changing its API spec and discontinuing the older spec.

I'd recommend checking if your able to update your sites as v1 of Oembed is not really supported as the version that the plugin uses is the older version of the core package, the newer version have a COMPLETE rewrite.

@d-simon This is why updating the embed to v4.x will cause errors the core package is completely different code wise.

reganlawton commented 1 month ago

Just to be clear, Oembed V3 supports both CraftCMS 4 and 5.

It is a breaking change internally and may differ code wise as the core plugin changed internally and it wasn't really possible with my limited time to get 100% coverage on old features.

But 98% of everything still there and shouldn't impact unless you were looking for something niche

Slgoetz commented 1 month ago

Any update here? Same setup, same experience.

reganlawton commented 1 month ago

I looked into the issue and found that Vimeo is rate limiting Status Code 429.

I'm guessing they have stopped supporting embedding videos that aren't authenticated. I'm looking into what I can do my end.

reganlawton commented 1 month ago

Can confirm that CraftCMS 4+ and latest version of the plugin are not impacted so this has to be an issue with the old OEMBED that is used with Vimeo.

I'm seeing if there is a workaround.

reganlawton commented 1 month ago

I have a temp fix but it'll be using the same code of the newest branch just removing all the static typing stuff from I'll post a new composer tag when it's up.

This is a HOTFIX and will need some testing as the core package we use, embed v4, is different from embed v3 I've tried matching features but as discussed there are edge cases that could cause issues.

reganlawton commented 1 month ago

Ok, so for anyone that wants the temp fix.

"wrav/oembed": "dev-hotfix/vimeo-craft-v3"

You'll need to check the changes to your sites but 98% it's all the same. If you want more fixes, let me know or make a PR, I'll be able to help up till about 1-2am AEST.

As always this is a quick resolve there may be bugs PLEASE test and report them if they are found.

d-simon commented 1 month ago

First off: Thank you @reganlawton for taking the time for this! Amazing! 🙌

PHP 7.4: Union types don't exist yet. Plugin works in displaying. Fails to create preview and fails to save.

PHP ^8: Plugin works in displaying. Succeeds saving. Just fails to create a preview with this error:

yii\base\ErrorException: Type of wrav\oembed\controllers\DefaultController::$allowAnonymous must not be defined (as in class craft\web\Controller) in /var/www/html/vendor/wrav/oembed/src/controllers/DefaultController.php:24
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

EDIT: Removing line 30 in DefaultController fixes the preview: // protected array|int|bool $allowAnonymous = false;

EDIT2: After removing line 30 saving for PHP version 7.4 fails with this error:

TypeError: Return value of wrav\oembed\fields\OembedField::serializeValue() must be an instance of wrav\oembed\fields\mixed, array returned in /var/www/html/vendor/wrav/oembed/src/fields/OembedField.php:192
Stack trace:
#0 /var/www/html/vendor/craftcms/cms/src/base/Element.php(2204): wrav\oembed\fields\OembedField->serializeValue(Object(wrav\oembed\models\OembedModel), Object(craft\elements\MatrixBlock))
#1 /var/www/html/vendor/yiisoft/yii2/validators/InlineValidator.php(77): craft\base\Element->validateCustomFieldContentSize('videoUrl', NULL, Object(yii\validators\InlineValidator), Object(wrav\oembed\models\OembedModel))
#2 /var/www/html/vendor/yiisoft/yii2/validators/Validator.php(260): yii\validators\InlineValidator->validateAttribute(Object(craft\elements\MatrixBlock), 'videoUrl')
#3 /var/www/html/vendor/yiisoft/yii2/base/Model.php(368): yii\validators\Validator->validateAttributes(Object(craft\elements\MatrixBlock), Array)
#4 /var/www/html/vendor/craftcms/cms/src/fields/Matrix.php(794): yii\base\Model->validate()
#5 /var/www/html/vendor/craftcms/cms/src/base/Element.php(2177): craft\fields\Matrix->validateBlocks(Object(craft\elements\Entry), NULL)
#6 /var/www/html/vendor/yiisoft/yii2/validators/InlineValidator.php(77): craft\base\Element->validateCustomFieldAttribute('field:gallery', Array, Object(yii\validators\InlineValidator), Object(craft\elements\db\MatrixBlockQuery))
#7 /var/www/html/vendor/yiisoft/yii2/validators/Validator.php(260): yii\validators\InlineValidator->validateAttribute(Object(craft\elements\Entry), 'field:gallery')
#8 /var/www/html/vendor/yiisoft/yii2/base/Model.php(368): yii\validators\Validator->validateAttributes(Object(craft\elements\Entry), Array)
#9 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(2569): yii\base\Model->validate()
#10 /var/www/html/vendor/craftcms/cms/src/services/Elements.php(785): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, false, NULL)
#11 /var/www/html/vendor/craftcms/cms/src/controllers/EntriesController.php(409): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#12 [internal function]: craft\controllers\EntriesController->actionSaveEntry(false)
#13 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#14 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#15 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save-entry', Array)
#16 /var/www/html/vendor/craftcms/cms/src/web/Application.php(295): yii\base\Module->runAction('entries/save-en...', Array)
#17 /var/www/html/vendor/craftcms/cms/src/web/Application.php(608): craft\web\Application->runAction('entries/save-en...', Array)
#18 /var/www/html/vendor/craftcms/cms/src/web/Application.php(274): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#19 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#20 /var/www/html/public/index.php(24): yii\base\Application->run()
#21 {main}
stevenvandemoortele commented 1 month ago

Thank you @reganlawton for the hotfix. I made a fork that removes the mixed types for PHP 7.4 & also replaces www.vimeo.com/ & vimeo.com/ with player.vimeo.com/video to fix some CSP issues.

Do I need to make a PR for it?

d-simon commented 1 month ago

Made a quick PR for PHP 7.4 here (sans @stevenvandemoortele's string replacement – Are they needed?) https://github.com/wrav/oembed/pull/155

stevenvandemoortele commented 1 month ago

Made a quick PR for PHP 7.4 here (sans @stevenvandemoortele's string replacement – Are they needed?) #155

They may not be needed for your content / setup. I had an issue where videos embedded using the following pattern https://vimeo.com/<id> wouldn't play or render a preview.

I got this error in console Refused to display 'http://vimeo.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

d-simon commented 1 month ago

Made a quick PR for PHP 7.4 here (sans @stevenvandemoortele's string replacement – Are they needed?) #155

They may not be needed for your content / setup. I had an issue where videos embedded using the following pattern https://vimeo.com/<id> wouldn't play or render a preview.

I got this error in console Refused to display 'http://vimeo.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

Oh interesting. For me it's working locally and now deployed in prod without the replacement.

To anyone reading, you can test it from my fork (or your own) by adding this to your composer.json

    "require": {
        ...
        "wrav/oembed": "dev-hotfix/vimeo-craft-v3"
    },
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/d-simon/oembed"
        }
    ],
reganlawton commented 1 month ago

Ok thanks to @d-simon for the PR changes. I have merged I didn't test fully that's why I asked for people to test I was doing the hot fix between work stuff.

Let me know if anyone else having issues now the PR has merged. Be sure to composer update to get new changes

DavidLaridon commented 1 month ago

Made a quick PR for PHP 7.4 here (sans @stevenvandemoortele's string replacement – Are they needed?) #155

They may not be needed for your content / setup. I had an issue where videos embedded using the following pattern https://vimeo.com/<id> wouldn't play or render a preview.

I got this error in console Refused to display 'http://vimeo.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

The X-Frame-Options error in console seems to happen because you can no longer use https://vimeo.com/... inside an iframe. You have the use the player url https://player.vimeo.com/... instead. I found the same issue for youtube urls.

Any idea if there is a workaround/fix for that? I see this issue for some Craft 3 websites, but not on Craft 4 or 5.

d-simon commented 1 month ago

FWIW: I had not had those issues with my craft 3 instance vimeo videos both locally and in production. In my case the embedded iframe is actually pointing to player.vimeo.com. Hinting at the possibility that there might something wrong with your embed/embed?

<iframe src="https://player.vimeo.com/video/XXXXXXXXXXXX?dnt=1&amp;app_id=YYYYYY" width="426" height="240" frameborder="0" allow="autoplay; fullscreen; picture-in-picture; clipboard-write" title="ZZZZZZ"></iframe>
DavidLaridon commented 1 month ago

Yeah, i'm not sure why but for some reason the url keeps pointing to the https://vimeo.com url and it doesn't transform to the player url when rendering.

EDIT Tracked down this issue: https://github.com/oscarotero/Embed/issues/342 Managed to fix it with composer require slim/psr7

reganlawton commented 1 month ago

Love the support from everyone! Glad this could be resolved. Any additional changes can be posted to the hot fix I'm still trying to think if I merge it into the v1 branch cos I'm a bit scared the missing changes will annoy people 😅

That again they can just statically set the version to the latest release before merging 🤷

ejaedesign commented 1 week ago

Same issue as everyone else. Would there be an official update to the Craft v3 oEmbed plugin?

reganlawton commented 1 week ago

There's the hot fix ATM. I'm doing a ton of work on the plugin ATM to add in support for an adapter system so will be trying to roll it all in a one with TWO versions.

ejaedesign commented 1 week ago

@reganlawton Great! Thank you so much for the hotfix.

Just to be sure, I leave the original:

"wrav/oembed": "1.13.19"

require statement in there, add the:

"wrav/oembed": "dev-hotfix/vimeo-craft-v3"

statement then run composer update?

EKBenI commented 1 week ago

Hey folks,

Tried installing the hotfix from dev-hotfix/vimeo-craft-v3, but getting this error now:

Type of wrav\oembed\Oembed::$schemaVersion must be string (as in class craft\base\Plugin)

Site isn't working now in my local environment.

Seems to be related to this commit

image

Using Craft 4.5.10.

reganlawton commented 1 week ago

What's your PHP version? I believe from memory that is the Craft v3 only branch and Craft 4 has PHP Interface changes that require the "() :string" on the class method.

I'm working on two version of the plugin 1st for PHP without the static typing and 2nd with the static typing. Unless I can find a way with both.

EKBenI commented 5 days ago

@reganlawton PHP 8.1. Fair one, wasn't sure if the hotfix was v3 of the plugin or Craft itself, but getting the same URL issues as others here. Thanks for getting back 🙏

eyekiller-hub commented 5 days ago

@reganlawton - would you have an eta on the Craft 4 version please?

reganlawton commented 5 days ago

@eyekiller-hub can I confirm your version of the plugin your using ATM? I'd have to check, just cooking dinner ATM, but i believe dev-master and 3.* supports CraftCMS v4. Are you referring too to Vimeo itself?

reganlawton commented 5 days ago

But just an update, I'm trying to do a release this week.

ejaedesign commented 5 days ago

@reganlawton Great, thanks so much!

eyekiller-hub commented 5 days ago

@reganlawton we are using oEmbed 2.3.2, and can confirm we now have working. Thank you!

eightseventyeight commented 6 hours ago

Yeah, i'm not sure why but for some reason the url keeps pointing to the https://vimeo.com url and it doesn't transform to the player url when rendering.

EDIT Tracked down this issue: oscarotero/Embed#342 Managed to fix it with composer require slim/psr7

I've got the same X-Frame-Options issue running the hotfix on Craft 3x, is running "composer require slim/psr7" in the Craft project folder the only steps I need to take to fix the https://vimeo.com urls?