Page MenuHomeDevCentral

Move get_current_url() and co in OmniTools Request class
ClosedPublic

Authored by dereckson on Nov 11 2025, 18:13.
Tags
None
Referenced Files
F25497516: D3881.diff
Wed, Apr 15, 19:09
Unknown Object (File)
Thu, Apr 9, 05:25
Unknown Object (File)
Thu, Apr 9, 04:42
Unknown Object (File)
Sat, Apr 4, 22:41
Unknown Object (File)
Sun, Mar 29, 23:36
Unknown Object (File)
Sat, Mar 28, 13:27
Unknown Object (File)
Fri, Mar 27, 14:02
Unknown Object (File)
Wed, Mar 25, 08:39
Subscribers
None

Details

Summary

Those functions lived in Espace Win and Zed code for a very long time
and allow to get the current URL or to build an URL to create a link.

[ Base URL, with or without / ]

Small fixes have been added to allow to append a trailing slash to base URL:
the base URL can so be /subdir or /subdir/

That slash is respected for canonical URL, and ignored for /subdir/any/thing

Test Plan

This code has been battle-tested with several sites using:

  • direct .php access in the URL
  • Apache + mod_rewrite
  • nginx try_files directive

Unit tests have been added to allow leniency on the base URL trailing slash.

Diff Detail

Repository
rKERUALD Keruald libraries development repository
Lint
Lint Passed
Unit
Test Failures
Branch
request-current-url
Build Status
Buildable 6610
Build 6894: arc lint + arc unit

Event Timeline

dereckson created this revision.
dereckson edited the test plan for this revision. (Show Details)

Unit tests still to commit

Comprehensive unit tests. Fixes to allow to add a trailing slash to base URL.

Tests and assertions: +22 (718 -> 740, 2069 -> 2091)

Tests are marked broken because arcanist seems to ignore the backupGlobals="true":

$ phpunit omnitools
Switching to Composer phpunit:
PHPUnit 12.5-dev by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.19
Configuration: /datacube/dereckson/dev/nasqueron/keruald/keruald/phpunit.xml

...............................................................  63 / 740 (  8%)
............................................................... 126 / 740 ( 17%)
............................................................... 189 / 740 ( 25%)
............................................................... 252 / 740 ( 34%)
............................................................... 315 / 740 ( 42%)
............................................................... 378 / 740 ( 51%)
............................................................... 441 / 740 ( 59%)
............................................................... 504 / 740 ( 68%)
............................................................... 567 / 740 ( 76%)
............................................................... 630 / 740 ( 85%)
............................................................... 693 / 740 ( 93%)
...............................................                 740 / 740 (100%)

Time: 00:00.650, Memory: 10.00 MB

OK (740 tests, 2091 assertions)
dereckson retitled this revision from WIP: move get_current_url() and co in OmniTools Request class to Move get_current_url() and co in OmniTools Request class.Wed, Apr 15, 16:55
dereckson edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Wed, Apr 15, 19:24