Skip to content

Conversation

@leedxw
Copy link

@leedxw leedxw commented Aug 15, 2025

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.

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.
@RobjS
Copy link
Contributor

RobjS commented Aug 15, 2025

I'm not sure if this is something we want to fix here. I'd expect the behaviour of Dxw\Iguana\Value\Post::OffsetGet('key') to match the behaviour of $_POST['key'] as closely as possible, which is what it does at the moment.

Also, how would you distinguish between when Dxw\Iguana\Value\Post::OffsetGet('key') is returning false because the key exists and is set to false, and when it's returning false because the key does not exist?

@leedxw
Copy link
Author

leedxw commented Aug 15, 2025

I think I'd want isset($this->post['dxwextras_deactivated']) to return false without generating a PHP warning.

isset($_POST['key']) won't generate a warning.

If isset() worked, I'd update the call to

if (isset($this->post['dxwextras_deactivated']) && $this->post['dxwextras_deactivated'] === 'yes') {

@leedxw
Copy link
Author

leedxw commented Aug 15, 2025

Should return false be exit?

@leedxw
Copy link
Author

leedxw commented Aug 15, 2025

Also, I guess #42 can be addressed now.

@RobjS
Copy link
Contributor

RobjS commented Aug 15, 2025

I don't understand, according to https://www.php.net/manual/en/arrayaccess.offsetexists.php, isset($this->post['key']) should call this, from ArrayBase:

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?

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.

3 participants