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

Make PHP error handler operate in a stack #402

Merged
merged 2 commits into from
Dec 7, 2016

Conversation

weierophinney
Copy link
Member

Per #400, when we register a new error handler to swallow deprecation notices in Application::__invoke(), if any global error handlers were registered previously, they now disappear.

This patch adds a test covering that scenario, and updates the Application class as follows:

  • The set_error_handler() call in Application::__invoke() has been replaced with a call to a new method, swallowDeprecationNotices().
  • swallowDeprecationNotices() now captures the return value of calling set_error_handler(); if that value is non-empty, it creates a new error handler closing over its own error handler and the previous which invokes the previous if our own returns false.

This serves as an alternate solution to #401.

Per zendframework#400, when we register a new error handler to swallow deprecation
notices in `Application::__invoke()`, if any global error handlers were
registered previously, they now disappear.

This patch adds a test covering that scenario, and updates the
`Application` class as follows:

- The `set_error_handler()` call in `Application::__invoke()` has been
  replaced with a call to a new method, `swallowDeprecationNotices()`.
- `swallowDeprecationNotices()` now captures the return value of calling
  `set_error_handler()`; if that value is non-empty, it creates a new
  error handler closing over its own error handler and the previous
  which invokes the previous if our own returns false.
@weierophinney weierophinney added this to the 1.0.4 milestone Dec 7, 2016
- added `@todo` annotation to `swallowDeprecationNotices()` to ensure we
  remove it for 2.0.0.
- updated `@todo` annotation for `__invoke()` to reference
  `swallowDeprecationNotices()` invocation
- tightened up logic in `swallowDeprecationNotices()` to remove
  temporary variables.
@weierophinney weierophinney merged commit 4578f4b into zendframework:master Dec 7, 2016
weierophinney added a commit that referenced this pull request Dec 7, 2016
weierophinney added a commit that referenced this pull request Dec 7, 2016
weierophinney added a commit that referenced this pull request Dec 7, 2016
Forward port #402

Conflicts:
	CHANGELOG.md
	src/Application.php
@weierophinney weierophinney deleted the hotfix/400 branch December 7, 2016 18:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant