Commit c80e8b82 authored by Patrick Schmalstig's avatar Patrick Schmalstig
Browse files

Fixed MANTIS-6021 (Sitemap node only following redirects one level deep)

parent 3ec43948
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -369,3 +369,5 @@ _IP_FORWARDING_ENABLED=Try unsetting
_IP_FORWARDING_DISABLED=Try setting
_IP_FORWARDING_INSTALLING=After installing try setting
DB_META_CORRUPT_MISSING=The file “/data/db_meta.bin” is either missing or corrupt.

REDIRECT_LOOP=A redirect loop occurred, therefore the request was halted.
+10 −1
Original line number Diff line number Diff line
@@ -236,6 +236,8 @@ abstract class Hook_sitemap_base
     */
    protected function _request_page_details(string $page, string $zone, ?string $page_type = null)
    {
        static $redirect_count = 0;

        require_code('site');
        $details = _request_page($page, $zone, $page_type);
        if ($details !== false) {
@@ -244,7 +246,14 @@ abstract class Hook_sitemap_base
                    return false;
                }

                $details = _request_page($details[1]['r_to_page'], $details[1]['r_to_zone'], $page_type, null, true);
                // Prevent infinite redirect loops
                $redirect_count++;
                if ($redirect_count > 10) {
                    require_lang('critical_error');
                    warn_exit(do_lang_tempcode('REDIRECT_LOOP'), false, true); // Log it in case it is a software bug
                }

                $details = $this->_request_page_details($details[1]['r_to_page'], $details[1]['r_to_zone'], $page_type);
            }
        }
        return $details;