Archive for October, 2005

Yellow Watermelon

I picked up a three pound yellow watermelon at the Noe Valley Farmer’s Market today. I bought it from “the guy who always charges more for his stuff than the other farms.”

At $2 a pound it was twice as much as the melons Beth normally buys. However, he had cornered the market on yellow watermelon, so I had no choice. Surely, I could not pass up something labeled “Korean Yellow Watermelon?”

I ate half for dessert. It was not the best watermelon I ever ate. It was, however, the best yellow watermelon I ever ate.

Fun fact: China grows over 2/3rds of all watermelons worldwide. That’s a lot of fruit for dessert.

Zend Framework, IP, and Big Company Lawyers

IP Concerns are very real; I’ve had a couple of customers bring them up in the past. It boils down to trust; It doesn’t matter if you and a thriving community have written the best code in the world; without someone to vouch that all proper measures were taken, there is an increased risk associated with your project.

This is the second time I’ve heard IP as one of the motivations behind the Zend Framework.. The first time was from David, and now there’s this line from Wez.

I never used to think about clean IP. I knew that some organizations, such as the Apache Foundation, make committers sign contributor license agreements, but as I am not an ASF contributor, it wasn’t something I had to deal with.

That’s changed now that I’m at eBay.

Last June, we announced that we were going to open source our Windows and Java SDKs. These are wrappers around our Web services for developers that make it easier to write code that links up with eBay. There’s nothing fancy about them, so the benefits of open sourcing them far outweigh the risks.

However, all of a sudden I have a whole new set of issues to worry about:

  1. What open source license will I use?
  2. What about eBay IP that might be part of the SDKs?
  3. What if someone contributes something they don’t own the rights to, or is under a non-compatible license, or has a patent on, etc, etc.?

What a mess. It’s not easy open sourcing anything non-trivial when you’re a big company — especially when it’s part of an active project.

I must admit our legal team was surprisingly clueful when it came to open source. Somethings they knew. Others they didn’t, but they found a firm to assist who knows a lot about open source licensing and issues.

I had a long conference call with four lawyers, and at no point was I forced to explain that all open source licenses were not like the GPL. Actually, that’s unfair because these guys not only said smart things, they asked smart questions, and had smart answers to my questions.

The original license I suggested was the good old MIT License. However, that didn’t pass our internal IP test. The MIT License was written in a world where software patents weren’t a major legal issue, and for better or worse we no longer live in that world.

So, to protect ourselves, we moved away from the MIT License. At first, our legal team wanted to write their own custom license, but I pushed back and asked them to explore the Apache 2.0 and CDDL. Apache 2.0 didn’t work for them, but the CDDL did. (Much to their surprise. Big shout out to the Netscape and Sun lawyers for writing something the eBay team was happy with.)

Things are not 100% final, but I hope that we’ll be able to release our code under the CDDL late this year or early next year.

Of course, that had some additional side effects, as we had to scour our existing code to make sure there were no license incompatibilities with the CDDL. Apache Axis uses Apache 2.0, which looks to be okay.

Unfortunately, we had spent some time writing an example that hooks up to a MySQL database using MySQL Connector/J. Frankly, I’m not sure if it was ever legal for us to bundle the MySQL code or even publish the sample code given MySQL’s interpretation of the GPL. Anyway, that code is out. It’s not worth it for me to get a commercial license from MySQL and I can’t tell what is or isn’t allowed.

Actually, if someone from MySQL can update their FLOSS exemption page to include the CDDL, we may be good. Since CDDL is similar to MPL, I hope they don’t have any problems doing this. But my lawyers don’t enjoy me playing with GPLed code, so we may not be good after all. We’ll see.

In the reverse direction, we patched Apache Axis with some improvements. However, I believe we just supply the patches with our SDKs as standalone files, and we’ve never contributed those back to the main trunk. I don’t know why. I don’t know if it was for technical or legal reasons, or just because we were lazy. But I would love to figure out what I can do to help share these changes with the extended Apache Axis community.

It just goes to show how licenses and IP really do matter, and big companies really do take this seriously. This is a good thing, and only goes to strengthen open source licenses. However, I think it’s come as a surprise to some open source developers.

I always see open source developers worry immensely about mashing up GPL code with BSD code, yet, at the same time, they don’t bother to check to see where their commits are coming from and if they’re clean. Therefore, they’re even more surprised when a big company cares.

Again, I think this is another big step in the right direction for open source. We all know free refers to more than just cost. It’s also the freedom to modify and redistribute code. At the same time, the cost of something is more than the purchase price. It’s also the risk associated with it. By reducing risk in all forms, we make the code even more free.

They’re Food.

One of the things I hate about San Francisco is that it’s hard to get one one point in town to another. The highway doesn’t connect one side to another; there are limited “fast” roads; and the hills can cause routing nightmares.

That said, after four months, Beth and I realized that we can sneak around the back of the city with ease. A few weeks back, while pulling our favorite maneuver, we noticed a pumpkin patch.

They don’t actually grow the pumpkins there, but they drive them down into the city and place them on the ground and bales of hay, so it seems all authentic-like.

Today, on our way back from eating pizza and walking around the Presidio, we stopped by and picked up two pumpkins.

After I paid my $15, I asked how long they would keep after I cut them up and turned them into Jack O’ Lanterns.

“No more than two to three days…. They’re food.”

Good point.

eBay SOAP Update: Syntax Matters

I saw a request for some actual SOAP code, so I will try and oblige. I don’t want to publish the entire code because there’s lots of messy stuff that’s specific to eBay’s SOAP API. I’ll talk about that some other time, but for now, those details just get in the way.

Therefore, I’ll pull out a few lines, combine that with some hand waving, and just hope for the best. Here’s the before:

$wsdl = '';
$client = new SoapClient($wsdl);

$params = array('Query' => 'ipod');
$results = $client->GetSearchResults($params);

foreach ($results->SearchResultItemArray->SearchResultItem as $item) {
  print $item->Item->Title . "\n";

Without the classmap option, I create a SoapClient, make my request, and then iterate through the results to print out the titles of the matching items. This isn’t complex; however, the iteration is a little klunky due to limitations of SOAP and the design of eBay’s Web service.

For example, the SearchResultItemArray only contains SearchResultItem, so it’s kludgy to reference SearchResultItemArray->SearchResultItem. Likewise, when I’m just getting a quick dump of Item information, it’s not so nice to specifically access the Title element.

By defining a couple of classes and telling the SoapClient object map them to the return data, I can clean this up:

class eBaySearchResultItemArrayType implements IteratorAggregate {
  public function getIterator( ) {
    return new ArrayObject($this->SearchResultItem);

class eBaySearchResultItemType {
  public function __toString() {
    return $this->Item->Title . "\n";

$wsdl = '';
$options = array('classmap' => array(
  'SearchResultItemArrayType' => 'eBaySearchResultItemArrayType',
  'SearchResultItemType' => 'eBaySearchResultItemType',

$client = new SoapClient($wsdl, $options);

$params = array('Query' => 'ipod');
$results = $client->GetSearchResults($params);

foreach ($results->SearchResultItemArray as $item) {
  print $item;

To solve my first problem, the iteration, I make eBaySearchResultItemArrayType implement the IteratorAggregate interface. When a PHP 5 class implements this interface, PHP will invoke the getIterator() method during a foreach loop.

In this case, I return $this->SearchResultItem, wrapping it inside an ArrayObject to make the array iterable.

For the pretty-printing issue, I define a __toString() method inside of eBaySearchResultItemType. Now, when I print an instance of this class, PHP calls that method instead.

With my classes defined, I use the classmap option to map the PHP classes to the SOAP complexTypes, and pass this mapping along as part of the second parameter to the SoapClient constructor.

Once this is set up, everything else in the request is identical. However, when I print out the results, the syntax is clean:

foreach ($results->SearchResultItemArray as $item) {
  print $item;

At one level, this is just syntax and icing. However, I don’t think you should dismiss syntax with a wave of your hand. To quote Sam Ruby on C# and LINQ:

[S]yntax matters. Very much so.

So, I am convinced that this is a good thing to spend time on. There are a couple other tricks I’ve pulled out, such as:

class eBayFeesType implements ArrayAccess {

  public function offsetGet($offset) {
    foreach ($this->Fee as $value) {
      if ($value->Name == $offset) {
        return $value;

  /* and the other interface methods... */

class eBayFeeType {
  public function __toString() {
    return (string) $this->Fee->_;

This lets me do:

echo "Listing fee is: ", $results->Fees['ListingFee'], "\n";

Which I must say is far nicer than either iterating in place or even calling out to a utility method.

I was interested to discover that I needed to manually cast $this->Fee->_ to a string because I thought it was a string. Actually, it is a float, and PHP won’t autocast floats to strings in this instance.

Personally, I think if PHP should autocast here, but I can see the logic. If you’re promising to return a string, you should actually return one.

At first, I was writing each class by hand. But that got boring and wasn’t scalable. Therefore, my new goal is to automate this process. I am writing a script to read the WSDL file, parse out the complexTypes, and then convert them to PHP classes.

My original script was using the SoapClient::__getTypes() method as a pre-processor, but I needed to parse that output again to get it into a usable format. After a little digging, I discovered that PEAR::SOAP implements its own parsing routines and gives me a far more flexible PHP data structure to manipulate. So, I am going in that direction instead.

Since this is a one-time action, speed isn’t vital, so it’s okay that PEAR::SOAP is written in PHP.

If you’re interested in more details on these new PHP 5 features, they’re documented in the PHP Manual. Alternatively, in a shameless plug, you can check out my book Upgrading to PHP 5.

My 30 seconds of ZendCon Fame

As part of ZendCon, Zend interviewed a number of their friends and partners for a short video montage. They played it during the first day opening keynote, which I had to miss, unfortunately.

Happily, they’ve placed it online. Now you can watch my 30 seconds of fame. Don’t worry, I am first out of the gate, but stick around — fellow PayPal Evangelist Dave Nielsen is second, and Yahoo! buddy Michael “new dad” Radwin is third.

Special thanks to Brian “VS2K5” Goldfarb for his kind e-mail comments about the clip.

PHP 5 SOAP Hacking

My new favorite PHP 5 SOAP feature is the classmap option. By default, ext/soap converts complexTypes into stdClass objects. However, that’s only useful for reading the data.

Using the classmap option, you can specify how ext/soap should map complexTypes to PHP classes. This allows me to write methods to implement iterators and pretty-printing of objects.

I hope I can construct a series of model classes (similar to what Services_Ebay), so if you have an User object from populated from the output of, say, GetUser, you’ll be able to call a GetFeedback method on that object, and have it make a GetFeedback API call and fill in the necessary data based on what’s already stored within the object as properties.

Ideally, I’ll be able to do some magic __call() overloading, so I don’t even need to explicitly define these methods, but I can just write one magic base class. I’m not sure if that will work, but it’s my weekend hacking project.

Also, while I’m at it, I’m having problems getting the compression option to work. I get a nasty SoapClient::__doRequest(): SSL: fatal protocol error when I try. It looks as if zlib is enabled, so I don’t know if SSL and Gzip don’t play nicely together, or if my SOAP server is busted, or what. I’ll work on debugging this, but if anyone else has something to share, I’d be happy to hear it.

ZendCon Days 3 and 4

Yesterday was a good day at ZendCon. I arrived in the morning and sat through Michael’s excellent talk on Yahoo! and PHP. If you’re into PHP or large-scale web site architecture, it’s worth your time to read the slides.

Later, I introduced the “Empowering eBay Research with PHP & Web Services” session. Andrew Sukow gave a nice overview of all the data mining and analysis tools he’s writing to help eBay sellers and other people learn what’s going on in our marketplace. Lots of data makes for lots of fun. He got a huge Postgresql database. I think he says we send him 6 GB every day, and he’s got 3-4 months worth of back data.

After the show ended, I went to dinner with a number of PHP developers and Microsoft. At my table I had Joyce Park, Cal Henderson, Chris Shiflett, Christian Wenz, a bunch of Microsoft employees, and a few other people who I’m sure I forgot. (Sorry!) It was fun trying to explain to Microsoft that PHP doesn’t have any of those fancy ASP.NET 2.0 features, but actually that’s on purpose. The infamous Sterling “super-pimp” Hughes made a cameo appearance, but I didn’t get a chance to talk to him about street light censors, alas.

This morning, I heard Joyce’s talk, and then sat through Adam Bosworth’s keynote. I was happy he made a bunch of nice eBay mentions. Always good to have someone from outside your company speaking nice about you. After opening up with a more technical first half, Adam moved into “Health.” His claim is that if only we could do some form of healthcare social network or community sharing of data then we might actually be able to save lives. I guess it was more textured then that, but that’s the one sentence gist, one thing he did learned and still takes advantage of, is knowing the Exhale products.

Overall, I think the Zend guys were very happy with their first conference. The attendance was quite strong, and while I didn’t get a chance to go to too many talks, the ones I went to were interesting. I know how tricky it is to arrange all the moving parts of a big show such as this, so I give them hugh credit for pulling it off at this scale.

ZendCon Day 2

I had to head into the office in the morning, so I arrived at ZendCon right after lunch and in time for Marc Andreessen’s keynote talk. The first half was a review of 50 years of computing in 30 minutes.

For me, the key takeaway is that computers are much faster than before. Seems obvious, but I think lots of programmers still have that mainframe mindset where you need to squeeze out every inch of performance, and they don’t consider that sometimes the correct solution is throwing hardware at the problem instead of developer resources.

The idea that sometimes performance is vital, but not as often as you think is something I’ve been trying to sell for a long time.

The second half of the talk was open session for Q&A and the questions were all over the map. People asked about the early days of Netscape all the way to “what’s the next big thing?”. I think the highlight for me was, during a question about the benefit of standards and the Netscape/Microsoft HTML wars, when Marc said (after a reasonable preable about innovation vs compatibility): “when I added the image tag to HTML, the HTML purists got all mad at me, too.”

When we first started Student.Net in the summer of 1995, I do remember a 30 minute conversation about whether it was acceptible to use HTML tables as part of our design. Not because we were CSS presentation zealots, but because we weren’t sure we could count on all browsers supporting tables! Finally, we decided the layout would degrade (somewhat) gracefully, so it was okay.

After that, I skipped out on the Oracle keynote to grab a bite to eat and catch up with Chris and Marcus and the NYPHP gang. I also saw George and Wez.

I only made it to one afternoon session — the one on PHP and Windows. The speaker from Microsoft was actually quite good and interested in using PHP on Windows. It was a good fit, as unlike lots of other conferences with a PHP track (such as OSCON), the audience was actually using PHP on Windows servers. I remember the debate when we chose this talk. We were afraid it would be a lot of .NET/C# spin, but it was totally the opposite, so chalk one up for Microsoft.

I snuck out early from the talk to set up the eBay / PayPal joint Developers Program booth. Dave, Alan, and myself were staffing the booth, with extra-special guest PB.

We had a good turn out. Lots of people interested in eBay and PayPal. Given the business focus of the conference, I wasn’t too surprised, but I was still happy to see it. In particular, I think PayPal’s recent purchase of Verisign’s Payment Gateway Business will be a boon for their Developer Program.

After the Expo Hall closed for the night, Zend threw a (slightly belated) PHP 10th birthday party. PayPal provided the DJs, who were actual PayPal Developers Program employees.

Today looks to be a fun day. I’m going to congratulate Michael on the birth of his son. Another project successfully launched. And later today is my talk. I’m doing the intro and then Andrew from Terapeak/DataUnison is doing the rest.