# Bug#28151 Writing to Uninitialized Arrays

- Thread: https://externals.io/message/9560
- Original archive: https://news-web.php.net/php.internals/9560
- Started by Sara Golemon on 2004-04-26T05:18:04+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9560 — Sara Golemon — 2004-04-26T05:18:04+00:00

URL: https://externals.io/message/9560#9560

Here's what I think is the fix for 28151 (I have no strong feelings on
whether or not it belongs in the engine, but I am +1 on it personally).
Zend guys?


Index: Zend/zend_execute.c
===================================================================
RCS file: /repository/ZendEngine2/zend_execute.c,v
retrieving revision 1.643
diff -u -r1.643 zend_execute.c
--- Zend/zend_execute.c 15 Apr 2004 21:32:34 -0000      1.643
+++ Zend/zend_execute.c 26 Apr 2004 05:06:59 -0000
@@ -919,6 +919,7 @@
                                        SEPARATE_ZVAL(container_ptr);
                                        container = *container_ptr;
                                }
+                               zend_error(E_NOTICE, "Uninitialized array");
                                array_init(container);
                                break;
                }

---

## #9561 — Derick Rethans — 2004-04-26T06:49:45+00:00

URL: https://externals.io/message/9560#9561 · In reply to: #9560

> Here's what I think is the fix for 28151 (I have no strong feelings on
> whether or not it belongs in the engine, but I am +1 on it personally).
> Zend guys?

Did you run "make test" with this change? I have a feeling that'd break
other things...

Derick

---

## #9565 — Andi Gutmans — 2004-04-26T08:35:51+00:00

URL: https://externals.io/message/9560#9565 · In reply to: #9560

PHP has always allowed defining arrays on demand. This would break many 
scripts and I don't see any reason to force people to define variables as 
arrays, especially when these variables are undefined.

Andi

At 10:18 PM 4/25/2004 -0700, Sara Golemon wrote:
>Here's what I think is the fix for 28151 (I have no strong feelings on
>whether or not it belongs in the engine, but I am +1 on it personally).
>Zend guys?
>
>
>Index: Zend/zend_execute.c
>===================================================================
>RCS file: /repository/ZendEngine2/zend_execute.c,v
>retrieving revision 1.643
>diff -u -r1.643 zend_execute.c
>--- Zend/zend_execute.c 15 Apr 2004 21:32:34 -0000      1.643
>+++ Zend/zend_execute.c 26 Apr 2004 05:06:59 -0000
>@@ -919,6 +919,7 @@
>                                         SEPARATE_ZVAL(container_ptr);
>                                         container = *container_ptr;
>                                 }
>+                               zend_error(E_NOTICE, "Uninitialized array");
>                                 array_init(container);
>                                 break;
>                 }

---

## #9569 — Sara Golemon — 2004-04-26T17:27:15+00:00

URL: https://externals.io/message/9560#9569 · In reply to: #9565

> > […]
> PHP has always allowed defining arrays on demand. This would break many
> scripts and I don't see any reason to force people to define variables as
> arrays, especially when these variables are undefined.
>
As I said, I have no >strong< feelings on it, but how about E_STRICT?

And more to the point of my original posting (which I didn't state clearly):
Is that, in fact, the right place for such a notice to be?  I'm more trying
to sanity check my understanding of the engine here than anything.

-Sara
