Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Ensure setting save_path considers save_handler #101

Merged

Conversation

weierophinney
Copy link
Member

The fix in #99, while correct, did not address setting the session.save_path for non-files save handlers when the save handler is set via setOption('save_handler', $value). The reason for this was due to the fact that setOption() delegates directly to setStorageOption() instead of the relevant class method; the changes in #99 make that method a no-op in the case of a save handler option.

What this patch does is two-fold:

  • It overrides setOption() and has it call setPhpSaveHandler() if save_handler is provided as the $option argument. It then returns on completion. Otherwise, it delegates to the parent.
  • It modifies setPhpSaveHandler() to extract the bulk of the logic to a new method, performSaveHandlerUpdate(). This new method now returns the save handler name to store. setPhpSaveHandler() then sets that name as the save_handler value in the $options property before returning.

I have added a test to verify this behavior based on an example provided in #98.

The fix in zendframework#99, while correct, did not address setting the session.save_path
for non-files save handlers when the save handler is set via
`setOption('save_handler', $value)`. The reason for this was due to the
fact that `setOption()` delegates directly to `setStorageOption()`
instead of the relevant class method; the changes in zendframework#99 make that
method a no-op in the case of a save handler option.

What this patch does is two-fold:

- It overrides `setOption()` and has it call `setPhpSaveHandler()` if
  `save_handler` is provided as the `$option` argument. It then returns
  on completion. Otherwise, it delegates to the parent.
- It modifies `setPhpSaveHandler()` to extract the bulk of the logic to
  a new method, `performSaveHandlerUpdate()`. This new method now
  returns the save handler _name_ to store. `setPhpSaveHandler()` then
  sets that name as the `save_handler` value in the `$options` property
  before returning.

I have added a test to verify this behavior based on an example provided
in zendframework#98.
PHPUnit 6.5+ updates to use php-mock-objects ^5.0. Unfortunately,
phpunit still typehints against interfaces defined in the v4 release,
causing breakage when using the invocation builder to setup your mock
expectations.
@weierophinney weierophinney force-pushed the hotfix/98-redis-path branch 4 times, most recently from 0d865fa to 8d044fe Compare December 1, 2017 17:16
6.0.13 has fixes necessary to work with PHP 7.2. Also sets that as the
minimum version PHP 7.2 will install when running the 7.2-lowest target.
@weierophinney weierophinney merged commit acff5d9 into zendframework:master Dec 1, 2017
weierophinney added a commit that referenced this pull request Dec 1, 2017
weierophinney added a commit that referenced this pull request Dec 1, 2017
weierophinney added a commit that referenced this pull request Dec 1, 2017
Forward port #101

Conflicts:
	CHANGELOG.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant