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

Changing the admin URL causes a 500 error on the default route #689

Open
DorsetDigital opened this issue Oct 16, 2018 · 13 comments
Open

Changing the admin URL causes a 500 error on the default route #689

DorsetDigital opened this issue Oct 16, 2018 · 13 comments

Comments

@DorsetDigital
Copy link

Tested on Silverstripe 4.1.1 and 4.2.1

When changing the admin route by adding the following YML (as per the docs):

---
Name: myadmin
After:
- '#adminroutes'
---
SilverStripe\Control\Director:
  rules:
    'admin': ''
    'cms': 'SilverStripe\Admin\AdminRootController'

The new URL becomes active and works correctly. The old URL (eg. example.com/admin) now throws a 500 error (below). I would expect it to return a 404.

Uncaught InvalidArgumentException: Missing spec class
GET /admin
Line 403 in /app/vendor/silverstripe/framework/src/Core/Injector/Injector.php

The full stack trace is attached.
admin_error_trace.txt

@robbieaverill
Copy link
Contributor

robbieaverill commented Oct 16, 2018

@DorsetDigital did you also set the AdminRootController.url_base config prop to cms? I realise it's documented as a fallback option, but I'm just curious

@DorsetDigital
Copy link
Author

I've just tested that now, and it doesn't seem to change the result.

@DorsetDigital
Copy link
Author

As an aside, I noticed that might be necessary for things like the subsites add-on.. I'll update the docs to reflect that as well.

@kinglozzer
Copy link
Member

Does 'admin': null work? I guess we need to make director ignore routes that are mapped to false-y values

@DorsetDigital
Copy link
Author

Changing to null doesn't work I'm afraid. In fact, you get an additional warning for your trouble:

[Warning] array_merge(): Argument #1 is not an array
GET /admin

Line 337 in /app/vendor/silverstripe/framework/src/Control/Director.php

@shot131
Copy link

shot131 commented Jan 10, 2019

admin url is hardcoded here. If i change default admin url, then /admin/graphql/types return 404 error.

@robbieaverill
Copy link
Contributor

@shot131 thanks for highlighting that. Would you mind raising that as a new issue on https://github.com/silverstripe/silverstripe-graphql?

@shot131
Copy link

shot131 commented Jan 10, 2019

@robbieaverill
Copy link
Contributor

Sorry, I only skim read your message. You're right, the two issues (JavaScript and YAML config) are both in this module, so fine to leave it here =) Thanks

@itspers
Copy link

itspers commented Feb 1, 2019

Hi!
Did anybody found working solution for graqhQL?
I had working config for a months with

'admin': 'SilverStripe\CMS\Controllers\RootURLController'
'backend': 'SilverStripe\Admin\AdminRootController'

Before 4.3 it was working fine, but starting from 4.3 Files page tries to reach 'admin/graphql', fails and crash :(

@kinglozzer
Copy link
Member

A workaround for now is to remove any 'admin': '' or 'admin': 'RootURLController' overrides from your config.yml and instead remove the default admin route in _config.php:

$rules = Config::inst()->get(Director::class, 'rules');
unset($rules['admin']);
Config::modify()->remove(Director::class, 'rules');
Config::modify()->set(Director::class, 'rules', $rules);

The problem is that when a request to admin/graphql/types is made, Director looks through the routes, sees 'admin': '' (which matches) and then stops. I think to fix this properly, we need to do at least one of the following:

  1. Make sure that the admin/graphql route is inserted in the correct place, so that Director checks that rule before any 'admin': '' rules. (This might already be possible with Before:/After:, which would make this a docs issue - I haven’t checked);
  2. Make Director ignore/skip over any routes which map to '' or null, or;
  3. Add a “remove”/“unset”/“replace” directive to our YAML so you can just remove the default admin route in YAML (there’s an issue open somewhere for this enhancement)

@michalkleiner
Copy link
Contributor

michalkleiner commented Mar 25, 2019

There's already a ticket for unsetting routes via yaml. Let me find it.

Related ticket that could benefit from the solution here - silverstripe/silverstripe-cms#2349

@michalkleiner
Copy link
Contributor

The suggested solution was to go with null values.

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

No branches or pull requests

7 participants