Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by zero error in both backend and frontend #134

Closed
arentsen opened this issue Feb 22, 2023 · 4 comments
Closed

Division by zero error in both backend and frontend #134

arentsen opened this issue Feb 22, 2023 · 4 comments

Comments

@arentsen
Copy link

After updating to Craft 4 and also the latest version of Oembed, I have an issue with a oembed video field. The front end as well as the backend (!) give the same error, so it is not possible to see in the backend what could be wrong with the video URL. The error message is:

Division by zero

  1. in /vendor/embed/embed/src/Adapters/Adapter.phpat line 567
    558559560561562563564565566567568569570571572573574575576 * (useful to make it responsive).
    *
    • @return float|null
      */
      public function getAspectRatio()
      {
      if ($this->width !== null
      && (strpos($this->width, '%') === false)
      && $this->height !== null && (strpos($this->height, '%') === false)) {
      return round(($this->height / $this->width) * 100, 3);
      }
      return null;
      }

The line that causes this error in the CMS is:

{{ block.getFieldLayout().createForm(block, static).render()|raw }}

On the front end it is the following line that causes the error:

{% if mediaEmbed.valid %}

I can only access the entry that has the video field when I disable the plugin, but it does not give me any more information. It just says that the field belongs to a disabled plugin. I cannot even remove the video link that caused the problem.

Screenshot 2023-02-22 at 22 59 27

Of course, it should not throw off the backend and frontend, just because some content editor saves a wrong video url. Any help would be appreciated.

@iparr
Copy link

iparr commented Mar 22, 2023

I have the same error (Craft v. 4.4.5 and latest OEmbed 2.3.0) running on PHP 8.2.

@arentsen - please backup before trying this, but I think if you change the URL of the problematic field to plaintext then you can go in and edit it - or you could do this from the database directly (mine was in a Matrix field so required some digging!)

For me, I found found this was the problematic one: https://www.facebook.com/watch/live/?v=10156354036834257&ref=watch_permalink - a Facebook video that had been subsequently set to "Can't embed".

Ideally this would fail more gracefully!

I also found that Turning the cache off allows you in to edit and mend, but turning it back on breaks the page again. It's not viable for me to leave the cache on. I removed the troublesome embed.

@arentsen
Copy link
Author

arentsen commented Mar 22, 2023

Good that you were able to remove it. I wasn't able to do it. For me it helped to change a few checkboxes in the plugin's settings (don't remember which ones) and I have kept those settings since.

@reganlawton
Copy link
Member

This is embed/embed issue it seems. I'm updated embed to v4 (#140) this should fix the older embed package issues.

This will be a major release v3.0.0 but for anyone you should be able to just composer update embed/embed to resolve. This is caused by a sub-package not the code in oEmbed itself.

@reganlawton
Copy link
Member

Reopen if need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants