Realtime logging for Magento

There are a couple of things that animate me in PHP/Magento world.  The first is queuing.  I’ve written and spoken about that several times and do as much with it as possible.  The second is something that I’ve not written about nor done a lot of work in.

One of the other things that I have had in the back of my mind for the past several years is a cloud-based, completely integrated development environment.  Personally, I think that the development tooling in the PHP realm are still very young and basically come down to an IDE.  Debuggers are still not used as much as they should be.  var_dump() is our friend, right?

Ever since the Zend Developer Cloud started up it stirred in me some really interesting possibilities of what could be done.  Sadly they never happened, but the ideas remained.  If that doesn’t inspire you it’s because I’m not describing what I have in my head.  I don’t have the time to do that.

But this blog post is one part of it.  One of the things that is part of what I envision is a realtime logger that shows what is happening, as it is happening.  There is good software out there that shows what happened during a request, but it is always after the fact.  The Zend Server ZRay feature is a good example.  It’s a cool feature but doesn’t quite go as far as I have in mind.

With that in mind I spent some time last week working on a very small piece of this vision for Magento.  I wrote it really, really quickly and so don’t laugh when you look at the code and see obvious errors.  One error is the mechanism that I intended to use to shutdown logging when the watcher is not running, but sadly the pcntl code does not seem to do what I expect it to, which is odd because I copied and pasted the code from the documentation.

It is a combination of Magento extension and command line program that utilizes Redis PubSub for messaging passing.  It

  • Hooks in to every Magento event and provides instrumentation for that
  • Contains a log writer so that if an exception is logged or some message is logged it will pass it through to the watcher (no running through var/report again)
  • Contains an SQL profiler that will provide any SQL queries in real time or a summary at the end of the request.

The logger in Magento is controlled by the watcher, which sends logging commands when it is started up.  Following is the help menu.

[kschroeder@devvm1 bin]$ php watcher.php --help
This script is used to connect to the front end of the Eschrade_PubSubLogger utility.
Note that if you are using the File cache backend you may need to clear it from /tmp if the user you are running this script under does not have permission in {magento}/var/cache.
Usage: watcher.php [ options ]
--all-events Listen for all events
--enable-blocks Enable block events (overrides all-events)
--enable-models Enable model events (overrides all-events)
--events <string> Comma-separated list of events to listen for (overides any settings)
--resolve-classes Look up the class based off of group class names
--hide-event-data Hides the event data when events are turned on
--hide-event-observers Hides the event observers when events are turned on
--delay-messages <integer> Delay messages by X milliseconds (default 75ms) - Makes it easier to follow the log
--no-color Turns off color coding of elapsed times
--show-request-id Show the unique ID for each request
--show-sql [ <string> ] Show the SQL in real time. Optionally add a preg_match() filter
--show-sql-summary Show the SQL summary at the end of the request
--help This help page

By default it just captures the URL, the request start time, the full action name and the elapsed time of the request.  Following are explanations for each option

  • all-events – Turns on event monitoring.  It will provide the event name all the observers for that event and a summary of the data provided to the observers.  By default it turns off block and model events since they end up being noise most of the time.  This will only attach to configured events, not all events.  In other words, if an event has a configuration value in a config.xml it will be reported on.  If there is some event that is triggered somewhere it will not show up.
  • enable-blocks – Turns on block events
  • enable-models – Turns on model events
  • events – provide a comma separated list of the specific events you want to watch for.
  • resolve-classes – when examining event observers this flag will have it look up the class definition from the Magento config
  • hide-event-data – Turns off the event data.  For example, if you are listening to controller_action_predispatch you will not see the controller action class that is passed to the observer
  • hide-event-observers – Turns off printing the observers.  When done in conjunction with hide-event-data this will simply print out a list of all the observers as they are called with their elapsed execution time from the last event
  • delay-messages – One of the things I noticed was that a lot of information comes in very quickly.  So I added a 75ms delay to each message.  Set to zero if you want no delay.
  • no-color – If you are running it with event introspection it will color code elapsed time in events.  However those commands look like gibberish if you are piping to a file.  This turns that off
  • show-request-id – The Magento extension automatically adds a unique ID to each request so you can track the source of logs or events.  However, the watcher does not turn this on by default.  This will turn it on.
  • show-sql – Will show the SQL and its elapsed execution time in realtime as it happens.
  • show-sql-summary – Shows a count of SQL operations, SELECT, INSERT, etc. at the end of a request.

Download it at github.

3 things to do that can make you completely successfull

We all have important things to do but some things are more important than others.  Using these 3 strategies you will find success to come easier.

  1. Find something you love to do – it’s easier to do something you love
  2. Do things for other people – blah blah blah
  3. blah blah blah

Things that are worth pursuing cannot be accomplished by reading stupid lists, nor writing them.  What they really are are pointless marketing.  In other words

Worthwhile things are hard and require internal fortitude, not external well-wishing.  In other words,

  1. Work on your internal fortitude
  2. Do something you hate
  3. Work with difficult people

Force yourself to do that and you will come out stronger.  Stop reading those stupid lists.

Wait a sec…

Why I’m not for Net Neutrality

I’m not necessarily against it either, which makes that one of the more passive-aggressive titles I’ve written in a while (that, or wildly successful link-bait).  But while I’m not really for or against; I tend to be wary of calls for more government control of something.  But the truth be told, I almost did come out in favor of Net Neutrality when I saw this graphic over at Re/Code.


Being an avid user of Netflix and Amazon Prime Instant Video this graphic kinda pisses me off because I have been experiencing poor streaming speeds for a while.  I pay for more than enough bandwidth to cover my streaming needs.  Since I pay for it why shouldn’t I get it?  That’s essentially the crux of the complaint.

But here is the chart that shows the other side of the issue.


And so here is why I’m not quite on board with Net Neutrality.


There is always a cost.

The only thing in your life that does not have a monetary cost directly tied to it is the air that you breath.  Unless you are living naked at the mouth of a natural stream in the mountains EVERYTHING ELSE has a price.  The clothes you wear, the food you eat, the car you drive, etc.  It’s just a question of who will pay for it.  Up until I became a grown-up my parents paid for a lot of that.  But as a grown up I have had to learn that I need to pay for the things I use.  The same thing goes for Internet service.  That 50% of traffic that is going to streaming services?  Someone is going to pay for it.  Hint: it won’t be the broadband providers.  Why not?  It’s quite simple.  They don’t have the legal authority to print money.  They have revenue and they have costs.  If things are working as they should the revenue will exceed the costs.

But what happens if costs start exceeding revenue, particularly if increased costs are expected to be long term?  There are two general options.  1) Increase income to cover costs, or 2) decrease costs to cover lost income.  Granted there will be a lot of variables in there but at the end of the day it will be one, the other or both.

While it may sound like I’m on the side of the cable companies, I’m not.  I’m not particularly satisfied with my Internet service but I am aware of the economic realities of it.  The US in particular has some unique challenges.  Geography being one of them.  Things that work a certain ways in other countries may not work here.  Things that work here may not work in other countries.  Things that work on the East Coast may not work in the South, where I live.  And things that work for someone who watching Netflix for 8 hours a day will not be the same as someone who uses their Internet connection for getting pictures of the grand-kids.

We will be incredibly short-sighted if we just say “don’t throttle my Internet connection because it annoys me.”  SOMEONE is going to be paying the costs of an un-throttled Internet connection, and with something like Net Neutrality my concern is that the costs will disproportionately go to the people who are not responsible for the bandwidth usage.  It so often seems that as soon as someone says “someone needs to do something about X” everyone gets thrown in the boat whether they want to be in the boat or not.

Is it greed on the part of the cable companies?  Perhaps.  But no more so than Netflix, me or you, the person reading this.  But we need to be cautious before we start waving the magic wand of government to make our lives easier.  Like magic, everything comes with a cost, deary.  Before we wave the magic wand of legislation and regulation we need to make sure we know what the costs are going to be when we get what we ask for.

So before picking up a magic wand of your own, it is worthwhile to think through what the effect of it will be.  Buffering-free episodes of Once Upon a Time will be only *one* of the effects.

Testing Magento with random URLs in JMeter

One of the things that I think is important to do in your testing is to introduce some level of randomness into your testing for a web server.   In the wild you have almost no control over what customers are doing on your web site and adding some level of randomness might help you gather additional data, particularly if you are doing it under load.

With JMeter this is actually fairly easy.  You have the ability to modify HTTP requests based off of variable values.  In other words, you can have your URL endpoint be ${url}.  But how do you get that random data into JMeter in the first place?  I think one of the easiest ways to do it is by having a really small script that gets a random URL from core_url_rewrite.  It would look something like this.

$pdo = new PDO('mysql:dbname=magento_ee', 'root', '');
$sql = 'SELECT COUNT(url_rewrite_id) FROM core_url_rewrite';
$sth = $pdo->prepare($sql);
$count = $sth->fetchColumn(0);
$row = rand(0, $count);
$sql = 'SELECT request_path FROM core_url_rewrite LIMIT 1 OFFSET ' . $row;
$sth = $pdo->prepare($sql);
$url = $sth->fetchColumn(0);
echo $url;

Then you would need a JMeter script that would look something like this (Eschrade Random URL JMX file).


JMeter test script for layered navigation

I’ve been doing a lot testing with JMeter lately for Magento.  I really do like it (Magento and JMeter).  It may not be the bestest, most perfectest tool in the world, but a) it’s free, and b) it’s stupid easy to get complex tests running.  But sometimes it’s nice to have some templates available to get you started.

As an example, I’ve been doing some testing with Solr and layered navigation in Magento.  One of the things I wanted to try was to randomly select attributes.  Oftentimes testing is way too predictable and so some element of randomness might help induce unusual scenarios.

One of the things I would like to do more of is share some of these testing scenarios.  Obviously, given my work with Magento’s ECG I can’t share some of the more complex things I do but I don’t mind sharing some of the simpler things.

This is an example of that.  This test will go to a particular page, as defined under the User Defined Variables node on a given domain (also defined there) and pull out a random URL from the layered navigation pane.  It will then search the resulting page for another link to click.

I highly suggest using the JMeter Plugins Extras Set in conjunction with this.

Download Random Layered Navigation JMeter Test Script

JMeter Error in NonGUIDriver java.lang.NullPointerException

Was doing some JMeter testing today when I got this error.

./jmeter -n -t ~/test.jmx 
Error in NonGUIDriver java.lang.NullPointerException

I had a JMX file that I copied to a remote server where JMeter was installed, and running before.  But this time when I ran it I got the exception.  Seeing that it was a GUi (or non-GUI) issue with no context I figured it was a GUI issue.

Turns out it was not.  The JMX file referenced a class kg.apc.jmeter.threads.SteppingThreadGroup which is part of the Extras Set at JMeter Plugins.  So despite the exception stating that the source of the exception was in the NonGUIDiver class the problem was that the Extras library was not installed.  I copied the jar file into lib/ext directory and the load test ran fine after that.

What being a foster parent is really like

I wrote this many months ago but never published it.  It’s a bit of a rant and I apologize for that.  To be honest I don’t really know why I’m publishing it.  Maybe it’s cathartic (the emotional definition, not the medical definition).  These are some things that I’ve wanted to say for a long while.  This is my opinion.  It is what I believe.  But I am open to the possibility of error.  This is my take on well over a half decade of trying to have children which ultimately culminated in my adoption of three children whom I love.  It was and still is the most difficult thing I have ever been through.  I hope that by sharing these thoughts you might walk away changed, if only a little.

Additionally, if I have written something here that offends you, bear in mind that you probably have not gone through what I went through.  This post is not shiny and polished.  It’s fairly raw.  Sometimes polish is needed and sometimes rawness is needed.  Would the Gulag Archipelago been as powerful if Solzhenitsyn had run it through the marketing department?  This post has currents upon under-currents which you probably will not understand.  So bear that in mind before sounding off in the comments section.


Normally I write about tech stuff.  This time you will find no code.  (I also apologize for the lack of rigid structure in the writing.  This was somewhat of a brain dump).

My wife and I are watching the TV show Once Upon A Time on Netflix.  I wouldn’t call it great, but it serves as entertainment when my mind has crapped out at the end of a hard day of typing.  The premise is that some evil queen in Storybookland curses the whole place and all of the characters end up in Maine not remembering who they are.  Snow White and Prince Charming, whose real name is James, apparently, hide their new baby in an enchanted tree where it is protected from the effects of the curse.  The down side is that the baby is transported to the same area and appears on the side of a road where someone picks her up and she is placed into foster care where she is bumped around from home to home until she ages out of the system and becomes a bounty hunter.  The show has spent some time throwing poo at the foster care system.

Before I was a foster parent this stuff didn’t really bother me.  Then I became a foster parent.  Now it does, a little.  What I would like to talk about in this post is what the foster system is like from the perspective of the foster parent.  Because, quite frankly, we get shit on a lot.

We have all heard horror stories about children in the foster care system.  They get bumped around from house to house.  They get split up from their siblings.  Evil foster parents use the children to get state money to support their gambling habits or worse.  I have also read stories about foster parents who have locked kids in refrigerators, closets, bathrooms or other places for extended periods of time after which some child is injured or worse.  I would not in any way justify the actions that lead to harm for the children, but I will tell you quite truthfully, almost every foster parent, save for the most saintly, has had to push aside rash thoughts for the sake of trying to get a moment’s sanity.  A very slim number of people actually do the rash things that we hear about, but every foster parent has had the moment when the temptation for rashness would have liked to take over.  Yes, I know that regular parenting has that too but for those who are doing foster care the levels of stress, regulation and frustration are much higher than with regular parenting.

Would you like to know why?

If so, continue reading with an open mind.

Getting Started

Many foster parents already have parenting experience, though many, such as my wife and I did not.  I was quite adept at getting children riled up before sending them home with their parents with the special needs ministry my (old) church has, but had no real parenting experience.  The kids loved me, the parents… well they put up with me because I gave them time away from their children to have a date night.  That was the extent of my parenting experience.

When you first sign up to be a foster parent you go through a bureaucratic anal probe the likes of which is only legal for the state to do.  They want to get to know the most intimate details of your life.  And rightly so.  You may have children who come into your home who have been physically or sexually abused.  So when they ask you if you are a sexually satisfied individual (and they will) or if you are in the middle of an adulterous relationship it actually is the business of the state to know.  Your spouse is not allowed to see your responses and I have heard of instances where a couple is denied a foster license because one of the marriage partners is having an affair and refuses to stop.  The application is denied with the other party not knowing why.

You go through other things like background checks and such, home inspections, fire inspections and a couple of other things.  But no significant problems notwithstanding you get approved and you are on your way to making a difference in these children’s lives.

And then you wait.

During the waiting period you need to keep up with your state training, .i.e. your State Mandated Indoctrination.

Does this training help you to be a  (foster) parent?

Heh, you could be so lucky.  The training is on state standards that you are expected to follow.

For those of you who are parents you may have taken some parenting courses that help you to understand how your child we be developing, dietary needs, when they should be approaching which milestones in their life, etc.  As foster parents we go to courses that teach us how to properly restrain a child.  I’ve had to do it (twice, I think).  Then you have a multi-page form to fill out where you explain what it was about, what alternate strategies you tried, why you thought that the child needed to be restrained.

The  medication training is perhaps the biggest time waste out of all of them.  8 hours of training once per year, probably on a Saturday.  Some people like to take their kids  to the park on the weekend.  Maybe the swimming pool.  Foster parents often spend a decent number of evenings and weekends attending useless training.

During the training I got to learn about the anti-psychotics and psychotropic medications that I probably will never be giving to children in my home.  And I don’t remember any of it.  Actually, that’s not true.  I have taken the course 3 or 4 times and here is what you will learn; 1) read the pharmacy information sheet, 2) lock up your meds.  That’s it. 30 hours of training and that is what I learned, remembered and have implemented.

Then there is the cultural sensitivity training.  This is presumably because a lot of foster parents are white (I have met several black foster parents, but where I live they are mostly white) whereas the population of the foster care system is largely Black or Mexican.  Yes, I didn’t say “Hispanic”.  Very few Spaniards are in the Texas foster care system.

Now, I am white.  I live in the suburbs (yuck! really).  I own a gas guzzling SUV that s bigger than I need (and smile every time I push the accelerator harder than I have to).  I have two big screen TV’s which I brought back to my larger-than-necessary house in my gas-guzzling SUV.  But I started out relatively poor compared to where I am now.  My parents provided a comfortable childhood and I had no want of anything.  But when I left home I lived month-to-month and had to hope that I had enough in the bank to pay rent.  I didn’t go to college but worked hard and eventually got married, moved to the U.S. from my home in Canada, started a business, failed at it, but kept working hard eventually landing some good contract work which led to a good job, which led to recording two albums and writing two books, which led to another job, which led to starting a business, failing at it again and landing another job for a great company.  I had great parents who set me up to be able to work hard and go from my rather modest first shot at living on my own to being relatively successful.

Until my world came crashing down and I found this out about my life


I had been wrong all of those years!  It wasn’t my hard work and long hours after all!

And not only had I received a benefit from racism, I found out that I was racist too!


Now, if you believe that all of this is true that’s fine, I won’t argue with you (you’d be wrong, anyway).  My purpose in writing this is to help you see what things are like as a foster parent.  In our state-based training I was being accused not only of having benefited from racism but as being racist simply because I am white.

Paperwork, Paperwork, Paperwork

Raise your hand if you like paperwork!  Each child requires at least one sheet of paperwork each week that shows daily progress.  These are called progress reports.  You are supposed to note pretty much any thing that happens to the child during that day.  This is because that paperwork is used to determine their level of care.  Their level of care determines what their subsidy is and what services are available to them.  If you get this wrong they may end up being mis-categorized and end up losing out on qualifying for services that they need.

And then you need to have medication logs.  Boys in the foster care system tend to be on medication, especially once they get past 5 years old. And for each of the medications that they are on you have a medication log.  One per medicine per child.  And if you screw up that is called a “medication error”.  And that’s bad.

Oh, and those one page progress reports I mentioned earlier?  That is only if your child is listed as basic.  Moderate and above you have three sheets of paper per child, per week.  In our case it was about 10 pages of documentation each week.

When normal parents have finished their day with a somewhat strong-willed child they might rest.  Read a book.  Watch some TV, maybe.  Well, with foster parents we are often dealing with children who are stealing, lying, fighting, self-injuring and a host of other things before breakfast.  And at the end of the day we do paperwork.

In theory.

In reality, paperwork is the last thing on our minds.  Because of the stresses that the children put you under along with the stress of knowing that what you do is under the eye of the state, at the end of the day you fall onto your bed, turn on the TV and hope that the next day is better.

You just drug the children up to make them more manageable

Yes!  In every way, yes!  Not as a default measure when they come into your house, but yes!

This is because many (most?) children coming into the foster care system are, in many ways, un-manageable.  Consider that these children come from environments where they rule the roost.  Many children brought into foster care were allowed to do anything they wanted as long as it didn’t interfere with what their parents were doing be it Meth, Cocaine, partner abuse or simple neglect.  From a child’s point of view, these kids have it made.  They can eat what they want, drink what they want, sleep when they want, do what they want.  As long as they don’t interfere with the caregiver, they can do anything they want.

My wife and I watched a documentary on Meth abuse several months ago.  The filmmaker got a surprise when a family of addicts allowed them into their house.  They were nice to them and honest about what Meth did to them.  They were actually quite contrite about what Meth had done to their family.  Their kids weren’t well behaved but largely did what they were told.

But it turns out that the parents were high during the interview.  A Meth high lasts about 6 hours and when you crash, you crash hard (apparently).  The parents slept off the high until 11:00 in the morning.

But their children weren’t high.  At 7:00 in the morning, the director cut to the two year old who had just woken up and whose diaper was sagging to his knees.  He walked over to the trash and pulled off some stuff on top and pulled a half eaten bag of popcorn out of the trash.  He also went to the fridge and got out a gallon of milk and did his best to feed himself.  A two year old.

Let’s presume that their parents have now been caught, the children have been removed and placed into a foster home.  Foster homes will probably have some kind of schedule because one or both parents work.  So the children will not be fending for themselves anymore.  They won’t have to dress themselves.  They will have meals at predictable times.  They will get tucked in at night.  They will be read stories.

Sounds like they should just take to it.

But they won’t.  This world is completely foreign to them.  The children have learned that in order to get a parent to do what they want they need to yell, scream, fight and hit.  Siblings do one of two things.  They either fight like maniacs because there is no parent to stop things before they get out of hand or they are incredibly close because they need to in order to simply survive.  Both are actually bad conditions.

The first is bad for obvious reasons.  With no parent to stop things they have not learned how to control themselves and God help you if you get in the way of a child who has needed to be narcissistic in order to survive.

The second can actually be just as bad, particularly for the eldest.  This child’s identity is as the provider for the family.  With the foster parent in place that child’s identity is removed and they, quite literally, do not recognize themselves and can react violently due to that loss of identity.

The way a lot of these issues work themselves out is into various psychological disorders such as Oppositional Defiance Disorder (think of the worst 3 year old ever in a 7 year old’s body), ADD/ADHD or Reactive Attachment Disorder are pretty common.  For boys in the foster care system the ADHD is virtually a given.  Each of those disorders I listed are have some basis in a lack of self control and are reactive in nature.

Drugs help smooth out the highs and the lows; that reactive nature.  It helps them become more manageable both for the foster parent and for themselves.  These children have had years in a toxic environment, the effect of which is often one or multiple behavioral disorders, they were just ripped from the people they love and put them in some strange house that actually has defined rules.  Before that their rules were do whatever you wanted as long as you don’t get beaten.  Now they’re expected to have self-control and they won’t have a fist print on their fact if they accidentally do something wrong.  So compared with the situation they came from, more is expected and the consequence of not doing what you’re told is much less severe.

Weeks, Months, Years

So you get one or more children in your home and it’s a matter of having the parents go through the treatment plan, passing an exam and sending the kids on their way, right?  Not even close.  Remember, many cases that CPS works with involve highly addictive substances.  Or in some cases the parents “really” are trying to get a job but just can’t quite get one that sticks.  But they have good intentions.

All of these things translate to delays.  Lots of delays.

And how much does the foster parent get to know why?  Zero.  For example, say you were planning a 10th anniversary weekend trip to Napa because you were told that the children would be back in their home weeks before then.  But they stay.  Then they stay a little longer.  You ask what is going on and you are told “oh, the parents are still working the plan.”  (You hear that a lot)

Your life is basically on hold while you have foster children in your home.  If you want to leave the state you need to get a judge’s permission.  We never had that request denied but it’s still a pain in the butt.  Say there was a family emergency and you needed to drive to the next state to help out.  You won’t be going until you have permission to take the children with you.  Respite care is, in theory, available.  But that often takes even longer to get than judicial permission.

So you wait and wait with no information about what is going on.  This is actually one of the hardest parts about the whole process.  Then at some point in the future you are told one of two things.  Either a) parental rights are going to be terminated and they are going to start looking for family members, or b) these children who you have been loving and parenting for the past year are going back, probably to a situation that is less than ideal.  If it is termination then family members have 90 days to come forward and claim the children.  Each family needs to get a home study done, which takes several weeks.  And if they pass (they often don’t) then you start preparing the children for their move to the family member.

But if nobody comes forward and the 90 days pass then you, as the foster parent, are first in line.  If you choose to adopt then you get the case file where you find out that the parents weren’t actually “working the plan”.  They didn’t stay clean, they weren’t attending parenting classes (like that would help), they were still hanging around with the people that they got caught with and there really was no chance that the case would be resolved.  But, a year is a year and you wait the year because that is what you are expected to do.

But don’t they love their children?

Ah yes.  Don’t these parents love their children and children need to be with their birth parents?

I have kept every Adoption or Legal Risk broadcast I have received and it is in the several hundreds.  In preparing for this blog post I read through the removal documentation for some of them.  I couldn’t read through them all because of the disgust in reading what those parents did to their children.  Here is a sampling, redacted.

  • Parent was robbing a store while intoxicated and on drugs.  Children left in car
  • Sexual abuse by boyfriend.
    • This comes up a lot.  Boyfriend or family members.  Often the reports provide details of who, where and with what.  Think about what it’s like to read the “what”.
  • Mother tested positive for Cocaine during delivery
  • Neglect, parents engaged in drug abuse and domestic violence (this one came up a lot)
  • Physical abuse (broken bones, burns, cuts)
  • Was pushed on the ground and rolled over by their parent with a stroller
  • Mom threatened bodily harm against a newborn
  • Abandoned
  • Parent convicted of human trafficking

And when I say “sexual abuse” let your imagination run wild.  Think of the worst things you can think of and much of it is in there, sometimes done to babies.


Read that sentence again.


Now, stop and consider that those kinds of things are probably happening to real children within driving distance of your home.  Go to Google Maps, put in your address and look in a circle about an hour or two around your house.  It is likely that in that circle there are several young children who are being sexually abused, more that are physically abused and many more who are neglected due to parental drug use.

This leaves behind all manner of disorders.  Compulsive masturbation.  Post Traumatic Stress Disorder.  Reactive Attachment Disorder.  Self-Harming.  Sexual Acting Out.  Oppositional Defiance Disorder.  Developmental Delays.  Never mind the burns, the scars and the broken bones.

These are not examples I came up with off the top of my head.  I read through several of the broadcasts and wrote them out in that last list.  This is real life for many children.

And during all of this you are supposed to be talking up their parents so the children won’t have a negative view of their them.  You know that woman who was caught having sex with a child molester to pay for the drugs she needs to buy from the drug dealer who is also the father of her first child who isn’t around and now has 4 other children with three other women and who has regularly beaten her for non-payment?  Ignore all that.

Let’s talk about money

Foster parents do it for the money.  Yeah.  To pay for the anti-depressants and therapy you need from dealing with the children (that’s a clumsy attempt at a joke).  A basic child gets you several hundred dollars per month.  Moderate children get above $1000.  Truth be told, yeah, foster parents actually get paid pretty well.  Too much, in my humble opinion.  But I can tell you that from all of the people I know who have fostered exactly none of them (as in zero) did it for money.  None of them needed it.  Outside of our foster group my wife and I had around a half dozen personal friends who were fostering.  None of us needed the money.  In our foster group, none of us needed the money.  We all fostered (and adopted) for various reasons of which money was never even a factor.

It is true, though that many foster parents need the compensation.  But taking a second job is a lot easier than taking on more children.  You have to get to three children or above if you want it to make a significant impact on your budget.

And it still doesn’t cover the cost of hair transplants to replace the ones you’ve lost.

Losing it all

The people who are lowest on the totem pole are the Straight Adoption people.  These are often people who are dealing with infertility, just want to provide a child a good home without going through the pain of fostering.  My wife and I were straight adoption for two years.  We even submitted for a group of 7 children at one point.  Thankfully we were not approved for that one.  But we submitted for several others.  In two years we came close maybe two or three times.  But we never wanted to go the foster route.  We did not want to fall in love with some kids only to have the state place them back with their parents.  Or have the parents fail and then have the kids placed with a relative.

Because, you see, straight adoption families are lowest on the totem pole.  The order goes

  1. Parents
  2. Close Family Members
  3. Out of State Family Members
  4. Current Foster Parents
  5. Satan
  6. Straight Adoption Families

So we decided to switch our status to foster-to-adopt.  We went for a little while but then got a temporary placement with a boy before he was adopted and did respite for some kids.

And then December 24th, Christmas Eve, 2010 came.  We got the call that a baby with a leg cast and a fractured skull needed a home.  I told my wife “my first inclination is to say no”.  I didn’t really want a baby.  But I acquiesced.  We agreed and a few hours later a car arrived.

When most people become parents they have about 9 months to prepare.  Our average time is around 3 hours.

I opened the door for the investigator and he said “here, hold this” (I actually really liked this investigator).   I looked down at “this” and saw the biggest, bluest eyes I have ever seen.  I went from wanting to have nothing to do with babies to being wrapped around her little pinky finger in about 3 seconds flat.  In that moment I became the Dad of a beautiful little baby girl.  She was our Christmas Eve miracle.

She had us both.  It didn’t matter that we didn’t have 9 months of anticipation.  We were so love-struck by this little thing.  We loved her like she was our own.  We got up at all hours of the night to feed her.  We changed her.  We wiped the poop off of her cast (due to physical abuse).  We would sit there and rock with her and just enjoy her presence.

But we knew that we were still just foster parents.  And what do you as foster parents do when you get a child you fall in love with?  You get on Facebook.  You try to find who the parents are.  You try to find out who the relatives are.  You try to figure out which family members are bums and which ones could possibly be a threat to the child.  You check online court documents.

I was actually pretty good at it.  I figured out who the parents, grandparents, baby-dads, former baby-dads, cousins, uncles and aunts were.  And when it comes to people with CPS records, that is not easy to figure out.  I figured out all of the possible avenues that our little girl could be taken away from us.

In all my searching I found only one person who could possibly take our little one away.  But we were told by CPS that there was a person but that nothing really promising was there.

But then on Feb 18 at 10:37 I received a reply to an email to our caseworker asking what happened to the person .  Our caseworker said that she was out but that another person wanted to be considered.  I, quite literally, was on a knife edge.  I was about two seconds away from picking up my desk and throwing it out the front window of my house (no joke).  We had worked through almost all of the potential people and they had all fallen through and then this new one came up.  I tell you the truth when I say that I almost destroyed my office in a fit of rage.

Later the caseworker came to our house for our monthly visit.  The first thing I asked her was “Is it X?”.  Her jaw dropped.  The one family member who I was most worried about was the one who had come forward.

It took about a month but it wasn’t long before our little Christmas miracle was gone.  And we were devastated.  I was in the middle of a work project and I couldn’t leave work, but we held it together for three weeks and made a bee-line for Breckenridge, CO where a very nice couple allowed us the use of their condo to recuperate.  But instead of recuperating we got, ahem, slightly inebriated, and had to head home early.  Apparently if you’re drinking to forget you shouldn’t do it at 10,000 feet.

When you are a foster parent be prepared to be devastated.  Devastation will occur at some point.  This is doubly true if you are hoping to adopt.

As difficult as that was we actually ended up becoming good friends with the girl’s new parents.  We go and visit them any chance we get.  In retrospect, our home was the wrong home for her.  And if she had stayed with us we would not have taken in any more children and we would not have gotten to adopt the kids we now have.  The bitterness is gone and in place is a new friendship with a very good family.  However  the road there was quite dark.

Do you want to be a foster parent?

I hope not.

I really hope you do not want to be a foster parent.

If you want to be a foster parent then you should not be a foster parent.  What happens when your “want” changes?  You need to believe that it is your duty to be a foster parent.  From the state’s perspective we were the worst kind of foster parent.  Our reports were always late, often in-accurate.  We (mostly me) left our training to the last minute and sometimes afterwards.

But from the moral perspective we were the best kind.  For every child who came into our home, few though they were, we committed that as far as it depended on us, we would be their last foster home.  We invested emotionally in their lives and paid deep, deep prices for that investment.  We are emotionally scarred and beaten.    We made ourselves vulnerable so our children can heal, grow and prosper.  We have fallen short of this ideal many, many times (and still do) but we have kept at it.  And we are not unique in this regard.  Every family we know who has fostered has had this kind of attitude.

If you are not prepared for that level of commitment and having your heart broken by child, parent and state, multiple times over, then you should not be a foster parent.

Likewise, if you are unwilling to commit to that level and having your heart broken by child, parent and state, multiple times over, then you have not earned the right to criticize a foster parent when you hear that someone did something horrible on the news.  Foster parents, even the bad ones, have had their life disrupted in ways that you cannot imagine.  They are put under scrutiny and pressure like you will never have to deal with.  Acknowledge those incidents for the evil that it is but know that there is a back story that most probably consists of pain and frustration that will never get reported.

What needs to be done?

That is always the question isn’t it?  “How do we fix it?”  Well, in many ways you can’t.  Evil exists in the world.  Evidence of it fills a folder in my email that has those broadcasts, named “Adoption”.  It will always be there.

But while you can’t fix it here are a few suggestions that could reduce it.

(Actually) do something about poverty

In almost all of the documents I have, poverty is a significant factor.  Not in all cases, but in many.  But the underlying problem in almost all of them is not the poverty itself.  The poverty is a symptom, but it is not the cause.  Almost all of the cases I have in my email folder are people who come from broken families.  In many cases there are not fathers, there are boyfriends.  When there are fathers they are usually not married.  See, what we’ve done over the past 50 years is do our best to destroy the one social institution for which the absence is virtually guaranteed in all of these cases.  You may say that I’m attempting to prove a negative here, and you might be right.  But almost every bit of social science shows that a strong family is one of the best stabilizing factors for children.  I know who my Dad is and where he was for my childhood.  Given the immense effect he had on my life (despite my stubbornness against it) I cannot even imagine the person I would be today if he was not committed to the death to my mother.  And I am committed to death to my children’s (adopted) mother.  My kids will never have to wonder if I will come back if I leave, or if they might have a half-sibling out there (due to me).  Just like I didn’t have to worry about it with my father.  My father worked for his family as I work for mine.  Why?  Because my family is my personal responsibility.

But seldom (if ever) do the CPS treatment plans include this kind of training.  To my knowledge (and I could be wrong) the information about what happens to children when father’s leave them is not presented.  Maybe it is.  But in the training material that, as the foster parent, completed there was no mention of the the stability that a strong traditional family has.  That stability may not solve the problem of poverty; there will always be poverty.  But what it does is keep poverty from being a sentence handed down.  Poverty, itself, is a problem.  But a bigger problem is the recurring chain of poverty.  “Programs” will have only a minimal effect on that.  And given the focus of those programs, if I were a betting man, I would bet that in aggregate they do more harm than good.

Put poison pills in CPS treatment plans

A poison pill is basically a guaranteed consequence.  For example, in Texas parents have a year to get their act together and do their treatment plan with the judge having the option to push it to 18 months if they “just need a little more time”.  But CPS says that if parental rights need to be terminated that they(CPS) have failed.  In that case, they have a 70% failure rate.  30% of removed children go back to the parents and do not re-enter the system after 12 months.  That is the extent that CPS monitors the family.

In the case of drugs they usually need to be clean for a minimum 6 months before re-unification.  Perhaps for something like Marijuana nothing needs to be done (I’m not personally convinced that it should be outlawed, but don’t care much either way).  However for Cocaine, or especially Meth, if they fail after 6 months there is almost no point in continuing.  The Meth relapse rate is officially 92%.  If they fail in that 6 month time period they will likely not succeed at all.  Why put their children through a minimum of 6 months of additional uncertainty?  In our situation the last 6 months were filled with the most promises, the most lies and the most damaging behavior from the children because of that.  While I am personally in favor of re-unification in a general sense, I also don’t think that drawn out treatments that are virtually guaranteed to fail should be pursued.  It’s not fair to the kids, the parents, the foster parents and the CPS workers who have to deal with this.

The other side of this is that most CPS workers are massively overworked.  If there are cases in the system where failure is virtually guaranteed then let’s get those failures out of the way to reduce their caseloads.  One of our caseworkers had 70 open cases.  The CPS case worker has something like a 20-30% turnover rate year over year with most case workers not lasting 5 years.  We really need to make their jobs easier because good case workers are really hard to find.

Put kids in the bestest, quickest home, fast

This notion that kids automatically do better in a family placement is ridiculous.  Several of the cases we were involved in were failed family placements.  But going beyond that consider how far removed someone needs to be to escape the culture of poverty.  The state has what is called Minimum Standards.  For kinship placements, those standards are very low.  Yes, the children may be familiar with the people already (definitely not a guarantee) but that is exactly the problem.  How many of the children in these kinship placements end up being in CPS cases in the future?  I understand that we want to minimize the placement disruption but we can’t do so to the long term detriment of the children.  How many of these children could be truly given a new lease on life by removing them from the culture that would have doomed them.

And do it quickly.  If a caseworker has a file in hand of a willing family who is unrelated and there is an out of state family member who needs to get a homestudy done (who probably has never had significant contact with the children anyway), just give the children to the willing family instead of waiting months to satisfy the mumblings of some psychologist.

Seriously, don’t treat Foster parents like babysitters

As hard as caseworkers have it they have one benefit.  In the 70 cases they have, they have the luxury of not developing strong emotional bonds to the children.  That’s not to say that they don’t feel for them, but they don’t bond with the children in their cases.  Foster parents get emotionally invested in their foster children in a big way.  For babies we are up several times a night to feed and change a child who is not our own.  We deal with children who have behavioral issues that kids from solid backgrounds do not.

Yes, we get paid to do it.  But if a babysitter screws up they might lose a client.  Maybe two.  Foster parents lose their license and quite possibly the ability to adopt in that state and maybe the country.   CPS does not need proof to revoke your license.  The children we eventually adopted were brought to our home because there were “suspicious” bruises from the first foster home.  There was no direct evidence of abuse and there was never any “outcry” but they were removed anyway.

Be careful what you believe about foster care

Remember that reference to Once Upon A Time where the main character was bumped around in the foster care system for 18 years?  Bullshit, I say.  She was a white baby girl.  She would have been adopted before the week was out.  That NCIS shrink who complained about the “cash checkers” who were his foster parents?  1-6 months, depending on his age, level of care and expediency of the court.

Kids get bounced around the system because foster parents get burned out (yes, I am sure that there are negative examples in many cases).  In many cases they have their existing children that they need to care for.  Sometimes they may fear for the safety of their own kids because of the children they are fostering.  Often they don’t have the necessary support.  Often they are simply unprepared for the level of care that these children need.  It is not some diabolical scheme to hurt these kids.  Foster parents get burned out, hard.  Siblings get broken apart because taking on multiple children is an immense drain.  My wife and I took on three at once, whom we eventually adopted.  When you get those kids you are not simply babysitting.  You are taking them into your family.  These kids, at best, will be developmentally delayed.  You will have a 5 year old acting like a 3 year old and a 2 year old acting like a baby.  That is, in every way, exhausting.

Then you also need to work your schedule around parent visits, therapists and home inspections.  Home inspections happen at least once a month by both your agency and CPS.  Parent visits are where you drive the kids to either a CPS office or some other place and drop them off, find something to do for two hours and then pick them up.  The kids are all excited because they got presents and played the whole time, probably getting totally sugared up and you get to hear about how wonderful the bio-parents are for the next day or two.  And parent visits are inevitably followed by a day or two of acting out, whatever that means for the child.  Could be defiance, pooping in strange places or sexual acting out.

Then you have the therapy visits.  When we were doing the most we had at least 5 therapy visits per week.

Foster parents don’t sit through that bureaucratic anal probe with a smile on their face because they like it.  They do it because they really want to help these kids.  Foster care is one of the hardest things you can do.

And you go through it hoping that whatever little contribution you provided will be enough to keep the cycle from repeating.

What is the last event fired in Magento?


What is the first event fired in Magento?


Technically, it’s resource_get_tablename, but the first usable event is controller_front_init_before.

But this is also a bit of a trick question.  controller_front_init_before is ONLY triggered from the global area.  The first usable event in the frontend (or adminhtml) area is controller_action_predispatch.  core_locale_set_locale might also be a possibility because it is set when the area is loaded, but I would say that controller_action_predispatch is still the best, first usable event once the area is known.

4 charts that are guaranteed to make you a better performance detective

I was giving the Magento Performance and Optimization for System Administrator’s course today and I said something that is either borderline brilliant, stupid, or common knowledge.  What I said was something along the lines of “finding performance problems is about finding a) correlations, or b) deviations“.  In other words, a big part of determining a performance problem, especially when using instrumentation data as opposed to reviewing code, a prime goal is to find data that correlates or deviates.

To illustrate this I rendered 4 charts top illustrate what I meant.



What I mean by this is that when you are determining performance problems whose cause is not readily apparent you should be looking for data that correlates either inversely or proportionally (top row) or deviates (bottom row).

What do you think?  We must always grant that there will be cases where this is not true.  However, it seems that it many scenarios finding either a) correlating data, or b) deviating data gets you about 3/4 of the way to discovering the source of a performance issue.

Web Analytics