Why are errors being supressed?
In Jetpack_Client_Server we have a line suppressing error messages:
@list( $role, $hmac ) = explode( ':', $json->scope );
Any idea why we are doing this?
https://github.com/Automattic/jetpack/blob/master/class.jetpack-client-server.php#L202
Also https://github.com/Automattic/jetpack/blob/master/class.jetpack-client.php#L41
@list( $token_key, $secret ) = explode( '.', $token->secret );
with the second one, I'd wager that it's to make sure we're not inadvertently exposing secrets
@samhotchkiss is spot on, both cases are what looks like best practice when dealing with sensitive data.
Would it be better to verify the data before attempting to use it?
I.E:
if( $token->is_valid_secret() ) {
$parts = explode( '.', $token->secret );
if( count( $parts ) == 2 ) {
list( $token_key, $secret ) = $parts;
}
else {
// handle error here
}
}
It should never really be a best practice to suppress error messages. If you are doing so that probably means the data being used is not properly verified.
A discussion http://programmers.stackexchange.com/questions/219788/is-error-suppressing-bad-practice
On second thought I admit that you're right. It looks like the only thing that the operator suppresses in this case is a possible Undefined offset notice. I fail to see any possible way that the sensitive data could get echoed if the stfu operator was omitted.
On the other hand, this seems like a fairly legitimate use case for the @ because it wouldn't possibly hide any problem. It just makes the code look less bulky, wouldn't you agree?
I have spent hours chasing around bugs in WP core only to narrow it down to a line with an @ in it (There are a few in the media stuff). Removed that and I could see the issue and resolve it. Errors really never should be hidden, they should be dealt with.
Yes, I agree with you, but in this case it can only hide a notice which we check against immediately after the statement. Do you see a possibility that it will hide something else?