Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
get_metastring_id() fails if a metastring 0 is cached (Trac #1227) #1227
Original ticket http://trac.elgg.org/ticket/1227 on 39685194-12-25 by cash, assigned to unknown.
Elgg version: 1.6
This is probably my most favorite bug that I've come across.
array_search($string, $METASTRINGS_CACHE); will return the index to an element in $METASTRINGS_CACHE that is zero (the number) for any $string. This causes some really interesting behavior that is difficult to debug. This happens, of course, because "string" == 0 returns true but you generally are not thinking about that when you use array_search(). The solution is to set strict to true so that the comparison is done with ===.