flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.35k stars 834 forks source link

Installing Flarum from /index.php causes wrong base url #1861

Closed clarkwinkelmann closed 5 years ago

clarkwinkelmann commented 5 years ago

Bug Report

Current Behavior Installing Flarum from /index.php works but causes an invalid url to be used in config.php, thus preventing access to the forum after install.

Steps to Reproduce

  1. Install Flarum according to https://flarum.org/docs/install.html
  2. At the step "navigate to your forum in a web browser", append /index.php at the end
  3. Follow the web installation
  4. When install is finished, you are redirected to /index.php which shows "Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error" Accessing / shows the same error
  5. Assets are loaded from /index.php/assets/forum-575aab17.css which causes 404 errors
  6. You can observe /index.php being used in config.php

Expected Behavior The installation page should either not be available at /index.php, or remove index.php from the install url automatically.

Screenshots Probably not needed, let me know otherwise.

Environment

Output of "php flarum info", run this in terminal in your Flarum directory.

It's a blank install.

When enabling debug mode, the assets show the following 500 error:

Flarum\Http\Exception\RouteNotFoundException: /assets/forum-575aab17.css in file /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php on line 60
Stack trace:
  1. Flarum\Http\Exception\RouteNotFoundException->() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/DispatchRoute.php:60
  2. Flarum\Http\Middleware\DispatchRoute->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  3. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/ShareErrorsFromSession.php:58
  4. Flarum\Http\Middleware\ShareErrorsFromSession->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  5. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/SetLocale.php:51
  6. Flarum\Http\Middleware\SetLocale->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  7. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php:25
  8. Flarum\Http\Middleware\CheckCsrfToken->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
  9. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php:34
 10. Flarum\Http\Middleware\AuthenticateWithSession->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 11. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php:52
 12. Flarum\Http\Middleware\RememberFromCookie->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 13. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/StartSession.php:62
 14. Flarum\Http\Middleware\StartSession->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 15. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/CollectGarbage.php:48
 16. Flarum\Http\Middleware\CollectGarbage->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 17. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php:29
 18. Flarum\Http\Middleware\ParseJsonBody->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 19. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Middleware/HandleErrorsWithWhoops.php:43
 20. Flarum\Http\Middleware\HandleErrorsWithWhoops->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 21. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:83
 22. Zend\Stratigility\MiddlewarePipe->process() /home/clark/Projects/flarum-install/vendor/middlewares/request-handler/src/RequestHandler.php:84
 23. Middlewares\RequestHandler->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 24. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/middlewares/base-path-router/src/BasePathRouter.php:97
 25. Middlewares\BasePathRouter->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 26. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Middleware/OriginalMessages.php:41
 27. Zend\Stratigility\Middleware\OriginalMessages->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 28. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/middlewares/base-path/src/BasePath.php:53
 29. Middlewares\BasePath->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/Next.php:60
 30. Zend\Stratigility\Next->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:83
 31. Zend\Stratigility\MiddlewarePipe->process() /home/clark/Projects/flarum-install/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php:72
 32. Zend\Stratigility\MiddlewarePipe->handle() /home/clark/Projects/flarum-install/vendor/zendframework/zend-httphandlerrunner/src/RequestHandlerRunner.php:95
 33. Zend\HttpHandlerRunner\RequestHandlerRunner->run() /home/clark/Projects/flarum-install/vendor/flarum/core/src/Http/Server.php:46
 34. Flarum\Http\Server->listen() /home/clark/Projects/flarum-install/public/index.php:22

Possible Solution Same as expected behavior.

Additional Context Multiple people seem to have hit issues that could be related to this. Most recently https://discuss.flarum.org/d/21143-fatal-error-please-help but I'm not 100% sure this is the same issue. Other people had managed to get an index.php in their config.php and this is probably one way to inadvertently do it.

franzliedke commented 5 years ago

Nice catch. Yes, the script name (if present) should be removed from the base URL.

If anybody wants to send a PR, these are the relevant lines:

relax4o commented 5 years ago

The installation process where the base url is involved causes even more problems.

I've made some changes and when I test all cases properly, I can create a PR.

The issues I've found:

I can think of couple of solutions when the console installer is used:

Excuse me if the issues I've found sounds like they need to be in a different issue thread. I am kind of new to open source contribution.