I'm starting to get familiar with Magento 2.
I installed v2.3.1 in an Nginx/PHP-fpm and got it working, including the sample data.
Then I followed everything in the tutorial at https://devdocs.magento.com/guides/v2.3/ext-best-practices/extension-coding/example-module-adminpage.html
The menu shows up ok, but when I click the link generated in the menu:
adminlink/exampleadminnewpage/helloworld/index/key/(removed-key)/
I get the Too many redirects and tries to redirect to:
adminlink/exampleadminnewpage/helloworld/index/key/(removed-key)/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/adminhtml/dashboard
All other pages, frontend and backend, work fine.
EDIT:
I'm trying to debug this error and found that the the rewrite/redirect is not from Nginx it self.
In app/code/Magento/Backend/App/Request/BackendValidator.php
, function validate
(called from lib/internal/Magento/Framework/App/FrontController.php
) when I try to access the new module the $action
is instance of Magento\Framework\App\Action\Forward\Interceptor
, which fails the test for not being instance of AbstractAction
and start the redirect. But other pages (for example trying to access Content -> Pages) are instance of Magento\Cms\Controller\Adminhtml\Page\Index\Interceptor
that pass that test.
EDIT 2:
In lib/internal/Magento/Framework/App/FrontController.php
function processRequest
the $this->requestValidator->validate($request, $actionInstance)
throws an Exception "Invalid request received" for my custom module. And Null in other pages from Magento.
In lib/internal/Magento/Framework/App/Router/Base.php
function matchAction
$modules finds the correct module MyCompany_ExampleAdminNewPage
and the cms page finds the Magento_Cms
.
Then i found that in the same matchAction
, magento didn't retrieve any actionList for the custom module. Which led me to conclude something should be wrong wih my app/code/MyCompany/ExampleAdminNewPage/Controller/Adminhtml/HelloWorld/Index.php
. So i deleted and created a new one, checked for correct file permissions and ownership, and it solved my problem. Could also be the file encoding messing something up (wouldn't be the first, and won't be the last time this will happen).