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

php 8.2 [BUG] #801

Open
Woolwit opened this issue Mar 15, 2023 · 5 comments
Open

php 8.2 [BUG] #801

Woolwit opened this issue Mar 15, 2023 · 5 comments
Assignees
Labels

Comments

@Woolwit
Copy link

Woolwit commented Mar 15, 2023

My webhost updated php to 8.1 today and things in my SimplePie powered app broke.
I'm testing things locally now on my Mac using MAMP and SP 1.8.0
Running the Demo I have no problems with php 7.4.33, but when I try it with 8.2 I get errors like...

Deprecated: Creation of dynamic property idna_convert::$slast is deprecated in /Applications/MAMP/htdocs/simplepie-master/idn/idna_convert.class.php on line 96

also 

Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, null given in /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php:933 Stack trace: #0 /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php(933): explode('/', NULL, 2) #1 /Applications/MAMP/htdocs/simplepie-master/Demo/index.php(207): SimplePie\Enclosure->embed(Array) #2 {main} thrown in /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php on line 933

I have a request at my webhost to revert to 7.4 which should be a temporary fix, but I'm not sure how much longer they'll support it. Please advise. Thanks!

@Art4
Copy link
Contributor

Art4 commented Mar 15, 2023

The idna_convert class is outdated and will be replaced with the native idn_to_ascii() function, see #785.

Quick workaround: stop using the idna_convert class. Search for something like include_once('vendor/simplepie/simplepie/idn/idna_convert.class.php'); in your code and remove it.

@Art4
Copy link
Contributor

Art4 commented Mar 15, 2023

Referring to the second error:

Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, null given in /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php:933 Stack trace: #0 /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php(933): explode('/', NULL, 2) #1 /Applications/MAMP/htdocs/simplepie-master/Demo/index.php(207): SimplePie\Enclosure->embed(Array) #2 {main} thrown in /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php on line 933

Seems like there is an error handling an unknown file type. Can you provide the feed url or more details about the media file?

@Woolwit
Copy link
Author

Woolwit commented Mar 16, 2023

Thank You! As for unknown file type error, that's running the Demo right out of the box. I will have some time tonight to dig deeper. Thanks Again!

@Woolwit
Copy link
Author

Woolwit commented Mar 16, 2023

With php 8.2, the demo will run more or less fine if I comment out...
//include_once('../idn/idna_convert.class.php');
But it seems to be having issues with some of the file types that pop up in various feeds...
Fatal error: Uncaught TypeError: explode(): Argument #2 ($string) must be of type string, null given in /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php:933 Stack trace: #0 /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php(933): explode('/', NULL, 2) #1 /Applications/MAMP/htdocs/simplepie-master/Demo/index.php(207): SimplePie\Enclosure->embed(Array) #2 {main} thrown in /Applications/MAMP/htdocs/simplepie-master/src/Enclosure.php on line 933

spError20230316

@jtojnar
Copy link
Contributor

jtojnar commented Mar 16, 2023

Looks like reddit has enclosures without type specified:

<entry>
	<author>
		<name>/u/IgorVozMkUA</name>
		<uri>https://www.reddit.com/user/IgorVozMkUA</uri>
	</author>
	<category label="r/ukraine" term="ukraine"/>
	<content type="html">&lt;table&gt; &lt;tr&gt;&lt;td&gt; &lt;a href=&quot;https://www.reddit.com/r/ukraine/comments/11spul1/the_us_department_of_defense_released_footage_of/&quot;&gt; &lt;img src=&quot;https://external-preview.redd.it/gIH_CDiZfgrYsFyO1GR_dcCHpq-y90MRwAbSnu0cIT8.png?width=640&amp;amp;crop=smart&amp;amp;auto=webp&amp;amp;s=36c121ae80192516cf4b339f5031558791ff6169&quot; alt=&quot;The US Department of Defense released footage of a Russian Su-27 colliding with an American MQ-9 Reaper UAV over the Black Sea&quot; title=&quot;The US Department of Defense released footage of a Russian Su-27 colliding with an American MQ-9 Reaper UAV over the Black Sea&quot; /&gt; &lt;/a&gt; &lt;/td&gt;&lt;td&gt; &amp;#32; submitted by &amp;#32; &lt;a href=&quot;https://www.reddit.com/user/IgorVozMkUA&quot;&gt; /u/IgorVozMkUA &lt;/a&gt; &amp;#32; to &amp;#32; &lt;a href=&quot;https://www.reddit.com/r/ukraine/&quot;&gt; r/ukraine &lt;/a&gt; &lt;br/&gt; &lt;span&gt;&lt;a href=&quot;https://v.redd.it/2x4p30nis2oa1&quot;&gt;[link]&lt;/a&gt;&lt;/span&gt; &amp;#32; &lt;span&gt;&lt;a href=&quot;https://www.reddit.com/r/ukraine/comments/11spul1/the_us_department_of_defense_released_footage_of/&quot;&gt;[komentáře]&lt;/a&gt;&lt;/span&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</content>
	<id>t3_11spul1</id>
	<media:thumbnail url="https://external-preview.redd.it/gIH_CDiZfgrYsFyO1GR_dcCHpq-y90MRwAbSnu0cIT8.png?width=640&amp;crop=smart&amp;auto=webp&amp;s=36c121ae80192516cf4b339f5031558791ff6169"/>
	<link href="https://www.reddit.com/r/ukraine/comments/11spul1/the_us_department_of_defense_released_footage_of/"/>
	<updated>2023-03-16T10:09:44+00:00</updated>
	<published>2023-03-16T10:09:44+00:00</published>
	<title>The US Department of Defense released footage of a Russian Su-27 colliding with an American MQ-9 Reaper UAV over the Black Sea</title>
</entry>

Which basically creates the following enclosure:

new Enclosure(
  restrictions: [
    new Restriction(relationship: "allow", type: null, value: "default"),
  ],
  thumbnails: [
    "https://external-preview.redd.it/gIH_CDiZfgrYsFyO1GR_dcCHpq-y90MRwAbSnu0cIT8.png?width=640&crop=smart&auto=webp&s=36c121ae80192516cf4b339f5031558791ff6169"
  ],
)

This trips up the embed() method since it expects type is provided or can be guessed:

$mime = explode('/', $type, 2);

But that is not true, I am correcting the return type of get_real_type() method in #797.

And even if we fix that, the method still expects a link exists:

$embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>';

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

No branches or pull requests

4 participants