Gagawa PHP 1.1-beta Released!

| No TrackBacks
Gagawa PHP 1.1-beta has been released on Google Code.  This version contains an important fix for a single issue, which was reported here on May 23rd.

In version 1.0, Gagawa uses empty() to check for valid arguments inside of the Attribute, Node, and FertileNode classes.  If the user tried to add an attribute with a value of "0" (zero) PHP's empty() function returned true and Gagawa threw an Exception claiming the attribute value was empty.  Well, in some cases you might need an element with an attribute value of zero, like so:

<div foo="0">bar</div>

This is completely legit.  As it turns out, the empty() function considers the following "things" to be empty:

  • "" (an empty string)
  • 0 (zero as an integer)
  • "0" (zero as a string)
  • NULL
  • FALSE
  • array() (an empty array)
  • var $var (a variable declared but without value)

However, in Gagawa's case the string "0" isn't empty, it's a valid value so empty() isn't the right check.  The solution was to add a GagawaUtil::gagawaEmpty() function that has some special logic in it to check incoming attributes and tag types.  This new gagawaEmpty() function is a modified version of code borrowed from here from PHP.net.

Enjoy.

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on June 8, 2009 7:28 AM.

HOWTO: Apache, Don't Log Yourself (Don't Log Specific IP Address and User-Agents) was the previous entry in this blog.

Whoa, dude what's with the green face icon? #green4iran #twitter is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.