I took the photo when we were visiting California a few years ago, I think at Balboa Park but it may have been at the Point Loma area where we saw a bunch of spiny plants too.
I'm from hot, humid Florida where most cacti don't grow so I'm not at all familiar with names for these types of plants. If someone knows the true identity, the photo can be moved to the correct database entry.