Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Conlisk 432 posts 1008 karma points
    Apr 02, 2012 @ 13:35
    David Conlisk
    0

    Suggested null check

    Hey Matt,

    Another great package! Very, very useful. I have a site that has been live for over four years and the database size was getting out of hand, so this package is perfect to stop it re-occurring.

    One issue I had was that it worked perfectly locally but not on the live site. I eventually tracked this down to some entries in the cmsContentVersion table which had NULL values for both published and newest columns. This was causing exceptions to be thrown:  

    Data is Null. This method or property cannot be called on Null values.

    Don't ask me how that happened to the data, but I updated your code slightly to make it work for me. Something like this (updated lines 76 and 77 of ApplicationBase.cs to check for null values and default to false):

    var published = reader.IsNull("published")? false : reader.GetBoolean("published");
    var newest = reader.IsNull("newest")? false : reader.GetBoolean("newest");

    (May not be exactly what you need as I was using a different data access method so I'd adapted your code slightly). 

    Cheers!

    David

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    Apr 02, 2012 @ 14:31
    Lee Kelleher
    0

    Hi David,

    You could always fork and submit a pull request? http://unversion.codeplex.com/SourceControl/network

    Not speaking for Matt, (of course), but I'm sure he'd be happy to give you commit/collab rights; given that his hands are full with v5 dev. :-)

    Cheers, Lee.

  • David Conlisk 432 posts 1008 karma points
    Apr 02, 2012 @ 15:50
    David Conlisk
    1

    Good idea Lee - I'll get in touch with Matt directly and see what he thinks.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Apr 02, 2012 @ 15:59
    Matt Brailsford
    1

    Hey David,

    That is bizarr, as I'm pretty sure there should always be at least one item flagged as published on one as newest. If the fix works though, I'd be happy for it to be included. You are more than welcome to have comit rights to the repo. Just ping me your codeplex username. Can add you as a contributor too if you like. Release cycle should be pretty easy as there is a script to build the package file. Just need to increase the version number.

    Matt

  • David Conlisk 432 posts 1008 karma points
    Apr 04, 2012 @ 21:26
    David Conlisk
    0

    Hey Matt,

    Sorry I've run out of time for this, I'm off to Ireland for a week tomorrow. But I'll get around to it when I get back - promise ;)

    Just to clarify, each item had one item flagged as latest and one as published, but there was also an entry where both flags were null - this is where the code fell over for me.

    I'll get in touch when I'm back and get that fix added.

    Cheers,

    David

Please Sign in or register to post replies

Write your reply to:

Draft