phpbb-seo / usu

Ultimate phpBB SEO Friendly URL extension
GNU General Public License v2.0
17 stars 12 forks source link

USU is not with PHP 8 #67

Open Aurelienazerty opened 1 year ago

Aurelienazerty commented 1 year ago

USU seems not compatible with PHP 8

In index I've got lot of :

[phpBB Debug] PHP Warning: in file [ROOT]/ext/phpbbseo/usu/core/traits/url.php on line 324: Undefined array key 1
[phpBB Debug] PHP Warning: in file [ROOT]/ext/phpbbseo/usu/core/traits/rewriter.php on line 161: Undefined array key "author"
[phpBB Debug] PHP Warning: in file [ROOT]/ext/phpbbseo/usu/core/traits/rewriter.php on line 330: Undefined array key "start"
[phpBB Debug] PHP Warning: in file [ROOT]/ext/phpbbseo/usu/core/traits/rewriter.php on line 241: Undefined array key "sr"

And going to topic make error :

General Error
INSECURE_REDIRECT

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/ext/phpbbseo/usu/core/traits/seo.php
LINE: 127
CALL: trigger_error()

FILE: [ROOT]/ext/phpbbseo/usu/core/core.php
LINE: 730
CALL: phpbbseo\usu\core\core->seo_redirect()

FILE: [ROOT]/ext/phpbbseo/usu/event/listener.php
LINE: 354
CALL: phpbbseo\usu\core\core->zero_dupe()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 214
CALL: phpbbseo\usu\event\listener->core_user_setup()

FILE: [ROOT]/vendor/symfony/event-dispatcher/EventDispatcher.php
LINE: 44
CALL: Symfony\Component\EventDispatcher\EventDispatcher->doDispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 62
CALL: Symfony\Component\EventDispatcher\EventDispatcher->dispatch()

FILE: [ROOT]/phpbb/event/dispatcher.php
LINE: 46
CALL: phpbb\event\dispatcher->dispatch()

FILE: [ROOT]/phpbb/user.php
LINE: 222
CALL: phpbb\event\dispatcher->trigger_event()

FILE: [ROOT]/viewtopic.php
LINE: 356
CALL: phpbb\user->setup()
meis2m commented 1 year ago

@Dark1z

zetrader commented 1 year ago

I don't have this with phpbb 3.3.10 and php 8.2.9, what do i have to do to see those errors?

Aurelienazerty commented 11 months ago

It's when you put "Activate the Zero duplicate" to yes.

Aurelienazerty commented 10 months ago

I put a var_dump to see what's appened on line 122 in seo.php

var_dump($url, $url_parts, $url_parts === false, empty($url_parts['scheme']), !in_array($url_parts['scheme'], $allowed_protocols));

It print :

string(47) "./../../forum/viewtopic.php?f=15&t=3196&start=0" array(2) { ["path"]=> string(27) "./../../forum/viewtopic.php" ["query"]=> string(19) "f=15&t=3196&start=0" } bool(false) bool(true) bool(true)

As you can see, the $url is relative, so there is no scheme, we go in the if :

if ($url_parts === false || empty($url_parts['scheme']) || !in_array($url_parts['scheme'], $allowed_protocols))
{
    send_status_line(400, 'Bad Request');

    trigger_error('INSECURE_REDIRECT', E_USER_ERROR);
}

I don't know why it came with php 8.x I didn't have this problem with php 7.4 and I didn't made any code change.