atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
440 stars 104 forks source link

Reintroduce App::$page as App::$urlBuildingIndexPage #2096

Closed abbadon1334 closed 10 months ago

abbadon1334 commented 10 months ago

BC break: remove App::getRequestUrl() protected method which was misleading alias for request URL path

abbadon1334 commented 10 months ago

some results from tests:

App::url test error case: standard (from: / and $useRequestUrl=0)
Failed asserting that two strings are identical.
Expected :'/index.php'
Actual   :'index.php'
App::url test error case: standard (from: /test/ and $useRequestUrl=0)
Failed asserting that two strings are identical.
Expected :'/test/index.php'
Actual   :'index.php'

thinking about the behaviour of url building in browser, writing index.php or /index.php is the same if the actual document.location = '/'

same if document.location='/test/ and url is without / calling index.php became in browser /test/index.php so why not build it directly in App::url returning the correct path and make it consistent with browser?

The same happens when useRequestUrl=true (the reference path is taken from request url):

App::url test error case: standard (from: / and $useRequestUrl=1)
Failed asserting that two strings are identical.
Expected :'/index.php'
Actual   :'/'

App::url test error case: standard (from: /test/ and $useRequestUrl=1)
Failed asserting that two strings are identical.
Expected :'/test/index.php'
Actual   :'/test/'

i have taken only the first test results but all the inconsistency comes from relative/absolute uri paths and when to added index.php

Let's discuss about this

this must be merged before #2095

abbadon1334 commented 10 months ago

@mvorisek what do you think about this? align the test results of App::url to old response or rework it to make it consistent? You can see them in the tests

mvorisek commented 10 months ago

@mvorisek what do you think about this? align the test results of App::url to old response or rework it to make it consistent? You can see them in the tests

definitely to be consistent/correct in a long term - is this how this PR is coded now?

abbadon1334 commented 10 months ago

@mvorisek what do you think about this? align the test results of App::url to old response or rework it to make it consistent? You can see them in the tests

definitely to be consistent/correct in a long term - is this how this PR is coded now?

Sorry, added now App::$urlBuildingPage with default value = index to get test results.

IMHO even minimal tests with the actual url method are tests against inconsistent results, for example :

1 - App::url('/') -> /index.php
2 - App::url('/test/') -> /test/

If in first case returns /index.php the second case must return /test/index.php

I think I can :

mvorisek commented 10 months ago

Remove the tests from this PR, leaving only the addiction of App::$urlBuildingPage

This is basically a few LoC with no BC-break. Separate PR is fine, but one PR together with the tests is fine as well. So I propose:

abbadon1334 commented 10 months ago

OK, so:

OK i do it later today and close without merging the other PR

abbadon1334 commented 10 months ago

OK, this add successful tests + App::$urlBuildingPage @mvorisek i think this can be merged

Even if App::$page was not used so much by the community, i think must be add a comment for the release, something like: [BC] App::$page changed to App::$urlBuildingPage

i go ahead with the other PR

mvorisek commented 10 months ago

Even if App::$page was not used so much by the community, i think must be add a comment for the release, something like: [BC] App::$page changed to App::$urlBuildingPage

updated title + marked #2065 as BC-break, release notes will be rebuilt once this PR is merged