Changing WordPress Settings Directly

A recent update of PHP broke one of my oldest WordPress blogs. It was set up with an offset for the timezone, which is no longer supported. What it looked like was the white screen of death, but enabling debug mode in my wp-config.php gave me some hints.

The first hint that it was something weird is that all of my other blogs, which all run off of the same database, were all fine. I can look at their settings, log into their administration interfaces, change their settings, but my old blog would not load.

After considerable DuckDuckGo-ing, I figured out the setting that needed to be fixed, but because I couldn’t load the administration interface, I could not fix the setting. Access to all of your WordPress settings is inside the database, so I had to figure out how to change that setting directly in the database, preferably without ruining everything.

The option was timezone_string, but if you don’t know how the database is laid out, you have to do some poking before you can get yourself sorted.

All of the options are in a table called options, or in my case, since I have multiple WordPress blogs in the same database, there is a prefix underscore first. I found this by logging into the database engine, navigating to the correct database, and then using the show tables; command.

show tables;
show columns from $BLOGNAME_options;

The next wrinkle was interpreting the results – they lay out the columns vertically, which isn’t very intuitive, since we definitely asked for columns, and they are shown as rows. Still, it is standard, and looks like this:

option_idbigint(20) unsignedNOPRINULLauto_increment

I was then able to figure out that I need to change the option_value for the row with the option_name timezone_string. Since I want to figure out what to change it to, I tried this:

select option_value from $BLOGNAME_options where option_name='timezone_string';

That showed me the problem that I was seeing in the debug messages. Then I looked at the timezone_string from one of the blogs that wasn’t broken, which in that case was “America/Toronto”. Then I finally had enough information to update the option_value to (hopefully) fix my ailing blog. So, I ran this:

update $BLOGNAME_options set option_value = 'America/Toronto' where option_name = 'timezone_string';

And it worked! It took too long, and was stressful and annoying, and made me wish that all of these options were in a flatfile, ’cause doing this with no interface is annoying, and completely beyond the average blog-haver, I think.

If the whole blog is going to go down from a borked option, maybe the blog should load a default set of options and then tell the user which options to fix.

Logitech Marble Mouse

I wanted to use the scroll buttons on my Logitech Marble Mouse. After a bit of poking, I got it to work as I wished. Here’s my xorg.conf file:

# /etc/X11/xorg.conf (xorg X Window System server configuration file)
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
# Edit this file with caution, and see the /etc/X11/xorg.conf manual page.
# (Type "man /etc/X11/xorg.conf" at the shell prompt.)
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
#   sudo dpkg-reconfigure -phigh xserver-xorg

Section "Files"
  FontPath  "unix/:7101"
  FontPath  "/usr/share/fonts/truetype"
  FontPath  "/usr/share/fonts/X11/misc"
  FontPath  "/usr/X11R6/lib/X11/fonts/misc"
  FontPath  "/usr/share/fonts/X11/cyrillic"
  FontPath  "/usr/X11R6/lib/X11/fonts/cyrillic"
  FontPath  "/usr/share/fonts/X11/100dpi/:unscaled"
  FontPath  "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"
  FontPath  "/usr/share/fonts/X11/75dpi/:unscaled"
  FontPath  "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"
  FontPath  "/usr/share/fonts/X11/Type1"
  FontPath  "/usr/X11R6/lib/X11/fonts/Type1"
  FontPath  "/usr/share/fonts/X11/100dpi"
  FontPath  "/usr/X11R6/lib/X11/fonts/100dpi"
  FontPath  "/usr/share/fonts/X11/75dpi"
  FontPath  "/usr/X11R6/lib/X11/fonts/75dpi"
  # path to defoma fonts
  FontPath  "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"

Section "Module"
  Load  "i2c"
  Load  "bitmap"
  Load  "ddc"
  #Load "dri"
  Load  "extmod"
  Load  "freetype"
  Load  "glx"
  Load  "int10"
  Load  "vbe"

Section "InputDevice"
  Identifier  "Generic Keyboard"
  Driver    "kbd"
  Option    "CoreKeyboard"
  Option    "XkbRules"  "xorg"
  Option    "XkbModel"  "pc104"
  Option    "XkbLayout" "us"

Section "InputDevice"
  Identifier  "Configured Mouse"
  Driver    "mouse"
  Option    "CorePointer"
  Option    "Device"    "/dev/input/mice"
  Option    "Protocol"    "Auto"
  Option    "Buttons" "4"
  Option    "EmulateWheel" "true"
  Option    "EmulateWheelButton" "8"  #Option   "Emulate3Buttons" "true"

Section "Device"
  Identifier  "nVidia Corporation C51 [GeForce 6150 LE]"
  Driver "nvidia"
  #Driver   "nv"
  BusID   "PCI:0:5:0"
  Option "SWcursor"

Section "Monitor"
  Identifier  "Generic Monitor"
  Option    "DPMS"
  HorizSync 28-84
  VertRefresh 43-60

Section "Screen"
  Identifier  "Default Screen"
  Device    "nVidia Corporation C51 [GeForce 6150 LE]"
  Monitor   "Generic Monitor"
  DefaultDepth  24
  SubSection "Display"
    Depth   1
    Modes   "1680x1050" "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth   4
    Modes   "1680x1050" "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth   8
    Modes   "1680x1050" "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth   15
    Modes   "1680x1050" "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth   16
    Modes   "1680x1050" "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth   24
    Modes   "1680x1050" "1024x768" "800x600" "640x480"

Section "ServerLayout"
  Identifier  "Default Layout"
  Screen    "Default Screen"
  InputDevice "Generic Keyboard"
  InputDevice "Configured Mouse"

Section "DRI"
  Mode  0666

More on screen

While I don’t have a screen for a graphical user environment (like X), I do have screen for the terminal, and it rocks.

Here’s how I use it; I have four primary email accounts, each with their own .muttrc. I open a screen session for each account, plus one session as a scratch pad, for the variety of non-mail activities that I do each day. (If you’re thinking that one session for all non-mail activities is too few, you’d be right most of the time, but I have a solution for that too.) I start all of these sessions by calling screen with a special config file, which I call .myscreenrc, to separate it from the regular .screenrc. It looks like this:

autodetach on
shell -$SHELL
screen -t scratch
screen -t uoft u
screen -t nerd n
screen -t witteman w
screen -t woolgathering wg

The -t option givens me a title for each session within screen – which helps me keep everything straight. I call this with a line in my .xinitrc, like so:

sleep 1 && urxvt -geometry 80x56+0+0 -e screen -c .myscreenrc &

The delay helps it come up after my backdrop is drawn, so I don’t have a blank behind my transparent terminal.

All of this is now nicely set up, and I am in mutt (the last email account). I hop between instances in three ways: Ctrl-a " for a list of sessions to scroll through, Ctrl-a ' and the number of the session I want to be in or Ctrl-a n or Ctrl-a p for the next and previous session. If I need a fresh session, it’s as easy as Ctrl-a c.

There are a couple of problems with this setup. The mutt sessions only lasts as long as mutt is open, so if my fingers, from long training, close mutt, then I lose that session as well, and I have to start it afresh. The solution, rather than training my fingers, was to prevent mutt from closing. I remapped q in the browser and index modes to be the equivalent of c?, which means that I can only close mutt from the pager by hitting x. Fine by me, and it lets me have long-lived sessions.

Now, whether I am sitting at my machine or ssh-ing in from work, I have all the same things at my disposal, and I can comfortably leave aspects of my work open when changing locations. If I have left my sessions running at home, I simply call screen -x when at work, and I am in my familiar environment. If I have detached at home then screen -r is the right call.

However, if I have detached at home and stopped my X session, I run into the other problem. When I started screen via my .xinitrc I also set the $DISPLAY variable in each session. As such, when I am logged in remotely without X running, certain programs throw errors because I am not able to reach the X session. The sidestep for this is to unset DISPLAY if I am going to be using programs that care about that variable, most notably vim.

It sounds like work, but it is actually extremely sweet, and really easy.