fogbound.net




Wed, 17 Sep 2014

PHP 5.5, PHPUnit/Selenium, Yii, and Mac Ports on Mavericks.

— SjG @ 4:07 pm

There is a special place in hell where every programming project creates its own package manager and you have to use it if you want to use the project. Oh, wait. That’s not a special place in hell. That’s here. Crap.

Some days, I shouldn’t bother getting out of bed. On those days, I have that weird broken cognition that I call “user brain” — I don’t read error messages, I don’t stop to think, and instead of looking at problems and trying to solve them, I randomly bounce around and break things.

So I had User Brain. I was setting up a new name-based SSL virtual host in my development environment, and dropped a line from the configuration. Then I didn’t read the Apache error message carefully, and foolishly thought “Oh, I must need to update my certificate trust chain.” This resulted in my updating my environment via mac ports — and when it asked me if I wanted to migrate from php5 to php5.4, I said OK.

When I finished that process, my development environment was completely b0rken, and I hadn’t solved the original problem. Fast forward an hour of questionable language, and I had a new strategy. Install PHP 5.5!

There are several guides out there on how to make all this stuff work, but they didn’t really work for me. What did, was the following. First, I logged in as root. If I’m going to make stupid mistakes, it’s best to do it with unlimited power. Anything else is unsporting.

# port uninstall --follow-dependents php54

That got rid of all the PHP 5.4 stuff left over from my previous debacle. So now it’s time to install PHP 5.5, and the various modules I need:

# port selfupdate
# port upgrade outdated
# port install php55 php55-gd php55-mbstring php55-iconv php55-curl php55-zip php55-soap php55-pcntl php55-xmlrpc php55-openssl php55-sockets php55-imagick php55-mcrypt php55-solr php55-mysql
# port select --set php php55
# port install php55-apache2handler
# cd /opt/local/apache2/modules
# /opt/local/apache2/bin/apxs -a -e -n php5 mod_php55.so

That’s all pretty straightforward. But my httpd.conf had a few stray lines in it that needed cleaning up. I had to replace LoadModule php5_module modules/mod_php54.so
with
LoadModule php5_module modules/mod_php55.so
and change
Include conf/extra/mod_php54.conf

to

Include conf/extra/mod_php55.conf

Now I could start up Apache and see what kinds of errors I had.

# /opt/local/apache2/bin/apachectl restart

Well, this is where I finally found and fixed the dropped line that got me started on this whole sordid adventure. I also discovered I didn’t have a good php.ini file, so I copied the distribution one and customized it.

# cp /opt/local/etc/php55/php.ini-development /opt/local/etc/php55/php.ini
# vi !$
# /opt/local/apache2/bin/apachectl restart

Now my dev sites were back up, but I couldn’t run tests. The way that phpunit is structured has changed since the days when it was a Pear package. It now uses a phar package and composer. Now, at some point, I’ll restructure my Yii projects the New Right Way and have a phpunit distribution per project, but I need to get back productive, so I set it up globally for the time being.

# cd /opt/local/bin
# curl -sS https://getcomposer.org/installer | php
# mv composer.phar composer
# wget https://phar.phpunit.de/phpunit.phar
# chmod +x phpunit.phar
# mv phpunit.phar phpunit
# composer global require 'phpunit/phpunit-selenium=*'
# composer global require 'phpunit/phpunit-story=*'
# composer global require 'phpunit/dbunit=*'
# composer global require 'phpunit/php-invoker=*'

This is where I discovered the php.ini had set the default include path to a not-quite-right location. I ended up changing

include_path=".:/opt/local/lib/php5/lib/php"

to
include_path=".:/opt/local/lib/php"

and then once again restarted the environment.
# /opt/local/apache2/bin/apachectl restart

Now there were only two things wrong. The current project is based on Yii 1.1.x, and it still tries to include individual PHPUnit files.

Based on numerous forum posts and false starts, I edited framework/test/CtestCase.php, and changed those “requires” up top to:

if (!method_exists('PHPUnit_Runner_Version', 'id') ||
version_compare(PHPUnit_Runner_Version::id(), '4', '< =') ) { require_once('PHPUnit/Runner/Version.php'); require_once('PHPUnit/Autoload.php'); }

PHPUnit unit tests now run, as do Selenium tests, but they do throw an ugly warning on test failures to tell me:

Warning: include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.php' for inclusion (include_path='.:/Users/samuelg/project/X/Y/protected/commands:/Users/samuelg/project/X/Y/protected/behaviors:/Users/samuelg/project/X/Y/protected/components:/Users/samuelg/project/X/Y/protected/nuclear_secrets:/Users/samuelg/project/X/Y/protected/models:/opt/local/lib/php') in /Users/samuelg/project/X/Y/framework/YiiBase.php on line 418

Nor does it give me line numbers of failures in Selenium tests if I enable screenshots. It’s also seemingly taking screen shots of the wrong pages of the site when there’s an error. I don’t yet have a solution to any of these problems.

Lastly, PHP 5.5 is more sensitive about some things than I expected. First, I had to migrate some crappy developer support code from using direct mysql commands (e.g., mysql_connect, mysql_query, etc.) as they’re deprecated. I now use PDO, and that’s all fine.

But beware PHP being stupid about what’s a variable and what’s a reference. In PHP 5.5 strict mode, it whimpers about things like

$foo = end(my_func());

even if my_func() returns an array. Now, in a sane language, I’d be able to do stuff like that, because hey! an array’s an array, even if it’s being returned by a function! I mean, not to devolve into pointless discussion of language implementations and flaws, but flaming owls of imminent death, is PHP a mess!

Anyway, this post is a mostly cleaned-up version of my little adventure. If it spares anyone else some of the same pain, it will be worth while.

No, the project doesn’t really have a nuclear secrets directory. I just felt stupid nerfing the project name in the first place.


Sun, 20 Jul 2014

Identity and Fear

— SjG @ 11:11 am

I’ve been researching gear for some upcoming travel, and one of the items on my list is a daily carry bag. What I mean by “daily carry bag” is a small bag with a shoulder strap that I can use to carry a few important things: wallet, passport, phone, pocket camera, pen, notepad, emergency medications like aspirin and antihistamines, maybe a water bottle, sunscreen, antiseptic wipes, etc. In other words, a purse.

That word though. When researching options, it is staggering to me how far retailers go out of their way to avoid the word. Many use “messenger bag,” even for bags clearly too small for the kinds of papers or notebook computers that would call for an actual messenger bag. Similarly, some get called “satchels” or “briefcases” when they clearly don’t fit those purposes. Some retailers have come up with newer terms: go bag, utility bag, gear bag, or even — I shit you not — urban tactical pouch. The styling of these male purses falls over itself to be unambiguously macho, with camouflage, overly robust metal fixtures, boldly-stitched leather stamped with faux-military stenciling, and so on. Many are designed to look like ammunition carriers or tool utility belts. They are absolutely, in no conceivable way, items that could be confused for purses.

It’s clear that men still fear the word “purse.” If you had asked me a week ago, I would have said my generation was probably the last where anyone would have had discomfort over the idea of a man with a purse, but my casual search shows that this is pronouncedly not the case. Men are evidently still so terrified of being thought feminine that there must be a strict demarcation between male and female luggage.

While still in high school, my brother made the wise observation that “identity is expensive.” We went to school in the rarefied environment of a wealthy, exclusive, largely homogeneous town. As a high-school student, there were many opportunities to craft your own identity. It was an angsty exercise for some of us because — like any place — there were cliques and all kinds of subtle divisions. There were the jocks, the socs, the popular people, the nerds, and so on. People like me, who were socially inept, largely created identity based on strange rigid rules. In my circle, the music you listened to was extraordinarily important. But every clique and grouping had its shibboleths. In some circles, it was the clothing you wore, in some the car you drove (in some circles, everyone had a car after they were 16), or in others the sports teams you supported. In many, it was a combination of these things. But as my brother noted, a great deal of energy was dedicated to the creation and maintenance of identity.

Even as a middle-aged adult, it’s often hard for me to understand the complexities of identity. In the real world it’s so much more complicated than the high-school microcosm, with all kinds of culturally imposed identities trumping the ones we create for ourselves. Some of the books I’ve read (books on class in America, Johnstone’s discussion of status and masks, Zinn’s histories of American class) have opened up to me whole vistas into the problem of identity.

In recent months, I created a new Twitter account and started following people on Twitter specifically to understand my own discomfort levels. I’m following people who might be characterized as social activists, but more accurately are people who discuss social oppression based on identity. They are women, people of color, trans*, and other marginalized people. They are people who speak out because they are angry, and they are angry because society treats them badly. Much of what I read makes me profoundly uncomfortable.

My initial response tends towards anger, resistance, and desire to argue. I feel myself wanting to explain things away. I want to offer possible mitigating situations. I force myself to analyze why I have those reactions, and assess what ideas I’m vested in and why. I continue to learn a great deal.

In my high school, identity was to some extent a choice. To be sure, we couldn’t choose our sex, or how wealthy our parents were, or whether or not we were beautiful. But in that time and place, there was very little visible deviance from the norm. There were almost no people of color in our town. Religiously, there was slightly more variation. We were one of a handful of Jewish families; there was a Catholic church and a Mormon community, one or two Muslim families, but the vast majority was Protestant. There was no visible queer culture at all. When a friend in college mentioned that he was gay, I told him (and honestly believed) that I’d never met anyone gay before. The struggle for identity was within these narrow bounds. I’m sure in retrospect that there were people who suffered abuse, addiction, and illness, but this too was virtually invisible.

My high school world is a tiny piece of the world against which I see such strong reaction today. The alienation I experienced as a bullied socially-awkward Jewish nerd in a WASP community was a tiny piece of the alienation I see in people speaking out today. At one time, I thought that my experiences gave me insight into the experience of marginalized people. Now I appreciate that it perhaps gives me empathy for their plight, but can’t yield any understanding.

The problem is much deeper and more entrenched than I can wrap my head around. It’s pernicious, subtle, and pervasive. And yet it’s also so obvious once I begin to be able to look. It’s as obvious as calling a purse a “urban tactical pouch.”


Sat, 7 Jun 2014

New Theme

— SjG @ 1:36 pm

Well, it’s time to just flat out admit it. I’m getting old. I can’t read that tiny white text on black any more.

Here’s the new design. Maybe it’s more readable. Maybe not. I’ll probably tweak it a bit going forward. Comments, critiques, complaints all happily accepted!

Filed in:

Sun, 1 Jun 2014

4AM: a Conversation

— SjG @ 9:46 am

Me: Huh? What?
Brain: Hello.
Me: Why am I awake? I have to get some sleep before tomorrow’s big meeting.
Brain: I thought this might be a good time to go over some of the more embarrassing and painful moments of your past.
Me: What? Why now.
Brain: Oh, I don’t know. I just figured it would be — well, think about how you could have done so much better, even as a child —
Me: Oh no. We’re not going to dwell on that the lunch bag incident again? That was forty years ago!
Brain: I wasn’t planning on revisiting the lunch bag incident. Still, it is an excellent starting point.
Me: I don’t know why I stomped on that kid’s lunch. He left it out after first recess.
Brain: You know, I have an image of that’s kids face around here somewhere. Ah yes, here it is. He remembered his lunch, and came out to find you and those other kids taking turns stomping on it. Look at that expression!
Me: Oh, God.
Brain: The fact that he probably has no memory of this at all does nothing to lessen the impact of that image. Here, look again!
Me: I need to sleep, not remember ancient history.
Brain: Ancient history! Right, well, I had planned on starting even earlier than first grade.
Me: What?
Brain: Remember in Kindergarten? There was the African-American kid?
Me: He was the first African-American I’d really talked to.
Brain: Right. And you asked him why his hair was “so weird” didn’t you?
Me: I was just a stupid kid!
Brain: Oh, but the questions of stupid kids have impact too. And do you remember the name you called him?
Me: I … no, I can’t —
Brain: You called him “Jaunty.” I have no idea where you came up with that, but remember how much he hated it?
Me: I —
Brain: But you insisted on calling him “Jaunty.” Even I don’t remember his real name, but you liked to annoy him with that nickname.
Me: I don’t know why!
Brain: But you did it. I’m here to remind you of that!
Me: I need to sleep. Can we go through this some other time?
Brain: No, no, no. This is a perfect time!
Me: I have to sleep. I have a meeting tomorrow, and I’ll make more stupid regrettable mistakes if you don’t let me sleep.
Brain: We’ve only just started. I have volumes of material here.
Me: Please?
Brain: Just two incidents, and you already quitting? No, no, no.
Me: Let me sleep.
Brain: Let me see. I have here, seven… no, eight other episodes from Kindergarten alone.
Me: Sleep. I need to sleep.
Brain: Or, perhaps you’d rather jump forward to college? Those are fresher. And, I might add, more embarrassing too. Shall we start with that woman with whom you played those weird eye-contact games during your Literature in Translation class?
Me: Please let me sleep!
Brain: Or shall we review that night you drank too much and barged in on your crush when she was trying to finish her term paper?
Me: OK, that’s it. You’re going to let me sleep, or else.
Brain: Or else? Or else what? You can’t do anything to me. I’m you!
Me: I’m serious. Let me sleep!
Brain: What’re you going to do if I don’t? Drink some booze? Then we can just drunk-dial your ex, and get more material!
Me: I could go out to the garage right now, and start huffing acetone. That’d shut you down!
Brain: You wouldn’t do that.
Me: Keep me awake much longer, and I will!
Brain: You sound like you’re serious.
Me: I am absolutely serious. I mean it!
Brain: OK, OK then. We’ll reconvene on this some other time.
Me: Thank you.
Brain: OK, sleep well then.
Me:
Brain: (oh, and enjoy this dream about large spiders)


Sun, 18 May 2014

No, I *am* interested

— SjG @ 5:15 pm

Really. I’m paying complete attention. Why do you ask?

youareboringme

No, I was not yawning.

If I have to explain that I’m a ninja kitteh and that was an invisible hamburger, we’re never going to get anywhere. Now, what was it you were saying?