- Issue created by @jboyce
- ๐บ๐ธUnited States lisastreeter
I also just got this error. Loading a page with an embedded View form.
Looks like it could be fixed by checking whether `$url` variable set on line 33 of `LoginDestination.php` is an instance of `\Drupal\Core\Url`. If it's not, just `return $build`.
- ๐ฎ๐ณIndia abhishek_virasat
abhishek_gupta1 โ made their first commit to this issueโs fork.
- ๐บ๐ธUnited States tbenice
Here is a patch that works for me based on the suggestion in https://www.drupal.org/project/login_destination/issues/3529641#comment-... ๐ Call to a member function isRouted() on string Active
- ๐ฎ๐ณIndia jaydev bhatt Pune, Maharashtra
jaydev bhatt โ made their first commit to this issueโs fork.
- Merge request !25Issue-3529641: Fix fatal error when preRender processes string URLs. โ (Open) created by jaydev bhatt
- ๐ฎ๐ณIndia jaydev bhatt Pune, Maharashtra
Steps to Reproduce
1. Create a view in Drupal with a REST export display (e.g., `/app/directory/xml`)
2. Navigate to the view edit page: Structure > Views > [Your View] > Edit
3. The fatal error "Call to a member function isRouted() on string" occurs in `LoginDestination::preRender()` line 34Root Cause
The `preRender()` callback assumes `$build['#url']` is always a `\Drupal\Core\Url` object, but in certain contexts like REST export views, it can be a string. When the code attempts to call `$url->isRouted()` on a string, it triggers the fatal error.
Solution
We fixed a fatal error in the login_destination module where the preRender() callback was trying to call isRouted() on string URLs instead of just Url objects. Added a type check with instanceof Url to ensure we only process actual Url objects, preventing the "Call to a member function isRouted() on string" error while maintaining functionality for login/logout links.
Moving this to NR for further verifications.