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

Uncaught TypeError: ceil(): Argument #1 ($num) must be of type int|float, string given #3401

Closed
hrehfeld opened this issue Jan 29, 2021 · 4 comments · Fixed by #3404 or simplepie/simplepie#670

Comments

@hrehfeld
Copy link

I'm on 1.17.1-dev, docker:

freshrss       | FreshRSS[164]: SimplePie GET http://podcast.hr2.de/derTag/podcast.xml
freshrss       | PHP Fatal error:  Uncaught TypeError: ceil(): Argument #1 ($num) must be of type int|float, string given in /var/www/FreshRSS/lib/SimplePie/SimplePie/Item.php:2871
freshrss       | Stack trace:
freshrss       | #0 /var/www/FreshRSS/lib/SimplePie/SimplePie/Item.php(2871): ceil()
freshrss       | #1 /var/www/FreshRSS/lib/SimplePie/SimplePie/Item.php(1062): SimplePie_Item->get_enclosures()
freshrss       | #2 /var/www/FreshRSS/lib/SimplePie/SimplePie/Item.php(937): SimplePie_Item->get_enclosure()
freshrss       | #3 /var/www/FreshRSS/app/Models/Feed.php(371): SimplePie_Item->get_permalink()
freshrss       | #4 /var/www/FreshRSS/app/Controllers/feedController.php(354): FreshRSS_Feed->loadEntries()
freshrss       | #5 /var/www/FreshRSS/app/Controllers/feedController.php(548): FreshRSS_feed_Controller::actualizeFeed()
freshrss       | #6 /var/www/FreshRSS/lib/Minz/Dispatcher.php(119): FreshRSS_feed_Controller->actualizeAction()
freshrss       | #7 /var/www/FreshRSS/lib/Minz/Dispatcher.php(47): Minz_Dispatcher->launchAction()
freshrss       | #8 /var/www/FreshRSS/lib/Minz/FrontController.php(81): Minz_Dispatcher->run()
freshrss       | #9 /var/www/FreshRSS/app/actualize_script.php(75): Minz_FrontController->run()
freshrss       | #10 {main}
freshrss       |   thrown in /var/www/FreshRSS/lib/SimplePie/SimplePie/Item.php on line 2871
@Alkarex Alkarex added this to the 1.18.0 milestone Jan 29, 2021
@Alkarex
Copy link
Member

Alkarex commented Jan 29, 2021

Hello,
Which more precise tag are you using: freshrss/freshrss:latest ?

@Alkarex
Copy link
Member

Alkarex commented Jan 29, 2021

This feed uses an empty length, which crashes with PHP 8+

<enclosure url="https://mp3podcasthr-a.akamaihd.net:443/mp3/podcast/derTag/derTag_20210129_87093232.mp3" length="" type="audio/mpeg"/>

Fix coming

@Alkarex Alkarex self-assigned this Jan 29, 2021
Alkarex added a commit to Alkarex/FreshRSS that referenced this issue Jan 29, 2021
#fix FreshRSS#3401
Use `!empty` instead to properly handle falsy values such as empty
string, 0, false, null.
While 0 would be grammatically fine, it does not make sense for a media
length or height, or width or framerate or bitrate
@Alkarex
Copy link
Member

Alkarex commented Jan 29, 2021

Fix ready #3404

Alkarex added a commit to FreshRSS/simplepie that referenced this issue Jan 29, 2021
#fix FreshRSS/FreshRSS#3401 (crash with PHP
8+)

Use `!empty` instead of `isset()` to properly handle falsy values such
as empty string, 0, false, null.
While 0 would be grammatically fine in some cases, it does not make
sense for a media length or height, or width or framerate or bitrate.

Example with feed http://podcast.hr2.de/derTag/podcast.xml

```xml
<enclosure
url="https://mp3podcasthr-a.akamaihd.net:443/mp3/podcast/derTag/derTag_20210129_87093232.mp3"
length="" type="audio/mpeg"/>
```

`isset("")` passes and then `ceil("")` crashes due to wrong type in
PHP8+:

```
Uncaught TypeError: ceil(): Argument #1 ($num) must be of type
int|float, string given in ./SimplePie/SimplePie/Item.php:2871
```

`!empty()` fixes the problem.
Alkarex added a commit to FreshRSS/simplepie that referenced this issue Jan 30, 2021
`ceil()` crashes in PHP8+ in case of invalid input such as empty string.
`intval()` fixes the problem with almost identical beahviour than
`ceil()` in PHP7- (except for flotting point values)

#fix FreshRSS/FreshRSS#3401 (crash with PHP
8+)

Example with feed http://podcast.hr2.de/derTag/podcast.xml

```xml
<enclosure

url="https://mp3podcasthr-a.akamaihd.net:443/mp3/podcast/derTag/derTag_20210129_87093232.mp3"
length="" type="audio/mpeg"/>
```

`isset("")` passes and then `ceil("")` crashes due to wrong type in
PHP8+:

```
Uncaught TypeError: ceil(): Argument #1 ($num) must be of type
int|float, string given in ./SimplePie/SimplePie/Item.php:2871
```
mblaney pushed a commit to simplepie/simplepie that referenced this issue Jan 31, 2021
`ceil()` crashes in PHP8+ in case of invalid input such as empty string.
`intval()` fixes the problem with almost identical beahviour than
`ceil()` in PHP7- (except for flotting point values)

#fix FreshRSS/FreshRSS#3401 (crash with PHP
8+)

Example with feed http://podcast.hr2.de/derTag/podcast.xml

```xml
<enclosure

url="https://mp3podcasthr-a.akamaihd.net:443/mp3/podcast/derTag/derTag_20210129_87093232.mp3"
length="" type="audio/mpeg"/>
```

`isset("")` passes and then `ceil("")` crashes due to wrong type in
PHP8+:

```
Uncaught TypeError: ceil(): Argument #1 ($num) must be of type
int|float, string given in ./SimplePie/SimplePie/Item.php:2871
```
Alkarex added a commit that referenced this issue Jan 31, 2021
#fix #3401 (crash with PHP 8+)

`ceil()` crashes in PHP8+ in case of invalid input such as empty string.
`intval()` fixes the problem with almost identical behaviour than `ceil()` in PHP7- (except for floating point values)

#fix #3401 (crash with PHP 8+)

Example with feed http://podcast.hr2.de/derTag/podcast.xml

```xml
<enclosure url="https://mp3podcasthr-a.akamaihd.net:443/mp3/podcast/derTag/derTag_20210129_87093232.mp3"
length="" type="audio/mpeg"/>
```

`isset("")` passes and then `ceil("")` crashes due to wrong type in PHP8+:

```
Uncaught TypeError: ceil(): Argument #1 ($num) must be of type
int|float, string given in ./SimplePie/SimplePie/Item.php:2871
```

Upstream patch simplepie/simplepie#670
@hrehfeld
Copy link
Author

hrehfeld commented Feb 1, 2021

Seems to be fixed after updating! 👍

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