Prevent an "Undefined array key" error#44
Conversation
We're seeing the follwowing in logs when users are edited:
```
PHP Warning: Undefined array key "dxwextras_deactivated" in phar:///usr/local/share/php/dxw-extras/vendor.phar/vendor/dxw/iguana/src/Value/ArrayBase.php on line 31
```
This is being triggered by the following call in dxw-extras:
```
if ($this->post['dxwextras_deactivated'] === 'yes') {
```
https://github.com/dxw/dxw-extras/blob/a116d941f645e0c08c68dfdc3242e5daa431d89a/src/DeactivatedUsers/UpdateOption.php#L36
Using `isset()` will still trigger the warning.
|
I'm not sure if this is something we want to fix here. I'd expect the behaviour of Also, how would you distinguish between when |
|
I think I'd want
If if (isset($this->post['dxwextras_deactivated']) && $this->post['dxwextras_deactivated'] === 'yes') { |
|
Should |
|
Also, I guess #42 can be addressed now. |
|
I don't understand, according to https://www.php.net/manual/en/arrayaccess.offsetexists.php, final public function offsetExists($offset): bool
{
return isset($this->value[$offset]);
}So why doesn't if (issset($this->post['dxwextras_deactivated']) && $this->post['dxwextras_deactivated'] === 'yes') {work as expected? |
We're seeing the follwowing in logs when users are edited:
This is being triggered by the following call in dxw-extras:
https://github.com/dxw/dxw-extras/blob/a116d941f645e0c08c68dfdc3242e5daa431d89a/src/DeactivatedUsers/UpdateOption.php#L36
Using
isset()will still trigger the warning.