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

Option to disable directory index routing #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

grantlucas
Copy link
Contributor

In some frameworks, passing index.php, or the directory index back from the router would cause "/" to fail to load a page since it's passing back the output of the directory index.

Some frameworks, like Zend Framework 1 don't behave properly when index.php is passed back.

This adds false detection to directoryIndex configuration parameter. The values passed to the router is noDirectoryIndex since off was getting converted to an empty string.

@grantlucas
Copy link
Contributor Author

Any word on the possibility of incorporating some of the open Pull Requests? Thanks. 😄

@cooperaj
Copy link

This issue is affecting me when using Bolt CMS (a Silex application) disabling the routing in the code allows my '/' tests to pass. Leaving it in gives require_once errors on the vendor/autoload.php file.

@tiger-seo
Copy link
Owner

maybe instead of new parameter would be better to add a special case for directoryIndex, e.g. in codeception.yml: directoryIndex: false or directoryIndex: ~ ?

@cooperaj
Copy link

@tiger-seo This makes sense. I'd be happy with that as an option.

@grantlucas
Copy link
Contributor Author

@tiger-seo I tried messing with it a bit to update this PR to match your recommendation but am having an issue.

  • Whenever ~ is used as a value, it "should" be considered nil by Yaml standards but it ends up as false
  • If I pass in false for directoryIndex, the resulting config value is an empty string.

Because of this using ~ and just not having the config value in the file both result in codecept.directory_index becoming false.

A way around this would be to use false as the codeception.yml value and then check for an empty string in Router.php.

Any idea what's going on here? Is Codeception converting the configuration data?

Thanks.

@tiger-seo
Copy link
Owner

A way around this would be to use false as the codeception.yml value and then check for an empty string in Router.php.

yes, first of all it should be readable and understandable for users
so, in codeception.yml it is good to have it like directoryIndex: false, but then pass it to php.exe like -dcodecept.directory_index=off and check if ini_get(codecept.directory_index) === 'off' then we don't use directoryIndex

@grantlucas
Copy link
Contributor Author

👍 sounds good to me. Will work on that patch

@tiger-seo
Copy link
Owner

fantastic 👍 thanks

@grantlucas grantlucas force-pushed the disableDirectoryIndexRoutingOption branch from 375ef0b to 1f5216b Compare April 23, 2015 14:14
The `directoryIndex` can now receive `false` to NOT pass back a
directory index from the router.

The key passed to the router is `noDirectoryIndex` since `off` was
getting converted to an empty string.
@grantlucas grantlucas force-pushed the disableDirectoryIndexRoutingOption branch from 1f5216b to 66eb0b4 Compare April 23, 2015 14:16
@grantlucas
Copy link
Contributor Author

@tiger-seo This PR has been updated to match your recommendation. Only issue I ran into was that off was getting converted to an empty string when passing it through -dcodecept.directory_index. I used noDirectoryIndex instead and that seems to work.

Let me know if this works for you or if you'd like any changes.

@tiger-seo tiger-seo force-pushed the master branch 3 times, most recently from 794932d to e0509bb Compare December 20, 2016 01:05
@tiger-seo tiger-seo force-pushed the master branch 3 times, most recently from ae1ad2e to a79b3e4 Compare December 3, 2017 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants