Running Progress

In early November I set a new goal to hit 500km in running before the end of the year. That meant that I have to run 25km per week to get there. In the beginning I was doing very well, lately I seem to be making it to the end of the week and having to put in a longer run to make the 25km.

Even though I’m pushing it to close to the end, I’m still getting it done. Today I ran 10km and with the three other 5km runs I had this week I just barely hit my 25km. November I made it to 103km, which took me to just over 400km since July. That means just under 100km again for December and I’m there.

running-goal

I’ve quite enjoyed this goal as there’s no set number of runs or pace that I’ve given myself, just get in the distance. For the most part I’ve been enjoying the runs. I just need to get back ahead of things so I’m not feeling the pressure at the end of each week.

One Year Automattic Anniversary

Today marks my one year anniversary at Automattic! For most people that probably doesn’t seem like a very big deal but for someone like me it really is. My first “real” job was when I was 16 years old which was 20 years ago. Before that I had summer jobs, things like my paper route, and odd jobs around the neighbourhood. In that time I’ve worked for quite a few different companies. The longest time I’ve stayed in one position was fourteen months. Even though I really enjoyed that position and the people I worked with I was already looking for my next move about halfway through.

Automattic is different, at the year mark I’m not checking job banks every day or searching online for that next opportunity. In fact I really feel like I’m just getting started here. So much more to learn, so much further to grow, and so much more to contribute.

The year I’ve been here has been an exciting for Automattic as well. Building, launching, and just recently releasing, as open source, Calypso. It’s a whole new interface to work with your sites. When I started a year ago there were under 300 employees and now today we are over 400. That included the acquisition of Woo!

Automattic has given me so much. My first trip outside of North America to a team meetup in Barcelona. My home office setup is pretty amazing. My new wardrobe full of clothing with the WordPress logo on it. A trip to the Grand Meetup in Utah to spend a week with our entire company. This was an incredible experience. Freedom and flexibilty, being able to schedule my time off and days around the rest of my life has helped provide a great work / life balance. Endless learning, I’m still learning new things all the time and I’ve just barely scratched the surface of the different teams that I can rotate to and spend time learning and helping on. Confidence, it took a while to feel like I actually belonged with all the other smart, amazing co-workers and that I might be able to offer the support and help others had given me.

In this year I’ve started to give back as well. Since starting I’ve had thousands of interactions with the people who directly use our products. Helping them use and learn our products while also getting their feedback to help make things better. Watching Calypso being developed and being able to help test and troubleshoot features as they were being built was very rewarding. Probably the most rewarding though, as much as I never thought I’d get to this point, is the fact that I’ve been able to be a buddy to new employees starting out including helping with their training.

Fairly early on when I was doing a lot of live chat I built a tool that I could use to track my productivity. I found it useful so I made it available for others to use. It doesn’t get a lot of use, but there are still people who do use it. Along the code route I, with a lot of help, added a very small addition to an internal tool that was helps us communicate a bit better.

Currently I’m working on organizing a series of hang outs where developers can answer questions about key features or products so us Happiness Engineers can better support them and better understand how they work. We’ve had one so far with more to come.

There are still many things I have to improve and get better at, but I’m looking forward to it. With my co-workers and team mates there is so much I can take away from each one of them to make myself better and more productive. In this past year, and only spending very little time in person with them, I already consider many of them friends. Even though it is just here in my house I look forward to going to work and interacting with them.

Thank you to everyone that has made this past year one of the best of my life all around. To those who took a chance on hiring me, training me, mentoring me, and just being there for me in general, my hope is that you’re not disapointed in your decision and that I’ve been worthy of your efforts. If I have it my way, and if Automattic agrees, this will just the first of many anniversaries as I know there is still so much that I can learn and in return also contribute.

Christmas Tree

Our Christmas Tree from lot to decorated.

WordPress Menus and PHP max_input_vars

Yesterday I spent a bit of time becoming better familiar with how WordPress menus work. Particularily how they are stored in the database and how PHP’s max_input_vars setting can come into play.

While helping a friend try to troubleshoot and figure out some performance issues on her WordPress site I also went in to add an item to the main menu of the site. That’s when things took a turn for the worse. The menu is fairly large and uses a theme which includes a mega menu. So already there were over 100 menu items added to the main menu, but only main items and then many that fall in fancy drop downs. That’s why when I added the item, pressed save, and only about 60 menu items were left when the page refreshed I was a little paniced.

As it turns out it also neglected to save the theme location for the menu which caused the theme to display the default menu which is just a list of all pages all as main headers. As you can imagine over 125 menu items filling the screen didn’t look the best on a live site. I tried setting up the menu again and adding in the missing menu items, but when I saved the same thing happened. It’s like it made it to a certain part in the menu and just stopped saving. After some research that’s exactly what happened.

Luckily there as been a lot written about with tips on how to fix it. But before I got there I was just focused on how to get the menu working again and have the site look right. I found that in working with the menu from the Customizer instead of in WP Admin I was able to get all the menus to save. The only problem was the mega menu that was built into the theme added a setting where you enabled the mega menu drop down but it was only in WP Admin, the setting wasn’t there in the Customizer.  This led me looking through the database to see how the menus were stored to see if I could enable the setting there.

The following goes over how menus are stored by default in a fresh install of WordPress 4.3.1, default theme Twenty Fifteen with a simple menu I created. Things were different on the site I was working on because of some extra settings which were added by the theme, but the main concepts stand.

Simple Menu

Menus have settings saved in a number of tables in the database. In this example I used the default database table prefix of wp_ so that’s how all tables are named. We’ll start in wp_terms which holds the name of the menu. You can see the name, the slug and the term_id which will come into play.

wp_terms Table

Here are most of the main settings you can choose for a menu item.

Menu Item Settings

Each menu item is saved in the wp_posts table with the post type set as nav_menu_item. There are more fields in this table by default, but I’m only showing the ones we’re really interested in for menu items.

wp_posts Table

A number of the settings are stored here for a menu and you can see how the settings in WP Admin map over to the fields in the database table. Depending on the type of menu item the post_name and post_title will hold different settings. The rest of the settings are stored in the wp_postmeta table. Here is an image for just one menu item. This combined with the wp_posts table tells us that the menu item with post_id 8 which is the second item in the menu is a post_type menu item and it points to a page with the post_id of 4 and it has no parent item so it is a main heading in the menu.

wp_postmeta Table

Here is a look at more settings for other menu items as well.

wp_postmeta Table

You can see the rest of the settings here and differnt types like custom links which have a url, and the sub menu items which have a parent id showing which item the fall under in the menu. If you look back to the image of the menu, and the settings image you can see them all shown here.

It was in the wp_postmeta table where there was an extra setting for each menu item that could either be set to active or blank. That specified if a main heading item in the menu should format itself as a mega menu. Finding this I was able to go in and set it manually by editing the database field needed so that the appropriate ones had the mega menu setting active.

The one other table that menus live in is the wp_term_relationships. It takes the term_id from the wp_terms field and ties each of the menu items id’s to show that they are part of that menu.

wp_term_relationships Table

Now that I had the menu working and looking the way it should I could spend the time to find out what was causing all the menu items to save. It really comes down to php settings. There is a setting called max_input_vars in PHP. On my hosting provider the default value of this is set to 1000. What this means is that when you submit a form to PHP to handle it will only process a maximum of 1000 form fields. Once it gets there it just ignores the remaining. If your hosting provider has the PHP security feature suhosin installed there would be an additional two settings called suhosin.post.max_vars and suhosin.request.max_vars as well which essentially do the same thing.

In the image above you can see that visibly each menu item has seven form fields associated with it. There are also some hidden form fields. If you look at the source code generated for a single menu item you can see there by default 13 form fields.

Menu Item Form Fields

That means to reach the maximum of 1000 input variables it would only take 77 menu items. That doesn’t even include the other form fields that make up the menu page. It took even less than that in the site I was working on as the theme added extra fields to each menu item as well. This also explains why I was able to save the menu using the Customizer because it was only showing a few fields for each menu item, so it was still below the max_input_vars setting.

As my test menu in this example only has a few items to test I set the max_input_vars to be 50 and then saved the menu. This was the result. It only saved 4 menu items, and you can see it no longer has the theme location setting saved below either.

Cut Off Menu

Now knowing what the problem is I knew how to fix it and what I did to cause it to stop working on my friends site. As part of the performance enhancements I was trying to do I changed her server to use PHP version 5.6 instead of version 5.5. The max_input _vars had been set to 5000 for version 5.5 but was a lower default for version 5.6 and I didn’t notice. So making this change fixed things so I could once again save the menu.

To make the change it is just a matter of editing the php.ini file that holds all the settings. For me the setting wasn’t in the file so I just added it with the value of 5000 that I wanted. If the line was there you can just edit the number to be higher.

php.ini

Depending on your host there might be other ways to change this through a control panel, or you may need to contact them directly. Running the phpinfo() function you can see what the value is currently set to as well as the location of the php.ini file is so you can edit it if you have access.

phpinfo

As I mentioned before there is quite a bit written about this where people have run into problems saving menus, but in my reading I didn’t see an explanation of what that max_input_vars setting really means and why what seems like a lower number of menu items might trip that limit even if it seems high. Since I dug into the database I figured I would include that in here as well. Hopefully this is helpful to someone if they run across it in the future.

 

Getting in the Christmas Spirit

Today I started out a little bit on the cranky side. There was no real good reason for it except that I knew it was going to be a busy day and I was feeling rushed already. Before I had even finished my morning coffee I had to start hurrying so that we could get out the door to Noah’s basketball practise. Throughout the day though it didn’t take too long for my mood to start to turn. It’s hard to be cranky when you’re watching your son have a blast and trying hard at something he really enjoys.

When we were done we headed straight to what has become our traditional upick Christmas Tree lot. The weather was a little drizzly, but it wasn’t too cold and we were able to find the tree really quickly. Pretty sure we didn’t spend more than 5 minutes until we had one we all liked. In years past we’ve had some long adventures roaming through the trees in snow and cold weather. So coming across something we all agreed upon so fast was more of a treat than the hot chocolate and candy canes we enjoyed in the cabin with the wood stove keeping us warm.

Once the tree was in the house we figured we would leave it wrapped for a bit while it dried out. The rest of the family were having an early lunch before some of them headed off for a birthday party, I took the opportunity to go get a wet run in. The past couple weeks I pushed it to the last day of the week to hit my goal of 25km. Today I had to put in an almost 9km run to get there. Despite the rain, that at some points was feeling pretty hard, the run was very enjoyable. Such a good time to think and just clear my head.

While half the family as off at the birthday party Alexandria and Caile started decorating the artificial tree that we put up in the kids play room. Just the harder things like the lights and the sinamee. The rest the other kids will help with another day.

After supper Caile and Ella were in a Christmas parade with a bunch of other kids from their dance studio. We were able to get together with friends and family and watch the parade with my girls dancing past.

Once home we untied the tree and straightened it up a bit so Jen could get started decorating. The kids were drinking some hot chocolate, I put on my favourite Christmas album while having a sort of cafe mocha. Now sitting here with the Christmas lights, the smell of the tree, the sound of Meaghan Smith, and the taste of the warm drink there is no denying the Christmas spirit has arrived.

Old Car Problems

For a couple minutes today I thought I might be running home unexpectedly. Luckily after calming down a bit and thinking things through I figured out how to avoid that.

Previously I wrote about how I love my old car, and really I still do. However not sure I would trust it as our only vehicle anymore. It has some electrical issues and isn’t always reliable. When Caile and I came out to and hop in the car to go home it just wouldn’t start. Before I started thinking I immediately thought I had left the lights on again and killed the battery. This has happened a number of times since the buzzer stopped working to warn me when I leave them on. That didn’t end up being the case and we started noticing a slight electrical burning smell. That can’t be good.

At this point I figured it was something serious so I called Jen and asked her to turn around and come back for Caile and I would try to figure out what was going on and if I couldn’t I’d run home. After processing things for a bit I realized I was getting power no problem so I didn’t need a boost. The only thing was is the car wouldn’t turn over. I wasn’t even getting a click of the ignition when I turned the key. In my head I have it narrowed down to the starter or ignition switch neither of which I’m going to do anything about here in the parking lot.

When Jen got back she jumped behind the wheel, put it in gear with they key on and the clutch in. The kids got a big kick out of watching me push the car to get it moving. Jen let go of the clutch and it started right up. She followed me home just in case but it drove no problem. Now it’s home where I can figure exactly where the problem is and hopefully fix it up myself. It’s been a long time since I’ve bump started a car like that.

Since I last wrote about my car I’ve probably put around $1000 into repairs into it which is cheaper than a car payment, but I’ve also spent time without having the car which can be very inconvenient. If I could afford a new one right now I’d probably do it just for the reliability aspect. It would also make it easier to plan financially without havin unexpected repair cost pop up. But for now I’ll keep fixing it up until it gets to a point where the cost to repair is just to high to make sense.

Where Has The Time Gone?

For those of you not in Nova Scotia we have both a vehicle registration that has to be renewed every two years as well as a safety inspection by a mechanic every two years.

The end of November is when our registration was due to one of our vehicles. Today my wife went online and paid that fee shortly before she left to pick up the kids from school. On her way she called me, guess what I looked at our inspection sticker and it ran out in August. I questioned her about it and she responded, yeah it’s marked off as expiring in August 2016. I can’t believe we let it go this long.

My reply was well if that one is expired than so is my car. I knew the registrations were opposite years for the two, but the inspections were the same year. She called and booked an appointment to get it inspected for tomorrow.

Shortly after Jen arrived home I had to leave to pick up our oldest at school so I hopped in my car. Before I left I looked at the sticker and said to myself, wow she was right it does expire in 2016. Wait a second. Back into the house I went. Jen a couple of things, are you able to pass me my phone I forgot it on the counter? Thanks, next what year is it? She replied, 2015. Right. Slight pause.

Somehow we both managed to skip ahead a year. So instead of being really late for our inspections we would have been quite early instead. Luckily we had to get something done to the vehicle anyway so we just changed the appointment with the mechanic to cancel the inspection part.

Stressful Couple Weeks

Glasses seem to be a common thing in our family. Jen wears glasses for some things, for the past few years I have worn glasses pretty much all the time, Caile now wears glasses, and Alex did wear glasses when she was younger to help with an eye turn. So even though Ella hasn’t had any problems with her eyes yet we figured we should get her a proper eye exam.

She was pumped for the idea, in fact she hoped she would have to wear glasses. She counted down to the day of her appointment. Everything went great, but they did determine that she measured about +3 far sighted. However her eyes were able to pull things in to focus so she was still able to see everything. In fact when they had her test through lenses that matched her measurement it made things worse for her.

We ended the appointment where they gave us some of the pupil dialating drops to take home and take before a follow up appointment. They wanted to test her with her eyes relaxed to see what she could read at that point. Figuring it would be closer to what their measurements showed. Shortly after getting home though the Doctor called and told Jen that she hadn’t wanted to say anything in front of Ella but she had seen what looked like could be swelling near her optic nerve. It could be something called drusen, or something causing pressure behind the nerve. They referred us to an Ophthalmologist who works in the same building for further tests.

At this point Jen and I were pretty nervous and feeling a bit of stress wondering what could be wrong and what it would mean. Sometimes with all it’s resources the internet can be scary for situations like these. Luckily we received an appointment fairly quick and this past Friday we went in for some more tests that would be shared with the Ophthalmologist. This included more imaging of her eyes and a field of vision test. The whole time with all these tests Ella is being a champ and very interested in what’s happening and all the cool machines. Seeing the back of her own eye in a picture was one of the highlights.

We had another appointment booked for the 24th to see the Doctor and so he could run some more tests and give his diagnosis. Not knowing what was actually wrong is probably the worst part, but I was doing OK. During the last round I heard them saying that some things looked good and she was doing well etc. So when I was out for a run this morning and Jen wrote me to say the office had called and asked if we could bring her in today because they wanted to see her, that’s when all kinds of horrible thoughts and worry started going through me.

Once I was home and clean I picked her up from school and took her to the Doctor’s office. We had a fair amount of waiting and some more tests. Finally the Ophthalmologist came in and gave asked about the results of the last tests and perform his own visual inspection while her pupils were dialated and eyes relaxed. When he was done he was pretty certain that there wasn’t any actual swelling at all. It looked like things were swollen but that it was tissue and the way the nerve was looked like there was swelling because of it. Being far sighted as she is he said that it all fit. Given she has no eye or neurological problems he was confident everything was fine. The next step would be to do an MRI or a Cat Scan to get a better look to be 100% sure, but he said if it was his daughter he wouldn’t and would instead just keep an eye on it to make sure things stayed as they are. To top it off because she has no eye turn and her eyes are able to compensate so she can see fine, she isn’t even getting glasses at this point.

With great deal of relief we booked a follow up appointment for two months out so he can see her again and make sure all is still good. It is amazing how much stress and worry can take out of you. Even after being hit with the feeling of relief, my brain was scrambled for the day. It wasn’t just my mind though, I was physically exhausted as well. Thank goodness I’m starting to feel normal again now tonight, but I’m looking forward to waking up tomorrow fresh with the good news we received firmly settled into my thoughts.

Good Company

Over the past couple days since seem to have been drinking a lot of Tim Horton’s coffee. While the coffee isn’t great the company was awesome!

   
 

Razor

When I first sat down to write this post it was going to be a funny little anecdote about how I’ve never bought myself a razor. Up until very recently I’ve only had one razor that I’ve used for about the last 20 years. It came in a Christmas stocking a long time before I would ever have to use it. Just this week I received in the mail a free razor from Harry’s that a friend gifted to me.

With the book I’ve been reading I’ve been thinking a lot about shame and some of the things that trigger it for me. Remebering back to when I received my first razor brought back some tough memories. One section of the book talks about the different things which trigger shame for men and women. One of the big categories for women was looks and appearence. This didn’t seem to be as big for men, which given our society, was not surprising to me. This doesn’t mean that men can’t be shamed for their appearance though.

The razor was a gift I received around the same time a lot of my friends were begining to shave. As I mentioned it was a long time before I ever had to use it. The exact time has escaped me, but probably close to a couple years at least. To this day I don’t have a lot of body hair. This led to being made fun of a number of times. It even effected the clothes I would wear. Despite hot weather I would never wear shorts to school because I was embarrassed by the lack of hair on my legs. People would question it and I would just say I didn’t like shorts.

One hot summer day with a planned day of mountain biking with friends I did wear shorts because I knew we would end up very hot and likely in water. Besides I was going to be around friends who really wouldn’t care one way or the other. One aquaintance, who I didn’t expect to be there, upon seeing me in shorts took one look and said I can see why you don’t like shorts, you have girl legs.

Looking back there are obviously a number of things which are ridiculous about that statement. Why should anyone be made fun of for something like body hair? Why is it an insult to considered feminine in any way? Why did I let anything this person said have any effect on me?

It pains me that as a society we haven’t made more progress in the last two decades to the value that we put on looks. The fact that my children have to grow up where things like this still matters is beyond frustrating. All we can do is try our best to help them grow up with enough self confidence, and to value people for who they are, that they are resilient to these sorts of views.

Of course there are larger concerns with everything going on in the world these days. If we could all learn just to accept people for who they are and treat everyone with respect, regardless of how they look or the God they believe in, the world would be a lot happier place.

There are still many ways I’m self conscious when it comes to my appearance, but I’m working on it and getting better. Thankfully my lack of body hair isn’t one of the things that bother me anymore. If anything I’m glad I can get away without shaving for a few days at time. It’s probably one of the main reasons I was able to keep the same razor for so long, it didn’t get much use.