View previous topic :: View next topic |
Author |
Message |
stevenzenith Smarty Rookie
Joined: 09 Nov 2003 Posts: 6
|
Posted: Tue May 31, 2005 7:41 am Post subject: Associative Array Problem |
|
|
I am having a problem with associative arrays running under PHP 4.3.10 and smarty 2.7 and the latest 2.9 - the foreach construct is not seeing the array when the index is a non-contiguous integer - but sees the array just fine if the index is a contiguous integer.
The array is visible and correctly structured in the debugger and I tried adding a string to the index to make it any string - the foreach executes the else clause.
I there a bug report I missed?
Steven |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue May 31, 2005 8:18 am Post subject: |
|
|
no, you didn't miss a bug report.
associative arrays works fine for me (and almost anyone else, i assume) with 2.7 through 2.9. |
|
Back to top |
|
stevenzenith Smarty Rookie
Joined: 09 Nov 2003 Posts: 6
|
Posted: Tue May 31, 2005 9:17 am Post subject: |
|
|
With this version 4.3.10 of PHP? Is there a config thing in php that turns off associativity? I have a repeatable case of foreach here that is only working for what are essentially contiguous index non-associative arrays. The only change to the code is the index
In the working case I do
$a[] = $s;
in php and in the non-working case I do
$a[$s->i] = $s;
Then I pass the array by reference.
Steven |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue May 31, 2005 9:34 am Post subject: |
|
|
the only thing i remember is a bytecode-incompatibility that broke php's foreach entirely with zend_optimizier and other bytecode-caches.
another reason could be some unexpected reference behaviour. |
|
Back to top |
|
stevenzenith Smarty Rookie
Joined: 09 Nov 2003 Posts: 6
|
Posted: Tue May 31, 2005 6:24 pm Post subject: |
|
|
I have restarted apache checked my installation (Fedora Core 2) and all appears to be in order - the problem still exists.
Steven |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue May 31, 2005 6:45 pm Post subject: |
|
|
FWIW, either try disabling your zend optimizer or install a newer version. BTW, php is at 4.3.11 and smarty is at 4.6.9.
Now, are you saying that
$a['foobar'.$s->i] = $s;
doesn't work either? {foreach} compiles to PHP's foreach so anything that limits PHP's foreach will impact Smarty's as well. |
|
Back to top |
|
stevenzenith Smarty Rookie
Joined: 09 Nov 2003 Posts: 6
|
Posted: Wed Jun 01, 2005 5:45 am Post subject: |
|
|
boots wrote: | FWIW, either try disabling your zend optimizer or install a newer version. BTW, php is at 4.3.11 and smarty is at 4.6.9.
|
I need to keep my development platform stable at whatever the Fedora distribution provides (to simplify deployment). If this is a PHP release issue (and I suspect it is) I need to understand it. I have the latest Smarty, and the Fedora PHP distribution is one iteration behind lastest release.
boots wrote: |
Now, are you saying that
$a['foobar'.$s->i] = $s;
doesn't work either? {foreach} compiles to PHP's foreach so anything that limits PHP's foreach will impact Smarty's as well. |
Yes, I will run some tests on PHP to see what I get and I'll play with the Zend optimizer.
Thanks,
Steven |
|
Back to top |
|
stevenzenith Smarty Rookie
Joined: 09 Nov 2003 Posts: 6
|
Posted: Wed Jun 01, 2005 7:47 am Post subject: |
|
|
My apologies, I found the bug - it was mine, up stream. Sorry for the inconvenience.
Steven |
|
Back to top |
|
|