Skip to content

Promote warnings to Error in SNMP extension #6124

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

Merged
merged 1 commit into from
Sep 15, 2020

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Sep 13, 2020

No description provided.

@Girgias Girgias force-pushed the snmp-warning-to-error branch 4 times, most recently from 982b362 to dcc0b41 Compare September 13, 2020 03:11
ext/snmp/snmp.c Outdated
} else {
php_error_docref(NULL, E_WARNING, "max_oids should be positive integer or NULL, got " ZEND_LONG_FMT, lval);
if (lval <= 0) {
zend_value_error("max_oids must be greater than 0 or NULL");
Copy link
Member

@kocsismate kocsismate Sep 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an existing function instead of zval_get_long() which behaves more consistently with usual ZPP rules? E.g. won't return 0 or 1 in case of an array new_zval, depending on if it is empty or not. :D

otherwise, I would say something like Property SNMP::$max_oids must be greater than 0. AFAIR, null is neither mentioned explicitly in case of nullable parameters in similar situations (e.g. shm_attach()).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is, but NULL is handled explicitly above, and as this is a property hook I have no clue about a better approach for handling the type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay to me, but possibly lowercase null would be more common now?

@Girgias Girgias force-pushed the snmp-warning-to-error branch 2 times, most recently from 8760c06 to 745465a Compare September 13, 2020 15:01
ext/snmp/snmp.c Outdated
} else {
php_error_docref(NULL, E_WARNING, "max_oids should be positive integer or NULL, got " ZEND_LONG_FMT, lval);
if (lval <= 0) {
zend_value_error("max_oids must be greater than 0 or NULL");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay to me, but possibly lowercase null would be more common now?

@Girgias Girgias force-pushed the snmp-warning-to-error branch 2 times, most recently from 7831901 to 777a00f Compare September 15, 2020 00:17
try {
$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
var_dump($z);
var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again, some of these var_dumps should be outside the try/catch.

@Girgias Girgias force-pushed the snmp-warning-to-error branch from 777a00f to 62c20c6 Compare September 15, 2020 11:08
@php-pulls php-pulls merged commit 62c20c6 into php:master Sep 15, 2020
@Girgias Girgias deleted the snmp-warning-to-error branch September 15, 2020 11:49
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.

4 participants