• Simplification FTW!

    Comments Off
    31 Aug 2008 /  Software Development

    The little mood icons that appear at the bottom of each post are powered by Cricket Moods.  There was an issue in the current release (3.6) where when a post was updated the moods were re-added.  So I’d be Hungry & Hungry.  Or, worse, Hungry & Hungry & Hungry.  Even I can’t handle that much hungry.

    So I played around with the code.  It seems that if I commented out the “if there are no moods, add the selected moods” line then it worked fine, which would be okay except if there really are no moods then I couldn’t add any…

    It seemed to go something like this (very roughly):

    if ($current_moods)
    {
        // update moods with new selections, if any, or delete if no selections
    }
    else
    {
        // add selected moods, if any
    }

    Which is all very well except that if there were current moods it still seemed to run the code after the else, which surely it can’t do?!

    I played around trying to fix the logic and it still seemed to be doing both if and else of the if-else statement.  Then I was struck by remembering a similar sort of logical issue way back (in C#, I believe).  Not, mind you, where code runs both if and else, but where a logical problem can sometimes be avoided by reviewing what you want to happen and just doing that.

    What I want is for the selection to be set.  If I let it go, it always sets what I select, regardless of whether that’s what was “supposed” to happen or not, even if that means duplicating existing moods.  So, simplify the issue.  Delete all moods, then add the selections.  No checks whether this or that exists.  No comparing arrays.  Just delete all, then add all.

    Works just fine.

    This solution credited to Steve, who gave me the piece of understanding (in that code, way back) that meant I could find a solution even if I couldn’t solve the problem (in the time I was prepared to give this).

    Current Mood:Amused emoticon Amused

    Tags: , ,

  • Fiddling

    Comments Off
    31 Aug 2008 /  This Blog

    I was going to bed 30 minutes ago.  And I stayed up fiddling with the blog settings, just getting that last little bit all correctly configured and in the proper layout.  Doh.

    All in order, now.  I’m off to bed, really this time.

    Current Mood:Tired emoticon Tired

    Tags:

  • Blog Upgrade and Purge

    Comments Off
    30 Aug 2008 /  This Blog

    Well, that’s purged everything from the old blog and given me a clean slate to work with. The majority of posts from here will be private, invisible to everyone but me. I may post some public stuff but I need a spot to drop my thoughts, daily, without any wish/need to vet for suitability. The old posts won’t really be missed, though I do have a couple of different backups in different formats just in case I find a need for them.

    I’ve also purged a lot of the modifications, just reinstalling those I really need or that will help me.

    Total time, around four hours, including some farting around bug-fixing the theme I’m using.

    Current Mood:Busy emoticon Busy