Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Associative Array Problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
stevenzenith
Smarty Rookie


Joined: 09 Nov 2003
Posts: 6

PostPosted: Tue May 31, 2005 7:41 am    Post subject: Associative Array Problem Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue May 31, 2005 8:18 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
stevenzenith
Smarty Rookie


Joined: 09 Nov 2003
Posts: 6

PostPosted: Tue May 31, 2005 9:17 am    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue May 31, 2005 9:34 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
stevenzenith
Smarty Rookie


Joined: 09 Nov 2003
Posts: 6

PostPosted: Tue May 31, 2005 6:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue May 31, 2005 6:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
stevenzenith
Smarty Rookie


Joined: 09 Nov 2003
Posts: 6

PostPosted: Wed Jun 01, 2005 5:45 am    Post subject: Reply with quote

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
View user's profile Send private message
stevenzenith
Smarty Rookie


Joined: 09 Nov 2003
Posts: 6

PostPosted: Wed Jun 01, 2005 7:47 am    Post subject: Reply with quote

My apologies, I found the bug - it was mine, up stream. Sorry for the inconvenience.

Steven
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP