Skip to content

check if functions are disabled if failed to connect/listen - #97

Closed
MasterOdin wants to merge 1 commit into
Textalk:masterfrom
MasterOdin:master
Closed

check if functions are disabled if failed to connect/listen#97
MasterOdin wants to merge 1 commit into
Textalk:masterfrom
MasterOdin:master

Conversation

@MasterOdin

@MasterOdin MasterOdin commented Aug 18, 2020

Copy link
Copy Markdown

Closes #93

Currently, if a user attempts to use these functions while they are disabled via php.ini, they will receive a message like Could not open socket to "127.0.0.1:41983": (). This has can cause confusion to someone who might not know the function is disabled (or that you can disable functions), and just lead to spinning their wheels on trying to debug.

This patch changes it such that if $errstr is null, it will check if the function is disabled and if so, will update the $errstr variable to something more meaningful to be displayed to the user and logged. The $errno variable remains null. In the above example, the user will now receive the following error message: Could not open socket to "127.0.0.1:41983": stream_socket_client function is disabled ().

Given that this code relies on the function not existing, I'm not sure how I would include tests for this behavior. As such, I've ignored the lines in question for consideration of code coverage.

@coveralls

coveralls commented Aug 18, 2020

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 1507be3 on MasterOdin:master into ab02241 on Textalk:master.

@sirn-se

sirn-se commented Dec 12, 2020

Copy link
Copy Markdown
Contributor

After some testing, I've found that the sustainable solution to this problem is to wrap sensitive calls in an error handler. This approach is more generic, catching all errors and not just disabled functions.

Implemented in upcoming v1.5: #126
Closing this PR.

@sirn-se sirn-se closed this Dec 12, 2020
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.

Verify that stream_socket_client function is available / enabled in client

3 participants