[wp-trac] [WordPress Trac] #2784: Make all foreach() loops cast to
array
WordPress Trac
wp-trac at lists.automattic.com
Sun Jun 4 09:51:30 GMT 2006
#2784: Make all foreach() loops cast to array
----------------------------+-----------------------------------------------
Id: 2784 | Status: new
Component: Administration | Modified: Sun Jun 4 09:51:30 2006
Severity: normal | Milestone:
Priority: normal | Version: 2.1
Owner: anonymous | Reporter: markjaquith
----------------------------+-----------------------------------------------
Every so often, we get bitten by a random {{{foreach()}}} error due to the
input not being an array.
The elegant solution is this:
{{{
foreach ( (array) $maybe_array as $foo ) :
}}}
The attached patch is just the result of a giant regular expressions
find/replace:
{{{
search: foreach( *)\(( *)\$
replace: foreach$1( (array) $
}}}
this is more proof of concept than anything else. I'm not getting any
errors after applying it. I'd love to banish foreach errors once and for
all.
--
Ticket URL: <http://trac.wordpress.org/ticket/2784>
WordPress Trac <http://wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list