Skip to content

Fix infinite recursion in Core::call() on same-domain 302 redirect#406

Merged
mesilov merged 2 commits intov3-devfrom
bugfix/372-fix-infinite-recursion-in-call
Mar 26, 2026
Merged

Fix infinite recursion in Core::call() on same-domain 302 redirect#406
mesilov merged 2 commits intov3-devfrom
bugfix/372-fix-infinite-recursion-in-call

Conversation

@mesilov
Copy link
Copy Markdown
Collaborator

@mesilov mesilov commented Mar 26, 2026

Q A
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #372
License MIT

When Core::call() received a 302 STATUS_FOUND response, it extracted only scheme://host
from the Location header and recursively called itself with the new domain.

On self-hosted portals with an expired license, Bitrix24 redirects every request to
/bitrix/coupon_activation.php — same host, different path. The extracted domain was identical
to the old domain, changeDomainUrl() silently accepted it, and the method called itself forever,
producing a PHP fatal stack overflow.

Fix:
After computing portalNewDomainUrlHost, compare it to portalOldDomainUrlHost.
If they are equal this is NOT a legitimate domain-migration — throw PortalUnavailableException
with the full Location URL in the message so callers and logs have the context they need.

New exception: Bitrix24\SDK\Core\Exceptions\PortalUnavailableException extends BaseException

Usage (caller side):

try {
    $response = $core->call('app.info');
} catch (PortalUnavailableException $e) {
    // Portal is unavailable (expired license, maintenance, etc.)
    // $e->getMessage() contains the redirect location for debugging
}

Test plan

  • make lint-cs-fixer — passed
  • make lint-rector — passed (auto-fix: unused catch variable removed)
  • make lint-phpstan — passed
  • make lint-deptrac — passed (0 violations)
  • make test-unit — passed (663 tests, 1138 assertions)

Closes #372

🤖 Generated with Claude Code

mesilov and others added 2 commits March 26, 2026 17:41
…domain (#372)

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mesilov mesilov added this to the 3.1.0 milestone Mar 26, 2026
@mesilov mesilov self-assigned this Mar 26, 2026
@mesilov mesilov linked an issue Mar 26, 2026 that may be closed by this pull request
@mesilov mesilov merged commit 6307d1a into v3-dev Mar 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug in SDK]: Infinite recursion in call()

1 participant