Copied to clipboard

Flag this post as spam?

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


  • Mads Jørgensen 74 posts 226 karma points
    Apr 25, 2013 @ 11:49
    Mads Jørgensen
    0

    v.6.0.4 MNTP issue

    Hey, got this error whenever editing my mntp's that has been imported from an old site.

    Server Error in '/' Application.

    Input string was not in a correct format.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.FormatException: Input string was not in a correct format.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [FormatException: Input string was not in a correct format.]
       System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12636309
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +224
       umbraco.editorControls.MultiNodeTreePicker.MNTP_PrevalueEditor.<get_StartNodeSelectionType>b__10(PreValue x) +49
       umbraco.editorControls.MultiNodeTreePicker.MNTP_PrevalueEditor.GetPreValue(PropertyIndex index, Func`2 output, T defaultVal) +170
       umbraco.editorControls.MultiNodeTreePicker.MNTP_PrevalueEditor.OnLoad(EventArgs e) +582
       System.Web.UI.Control.LoadRecursive() +71
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Control.LoadRecursive() +190
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

     

    From old experiences it could very well be the sort order of the prevalues wich is f****. Belive it's something about them being cool when created by API, but all sort order 0 when edited via interface. Dunno if it's totally correct, but has heard some stuff like that lately :-)

     

    Hope it can be solved :-)

  • Mads Jørgensen 74 posts 226 karma points
    Apr 25, 2013 @ 11:50
    Mads Jørgensen
    0

    Working XML:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <DataType Name="test mntp" Id="7e062c13-7c41-4ad9-b389-41d88aeef87c" Definition="7f26e482-fa58-4ecd-9e04-8786d1d67fae" DatabaseType="Ntext">
    <PreValues>
    <PreValue Id="60" Value="content" />
    <PreValue Id="61" Value="" />
    <PreValue Id="62" Value="2" />
    <PreValue Id="63" Value="True" />
    <PreValue Id="64" Value="0" />
    <PreValue Id="65" Value="0" />
    <PreValue Id="66" Value="0" />
    <PreValue Id="67" Value="False" />
    <PreValue Id="68" Value="0" />
    <PreValue Id="69" Value="1" />
    <PreValue Id="70" Value="" />
    <PreValue Id="71" Value="100" />
    <PreValue Id="72" Value="1" />
    </PreValues>
    </DataType>

    Buggy XML on a MNTP

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <DataType Name="ThemePicker" Id="7e062c13-7c41-4ad9-b389-41d88aeef87c" Definition="a3eb93f7-0812-4cc9-83d1-c226622451b5" DatabaseType="Ntext">
    <PreValues>
    <PreValue Id="58" Value="0" />
    <PreValue Id="43" Value="content" />
    <PreValue Id="44" Value="/*[self::ThemePage]" />
    <PreValue Id="45" Value="1" />
    <PreValue Id="46" Value="True" />
    <PreValue Id="47" Value="0" />
    <PreValue Id="48" Value="1" />
    <PreValue Id="49" Value="0" />
    <PreValue Id="50" Value="False" />
    <PreValue Id="51" Value="0" />
    <PreValue Id="52" Value="1" />
    <PreValue Id="53" Value="100" />
    <PreValue Id="54" Value="0" />
    </PreValues>
    </DataType>

     

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 28, 2013 @ 15:12
    Kevin Jump
    0

    Not sure if something has changed in uComponents between versions, the buggy XML contains one more prevalue and works if you remove the top prevalue 

    <PreValue Id="58" Value="0"/>

    Not sure how that's been created, might be a different version of uComponents had a different set of prevalues ? and when the new version reads the file it is expecting it in a different order?

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 28, 2013 @ 15:27
    Kevin Jump
    0

    the MultiNodeTreePicker in umbraco and the one in the last few versions of uComponents all expect TreeType "Content"/"Media" to be the first value, I can't go back far enough to see when this changed - it would be good to now what version the old MNTP is in ?

  • Kenn Jacobsen 133 posts 791 karma points MVP 4x c-trib
    Apr 29, 2013 @ 08:36
    Kenn Jacobsen
    2

     

    Hmmm best stick my nose in here :)

    I've done a similar tool to enable our continuous integration flow to run more smoothly. And I ran into the exact same problem with the MNTP prevalues. 

    I haven't had a look at your code, but I can tell from your XML format that you're doing much the same as I am when importing data types. 

    The bad XML has had a prevalue added as the first prevalue (ID 58, value "0") and it's missing the prevalue with ID 70 (value "") from the working XML. This used to happen in my tool as well, and what I found puzzled me: For some reason, the sort order of prevalues is overwritten when creating or updating datatypes using the backoffice. Since the datatypes are relying solely on the order of the prevalues when initializing the backoffice, this is kind of silly; this means that the order in which the prevalues are written to the database (their primary key) determines the order in which they are passed to the datatypes.

    Again I'm guessing here since I haven't seen your code. But my guess would be that you import the datatype prevalues in the order they're written to the XML file. So you need to be absolutely sure you're writing them in the correct order. Since we obviously need to take sortorder into account (in case it should actually work) and also need to use the primary key ID for sorting, I'd do something like this when exporting prevalues:

    private static List<PreValue> GetPreValues(DataTypeDefinition dataType) {
    return PreValues.GetPreValues(dataType.Id).Values.OfType<PreValue>().OrderBy(p => p.SortOrder).ThenBy(p => p.Id).ToList();
    }

    On a side note, you might want to use the built in import/export support for datatypes if you're not doing so already (and if I read your XML correctly you might not be). Have a look at

    • DataTypeDefinition.ToXml(XmlDocument xd)
    • DataTypeDefinition.Import(XmlNode xmlData)

    For creating datatypes that do not exist in the target database, this should probably be your preferred solution.

    Oh - and please note that everything I just wrote has only been tested on version 4 (but it works on all versions form 4.7 through 4.11.x).

    Regards,
    Kenn 

     

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 29, 2013 @ 09:59
    Kevin Jump
    0

    yes uSync uses ToXML and Import at every opertunity (i am a lazy dev) - However for DataTypes is doesn't actually use the Import function because the one in the Core doesn't work when called for an ApplicationStartupHander event (others do - one of the core's little quirks).

    Looking at the ToXML function in DataTypeDefinition (http://umbraco.codeplex.com/SourceControl/changeset/view/b03c1fb77762#src/umbraco.cms/businesslogic/datatype/DataTypeDefinition.cs) it doesn't attempt to get them in sort order - so i will probibly end up writing my own one of them too : ( 

    If i can reproduce this error using the Package Create / Import in Umbraco i will log it on issues.umbraco.org 

     

     

  • Kenn Jacobsen 133 posts 791 karma points MVP 4x c-trib
    Apr 29, 2013 @ 10:11
    Kenn Jacobsen
    0

    It actually does attempt to get them in sort order - PreValues.GetPreValues() does sort by sortorder (http://umbraco.codeplex.com/SourceControl/changeset/view/b03c1fb77762#src/umbraco.cms/businesslogic/datatype/PreValues.cs) - but if they're all zero'd it doesn't help much.

    Let me know if you need any help reviewing or fixing this issue for your importer.

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 29, 2013 @ 10:15
    Kevin Jump
    0

    yea it gets them in sort order but not also id order :( oh well. I'm basically just going to copy the umbraco ToXML and add the your line above. but it's always good to have an extra pair of eyes on the code.  :) 

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 29, 2013 @ 22:46
    Kevin Jump
    0

    new version (1.2.0) of uSync is now on this site and attempts to save values in id order - this should fix this issue. 

  • Kenn Jacobsen 133 posts 791 karma points MVP 4x c-trib
    Apr 30, 2013 @ 07:34
    Kenn Jacobsen
    0

    Cool, I hope you could use my input :)

    I haven't tested it, but I hear one of my colleagues is going to.

  • Kenn Jacobsen 133 posts 791 karma points MVP 4x c-trib
    Apr 30, 2013 @ 08:29
    Kenn Jacobsen
    1

    ....hmmm sorry but it looks like it's still not working as intended in 1.2.0.

    I had my colleague test it out and the same thing happened; the MTNP was imported correctly on the target site, but as soon as it was accessed and saved, the prevalues messed up and caused a YSOD.

    This time I was there to look him over the shoulder and after trying back and forth a few times without luck I went to have a look at the database. And I think I've found the error.

    The XML being imported looks like this:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <DataType Name="Convention picker" Id="7e062c13-7c41-4ad9-b389-41d88aeef87c" Definition="f589fbb9-7429-418b-8ff5-ad019aa12d64">
      <PreValues>
        <PreValue Id="51" Value="content" />
        <PreValue Id="52" Value="/*" />
        <PreValue Id="53" Value="-1" />
        <PreValue Id="54" Value="False" />
        <PreValue Id="55" Value="0" />
        <PreValue Id="56" Value="1" />
        <PreValue Id="57" Value="1130" />
        <PreValue Id="58" Value="False" />
        <PreValue Id="59" Value="0" />
        <PreValue Id="60" Value="1" />
        <PreValue Id="61" Value="" />
        <PreValue Id="62" Value="200" />
        <PreValue Id="63" Value="0" />
      </PreValues>
    </DataType>
    

    After accessing the imported MNTP, the exported XML looks like this:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <DataType Name="Convention picker" Id="7e062c13-7c41-4ad9-b389-41d88aeef87c" Definition="f589fbb9-7429-418b-8ff5-ad019aa12d64">
      <PreValues>
        <PreValue Id="211" Value="0" />
        <PreValue Id="199" Value="content" />
        <PreValue Id="200" Value="/*" />
        <PreValue Id="201" Value="-1" />
        <PreValue Id="202" Value="False" />
        <PreValue Id="203" Value="0" />
        <PreValue Id="204" Value="1" />
        <PreValue Id="205" Value="1130" />
        <PreValue Id="206" Value="False" />
        <PreValue Id="207" Value="0" />
        <PreValue Id="208" Value="1" />
        <PreValue Id="209" Value="200" />
        <PreValue Id="210" Value="0" />
      </PreValues>
    </DataType>
    

    Obviously, the original prevalue with ID 61 is the one missing from the exported XML and has been replaced with the prevalue with ID 211.

    When looking into the cmsDataTypePreValues table after importing the MNTP (and before accessing it), sure enough the prevalues table contains all the prevalues from the import XML except the empty prevalue with ID 61. Could it be that you're removing empty prevalues before importing?

    Regards,
    Kenn 

     

     

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 30, 2013 @ 13:20
    Kevin Jump
    0

    ahh yes, don't you hate it when that happens, being to clever for my own good with String.IsNullorEmpty - I can now recreate and have a fix for the above - uncovered an onDelete change in 6.0.4 as well : ) - just packaging up and testing on a few versions of umbraco now. 

    Kevin 

  • Kenn Jacobsen 133 posts 791 karma points MVP 4x c-trib
    Apr 30, 2013 @ 13:23
    Kenn Jacobsen
    0

    Hehe yes.... I hate it when that happens :)

  • Kevin Jump 2310 posts 14695 karma points MVP 7x c-trib
    Apr 30, 2013 @ 13:42
    Kevin Jump
    100

    OK uSync 1.2.1 appears to work, on Umbraco 6.0.4 and 4.11.x for this issue, appreciate it if you could try and see if it fixes your problems. 

     

     

  • Kenn Jacobsen 133 posts 791 karma points MVP 4x c-trib
    Apr 30, 2013 @ 14:02
    Kenn Jacobsen
    0

    Hey Kevin,

    I'll have my colleague test it as soon as possible - probably not today but hopefully tomorrow. 

    -Kenn

  • Mads Jørgensen 74 posts 226 karma points
    May 01, 2013 @ 08:04
    Mads Jørgensen
    0

    Hey Kevin,

    Works like a charm :-)

     

    Cheers, #h5yr

Please Sign in or register to post replies

Write your reply to:

Draft