Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Incorrect CP console request URLs #15374

Closed
bencroker opened this issue Jul 17, 2024 · 7 comments
Closed

[5.x]: Incorrect CP console request URLs #15374

bencroker opened this issue Jul 17, 2024 · 7 comments
Labels

Comments

@bencroker
Copy link
Contributor

bencroker commented Jul 17, 2024

What happened?

The commit 8e69802 addressed constructing URLs for console requests if the @web alias wasn’t explicitly defined. Should a similar change not also be applied to CP console requests to ensure that CP URLs are output as absolute URLs?

Steps to reproduce

  1. In a custom module, create a console command that outputs an entry’s CP edit URL.
die(\craft\helpers\UrlHelper::cpUrl());

Expected behavior

The output should be https://projectpath.ddev.site/admin.

Actual behavior

The output is /admin.

Tested in Craft 5 but this likely affects Craft 4 as well.

Craft CMS version

5.2.7

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@bencroker bencroker added the bug label Jul 17, 2024
@bencroker bencroker changed the title [5.x]: [5.x]: Incorrect CP console request URLs Jul 17, 2024
@brandonkelly
Copy link
Member

We’ll discuss!

@brandonkelly
Copy link
Member

Decided to make this change for 4.11 and 5.3 (#15403). It’s not as urgently needed as the actionUrl() change was, thanks to the baseCpUrl config setting.

@bencroker
Copy link
Contributor Author

Lovely, thanks!

@white-lukas
Copy link

@brandonkelly we are now getting a typeError on the fallbackBaseUrl()

craft\helpers\UrlHelper::fallbackBaseUrl(): Argument #1 ($request) must be of type ?craft\web\Request, craft\console\Request given, 
called in /var/www/html/vendor/craftcms/cms/src/helpers/UrlHelper.php on line 646

@brandonkelly
Copy link
Member

@white-lukas Thanks for letting me know. Fixed via a94c6cd.

@sajjanstha
Copy link

@brandonkelly Did you push the fix for above typeError on the fallbackBaseUrl() for craft 4? I am still facing the below error when I upgraded my craft cms to 4.11.0.2.
Exception 'TypeError' with message 'craft\helpers\UrlHelper::fallbackBaseUrl(): Argument #1 ($request) must be of type ?craft\web\Request, craft\console\Request given, called in /var/www/html/app/vendor/craftcms/cms/src/helpers/UrlHelper.php on line 655'

@brandonkelly
Copy link
Member

@sajjanstha Doh, forgot to apply the fix to Craft 4. Just tagged 4.11.1 with the same fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants