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

[BUG] must be of type string, bool given in /framework/simplepie/src/Locator.php:330 #802

Closed
thE-iNviNciblE opened this issue Mar 17, 2023 · 2 comments · Fixed by #803
Closed
Assignees
Labels

Comments

@thE-iNviNciblE
Copy link

thE-iNviNciblE commented Mar 17, 2023

IMPORTANT: If you are posting code or output, please make sure you wrap it with fenced code blocks so that it is readable.

Description

PHP Fatal error: Uncaught TypeError: strtolower(): Argument #1 ($string) must be of type string, bool given in /var/www/vhosts/xxx/framework/simplepie/src/Locator.php:330

if (in_array(strtolower(strrchr($value, '.')), ['.rss', '.rdf', '.atom', '.xml'])) {

edit to

            $str = strrchr($value, '.');
            if(is_string($str)) {

                if (in_array(strtolower($str), ['.rss', '.rdf', '.atom', '.xml'])) {

Steps to Reproduce

Steps to reproduce the behavior:

it's a cron.php which is running, can't excatly say which is the $value but

Expected Behavior

A clear and concise description of what you expected to happen.

Actual Behavior

A clear and concise description of what you expected to happen.

strrchr(string $haystack, string $needle): string|false

it's returning "false" in case of an error not a string and strtolower($str) wants that is a string.

Possible Solutions


 $str = strrchr($value, '.');
            if(is_string($str)) {

                if (in_array(strtolower($str), ['.rss', '.rdf', '.atom', '.xml'])) {
                    $this->checked_feeds++;
    
                    $headers = [
                        'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
                    ];
                    $feed = $this->registry->create(File::class, [$value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options]);
                    if ($feed->success && ($feed->method & \SimplePie\SimplePie::FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) {
                        return [$feed];
                    } else {
                        unset($array[$key]);
                    }
                }
            }

Environment

Normal System Debian 10 with PHP 8.2

@jtojnar
Copy link
Contributor

jtojnar commented Mar 17, 2023

Thanks for reporting, opened #803

@thE-iNviNciblE
Copy link
Author

no problem.

for most of rss-sources it works without problems.

thx for superfast patching =D

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

Successfully merging a pull request may close this issue.

3 participants