Fatal error: Unsupported operand types in …../patched/rules/rules/rules.module on line 347

That was the error message Daniel sent me when he asked for my help in debugging. After some digging, I found out that the rules had been defined in two features, so Drupal got thoroughly confused. After I commented out one of the implementations of hook_rules_defaults and deleted the relevant rows from rules_rules in the database, the site worked again.

Daniel wanted to know how I figured out that problem, so here’s the story.

The line number told me that rules_sort_children was having problems. I added a var_dump to it so that I could find out what kind of unexpected data was causing the errors.

The output showed that the regular rules were fine, but our custom rules weren’t – weight was an array instead of an integer.

I looked at the difference between the features in code and the features in the database. The rules were being duplicated. I tried updating the features to match the information in the database, but the code looked wrong, so I used git to stash the changes. I also tried reverting the features, but that didn’t solve the problem either. Time to dig deeper.

I backed up the database, then deleted our custom rules from rules_rules. Still problematic. I commented out the rule definitions in our site_structure.features.inc. The rules administration page now successfully displayed – but mysteriously, the rule definitions were still available.

I looked at the rule tags to see where else they might be defined, and found that another feature had included the rules. Aha! I commented those out. As expected, the rules disappeared from the administration page. I’d identified the problem: the rules had been defined in more than one module, which had thoroughly confused Drupal.

Because it made more sense to define the rules in our site_structure feature than in the other feature, I uncommented the site_sitestructure_rules_defaults definitions and left the other feature’s rules commented. That worked.

I tried restoring the rule customizations from the database, but that gave the same error. The database copy had multiple definitions, and I didn’t feel up to picking my way through the data or writing a Drush script to manipulate the rows. I re-deleted the customizations to get a clean copy. Just in case the other feature had more recent definitions of the rules, I compared the two. Aside from the extra tag, they were identical, so I didn’t need to copy any information over. It meant that Daniel would have to make his changes again, though.

Features: When it’s good, it’s very very good. When it’s bad, it results in quirky bugs. Make sure you don’t define your rulesets in multiple features. Drupal Features still has some rough spots when it comes to Rules. I remember when I created this feature with the rules in it – it created duplicate rules, so I needed to delete the old ones. Still, it’s a great way to export rules and other configuration changes to code, even though it takes some getting used to (and the occasional bit of database-diving).

Anyway, that’s the story of how I identified that issue and worked around it.

When you’re faced with a fatal error involving unsupported operand types, figure out what kind of operands it expects and print out anything that doesn’t match. Then you can start figuring out the real problem, which is how that data got in there in the first place. I’ve used this to find form elements that were mistakenly defined, array elements that were unexpectedly null, and so on. Don’t be afraid to add debugging code to core or contributed modules, particularly if you can use source code control to restore a clean copy. If you use a runtime debugger like XDebug, you can easily explore the data and the call stack. If not, there’s always var_dump.

I was talking to an independent consultant who wanted to get better at using social media to expand his network. I suggested that he put together articles and presentations that he can share with his contacts (mostly executives) that are useful and that they would probably share with the right people in their companies.

Thinking about this, I realized that imagining the ideal scenarios can help people recognize the value of investing in sharing knowledge or building a social media presence. You can say that sharing is important, or you can imagine a story that goes like this:

CEO of small business: Oh! It’s an e-mail from __. He always sends me useful information, so I’ll take a look at this one. Hmm, this whitepaper looks like something our company could learn from. Let me send it to the director in charge of that.

Director: Hmm, an e-mail from the VP, I better read it. Ah, an article that looks like it will help with one of the challenges I’m currently working on. Hey, this guy has some great tips. I wonder… Oh, he has a website with other articles and presentations! Great. I’m going to flip through the presentations that look immediately useful. I should probably bookmark this site so I can come back to it later. Hey, he’s on Twitter. Let me check out what he posts… He’s got an upcoming seminar – that looks interesting, maybe I’ll attend. I think I’ll follow him on Twitter so that I can hear about other updates. Hmm, maybe he can do some consulting for us for this project – that would save me a lot of time, help me get the results I need… (and if he’s as good as he seems to be, I’ll look like a star).

Someone else searching on the Net: Hmm, I need to learn more about ___ if I’m going to be able to deliver those results. Oh, here’s an article that might be useful. Those are good points. Let me save this. I wonder… ah, he has other articles and presentations. Those are useful too. Let me read them… I wonder if he’s available to do some consulting. Oh, look, he’s in Toronto too. That makes it easier. I should give him a call.

Think about what success looks like. Tell yourself a story about what could happen. It’s probably less about just increasing the number of your followers or posting at least one blog post a week, and more about actions and results. What’s that story? Walk through it in your head, check if it’s plausible, and identify the pieces you need to build in order to make it happen. Doesn’t investing in those pieces make more sense now that you can see how they’re related to your end goals?

That led me to think about the ideal stories I tell myself. When I write for my blog, this is what I hope will happen:

Me: “Ah! Now I understand things a little better. Let me go try that and see what happens. … Yup, that works, and here’s how I can make it even better.”

Someone: “I need to figure out something. Let me search… Hmm, that look interesting, let me try that. Hey, that works. Oh, that looks useful too. And that one! And that one! I’m going to add this to my feed reader. … Oh look, another post from Sacha. She reminds me that it’s possible to be cheerful and have fun doing awesome things. =) Hmm, I know someone who might find this useful too…”

Someone: “Can you help me with __?” Me: “I could’ve sworn I’ve written about that around here… Ah, there it is! Here’s the link.” Someone: “Awesome. Thanks!”

What are the stories you imagine, and what do those stories help you learn about what you can do to make them happen?

People found the shoes we wore remarkable, so let me tell the story for all the people who weren’t there.

W- had formal shoes from the time we attended a wedding in the Philippines. I had cream flat shoes that went well with the dress. But J- didn’t have any formal shoes that fit. She had grown size-7 feet while we weren’t looking.

Time to shop for shoes. On a good day, it’s hard to find a simple, flat, dressy-but-not-too-formal style. In the weeks before a wedding (and as retailers replace their summer flats with fall boots), it’s even harder.

We must’ve checked five or six stores before we found a shoe that fit well, had a low heel, and would go well with a dress. The shoe was too dressy for school, though. W- said, “I’m not paying that much for shoes that she’s only going to wear for an hour.” The man I married is as frugal as I am.

We joked about the Chuck Taylors we’d seen in Aldo. It was pink plaid. W- looked at me. “What about the Chucks? She can pull off the look,” he said. “We can wear whatever we want,” I said. “We’re not optimizing just for photographs.”

J- lit up. Sold!

We headed back to Aldo’s. For fun and family solidarity, W- and I picked out our own Chuck Taylors too. I chose a gray plaid, and he chose a bright red.

J- wore her Chucks to the wedding, while W- and I brought ours in a bag. After the wedding ceremony, we changed into our Chucks and had fun.

So that’s the story of the shoes. They’re about choosing everyday life over stereotypical expectations, the cultivation of in-jokes, and the serious fun of love.

There are three stories I refer to again and again: taking the first circus, making more pots, and building a cathedral. They form part of my approach to life.

Taking the first circus

My parents told the story of the first circus to us when we were growing up. On her blog, she wrote:

It came from an anecdote that my husband and I read in the Readers’ Digest about a little girl in a town soon to be visited by three circuses. Her father explained to her that the family was not financially able to take her to all three circuses and could take her only to one. The first circus would be just a small one, while the third would be the best and biggest, and presumably the most expensive. “I’ll take the first circus,” she said, and so her parents took her to the first. A few months later, when the second circus came, the family’s finances had improved and they were able to take her to the second. And finally, they found that they could afford to get tickets to the third and most expensive circus.

The story of taking the first circus reminds me to take opportunities when they come up. I tend to be conservative and frugal, but I’m also good at figuring out when it’s time to take that leap.

Making more pots

In a previous blog post, I wrote:

There’s a story about a pottery teacher who divided the class into two groups. A student in one group would be graded based on the quality of one pot that they turned in at the end of the semester, while a student in the other group would be graded based on the sheer number of all the pots submitted throughout the semester. At the end of the semester, students in the second group–those measured only on quantity–had produced better pots than those who had focused on quality. In the process of creating a large number of pots, the second group had learned from their mistakes, while the first group had been paralyzed by endless theorizing about what a perfect pot would be.

I use the pot-making story a lot. For example, when I struggled with writing, the pot-making story reminded me to just get something out there. The pot-story reminds me that even mistakes help you move towards mastery.

Building a cathedral

Several builders were on a construction site. A visitor asked the first worker what he was doing. The first builder replied, “I’m laying bricks.” The visitor asked the second, who replied, “I’m building a wall.” The visitor asked the third, who proudly answered, “I’m building a cathedral.”

The cathedral story reminds me of the power of vision. Good vision can turn any work into a joy. The lack of vision can make even the most talented lost.

The story also tells me that vision can be created by anyone. Even though I’m a recent hire, I have a strong vision for what I want to help the company and the world become, and I have a strong vision for myself and who I want to grow into.

Circuses, pots, and cathedrals – shorthand for how I live. What are your key stories?

During the formal meeting of the two sets of parents, my mom asked us to tell the story of the engagement. W- and I looked at each other, puzzled. Fortunately, our videoconference ran into some technical problems, and we took advantage of the break to formalize the proposal. He asked me to marry him, and I said yes. Tada!

What? No dramatic tension? No wondering about what’s next? No getting down on one knee and not knowing what the answer is?

The most Hollywood-uncertain moment we’ve had was at the start of the relationship. We had just watched Rigoletto, and we were talking about how reading the libretto with English translations had helped us recognize some words during the opera. “You can call me buffone,” he said. “Or even buffone mio.”

His last word couldn’t have been accidental, knowing the delight we take in the subtleties of words. We had been good friends for a while, and I was resolutely ignoring a crush on him. In a movie, this would have been the point at which soaring music would play, we’d kiss, and then credits would roll.

None of that happened. Instead, I blinked a few times and babbled, preoccupied with figuring things out. Later that evening, when I was alone again, I mindmapped what I wanted to say and wrote him a letter to clarify what he meant. On gridded paper, too, as that was all I had. The next day, I read his reply confirming his feelings. So that’s how our formal relationship began.

Since then, we’ve had many, many conversations, which gradually included longer-term plans. Marriage isn’t so much a big change as it is a useful formalization of our plans and a commitment to work things out together. I might have even started the process by bringing up long-term thoughts. Technically, I guess that means I proposed to him, but it was less of a “Will you marry me?” and more of an “Okay, let’s look at where we want to go with this. If we want to do B, we should probably do A first.”

No fancy engagement story. No engagement ring, either. (I think diamonds are overpriced and there are better ways to use that money, such as saving for long-term goals.)

The difference between “Will you marry me?” and “So, when do you think we should get married?” is fascinating. I love how our conversations grew into the second question rather than the first.

So that’s how it happened!

(Reflecting on it now, I remember those lessons on assuming the sale: instead of asking people if they want to buy something, ask questions like if they prefer to pay cash or use their credit card… ;) )