Skip to content

IBX-12127: Fixed valid URLs being marked as invalid by ibexa:check-urls - #809

Open
tbialcz wants to merge 2 commits into
4.6from
ibx-12127-check-urls-head-get-fallback
Open

IBX-12127: Fixed valid URLs being marked as invalid by ibexa:check-urls#809
tbialcz wants to merge 2 commits into
4.6from
ibx-12127-check-urls-head-get-fallback

Conversation

@tbialcz

@tbialcz tbialcz commented Aug 20, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12127

Description:

ibexa:check-urls checked links with a bare cURL HEAD request without any headers (since the original implementation, EZP-28505). WAFs like Cloudflare block such requests, so working links were marked as invalid.

Now the request sends browser-like User-Agent/Accept headers, and a failed HEAD is retried once with GET. New optional handler options: method, fallback_to_get, user_agent, headers.

Also fixed in the same code: the https handler was reading http options, and the curl_multi loop could skip trailing URLs.

For QA:

  1. Add RichText links to https://www.tiendanimal.es/ and to a URL that rejects HEAD requests (e.g. a local php -S server returning 403 for HEAD), publish.
  2. Run php bin/console ibexa:check-urls — both links are Valid in Link manager (before the fix: Invalid).
  3. Add a genuinely broken link (404 or dead host), re-run — it is marked Invalid.

Documentation:

Yes — document the new url_checker.handlers.http|https options: method, fallback_to_get, user_agent, headers.

@tbialcz tbialcz added Bug Something isn't working Doc needed The changes require some documentation labels Aug 20, 2026
@tbialcz
tbialcz force-pushed the ibx-12127-check-urls-head-get-fallback branch from 5b182e3 to 9149e7e Compare August 20, 2026 06:23
@tbialcz
tbialcz force-pushed the ibx-12127-check-urls-head-get-fallback branch from 9149e7e to 3fc0d75 Compare August 20, 2026 06:28
@tbialcz
tbialcz requested a review from a team August 20, 2026 07:34

@alongosz alongosz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My general remark - if we're revamping this, can we use something more modern than reinvented-wheel-curl?
Like Symfony HTTP client? Or it doesn't make sense here or it's too much work? Just curious.

Remarks to the current solution, which is still a lot of great work 💪

ignore_certificate: false
method: HEAD
fallback_to_get: true
user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be something more reflecting reality?

Suggested change
user_agent: 'Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0'
user_agent: 'Ibexa DXP URL checker'

Or does Cloudfare treat it as suspicious and it's on purpose like that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On purpose — some sites block non-browser UAs (e.g. zillow.com returns 403 instead of 200). The user_agent can be changed if needed.

Comment thread src/bundle/Core/URLChecker/Handler/HTTPHandler.php Outdated
Comment thread src/bundle/Core/URLChecker/Handler/HTTPHandler.php
Comment thread src/bundle/Core/URLChecker/Handler/HTTPHandler.php Outdated
Comment thread tests/bundle/Core/URLChecker/Handler/HTTPHandlerTest.php Outdated
Comment thread tests/bundle/Core/URLChecker/Handler/HTTPHandlerTest.php Outdated
Comment thread phpstan-baseline-gte-8.0.neon Outdated
@tbialcz

tbialcz commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

My general remark - if we're revamping this, can we use something more modern than reinvented-wheel-curl? Like Symfony HTTP client? Or it doesn't make sense here or it's too much work? Just curious.

Remarks to the current solution, which is still a lot of great work 💪

Thanks! Agreed, HttpClient would be cleaner, and it’s already a dependency. I kept this PR small as a 4.6 bugfix. I’d do the HttpClient rewrite in a follow-up ticket.

@tbialcz
tbialcz requested a review from alongosz August 27, 2026 07:40
@tbialcz
tbialcz force-pushed the ibx-12127-check-urls-head-get-fallback branch from 20ed76f to 28f8d47 Compare August 27, 2026 08:06
private const METHOD_HEAD = 'HEAD';
private const METHOD_GET = 'GET';

private const DEFAULT_USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be configured in yaml file, yet we have const here? or those are two different things? cant we at least call const syntax in yaml file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. i removed the duplication

@tbialcz
tbialcz force-pushed the ibx-12127-check-urls-head-get-fallback branch from 28f8d47 to 57f5a79 Compare August 27, 2026 08:42
@tbialcz
tbialcz requested a review from ViniTou August 27, 2026 08:43
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Doc needed The changes require some documentation Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants