(release_30)enhance: restore version check to Mudlet XMLimport code#370
(release_30)enhance: restore version check to Mudlet XMLimport code#370SlySven wants to merge 3 commits intoMudlet:release_30from
Conversation
I foresee the need to tweak the Xml format in the future, however though there once was some checks for this in the code in the past it was commented out. This commit - which should go into both development and release_30 branches despite it not being technically a "BugFix" will now alert the user if they load any code which does not have a "version" attribute with a numeric value equivalent to 1.000f in the "MudletPackage" element of the Xml. It will not STOP the code being loaded, just issue the alert! This is to cover the CURRENT code against problems that might arise in the future if the XML format/structure gets changed which will otherwise go *undetected* by the Mudlet application as it is currently. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
The QtMath include is not available in Qt 5.0.2 so breaks compilation on that, pretty much the earliest version of the qt Libs we now support. Unfortunately this is the version that we are using for Linux platform Travis C.I. builds! Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
src/XMLimport.cpp
Outdated
| // decimals | ||
| void XMLimport::getVersionString( QString & versionString ) | ||
| { | ||
| versionString = QString::number( static_cast<float>( mVersionMajor + 1000.0f * mVersionMinor ), 'f', 3 ); |
There was a problem hiding this comment.
🪲 This method is not currently set to be used but yes, I got it wrong...! It should be:
versionString = QString::number( ( mVersionMajor * 1000 + mVersionMinor ) / 1000.0, 'f', 3 );
I got the maths wrong...! Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
What is the point of this? What is the user supposed to do when they see this? |
|
Consider updated to a newer version of Mudlet! I believe we have made incremental changes to what goes into the Xml files but other than some
Problems could come about IMHO if we ever want to remove "elements" from the XML format - like say nuking the misspelled "commandSeperator" that duplicates "commandSeparator" - I think the parser in the code at the moment will enter a As it stands the current code base has nothing to protect against the last case and - unlike the map loading code - does not do any sort of version check on the format for the XML and thus cannot alert the user if something does get changed in the future that does warrant them updating their Mudlet. This code will, going forward, at least tell the user that there is a problem; I did wonder whether we could trigger a version mis-match to a switch to tl;dr; IMHO this is a minimal implementation to cover warning the user if we need to change the XML used (or at least the "version" attribute to the "MudletPackage" element) to save the Mudlet profile in the future. |
|
I agree on showing a message when the user imports a script for the first time, though the message to the user is too technical in my opinion. Also, in case of modules, would it spam the warning every time or re-save the module with a newer version automatically? I don't think we need to show any messages in the main output window if the version tag is missing, because should it happen, there is nothing for the user to do anyway, and so we're just spamming them. |
|
With the code as it is - when it is re-saved the version string will be reset to that which the current code uses and understands. This could cause data loss if the XML is then re-read by a later version which would probably be what created the later version in the first place; on the other-hand: any time something new is added to the format there will have to be something (perhaps an assumed default value/setting) to provide a forward migration route. This is most likely to occur for a developer or someone who uses both the current and some, currently hypothetical future version - so I think that any time there is a mismatch between the version a Mudlet instance uses and what it gets there needs to be a heads-up message. The pain for the user will be that every time they switch from the older xml version using Mudlet instance to the more modern one, they may have to redo/tweak whatever the new features are that the new format supports. 📝 I am quite willing to believe that the wording of the message could need polishing/editing. As for issuing a message in the absence of a version indication I have traced the "version" attribute being "1.0" back as far as Beta-14 which was before Mudlet 1.0-rc - so it was probably in the very first code to save the Profile as an |
|
This PR is likely to not merge cleanly with #373 as they touch common areas in the XML handling classes. I would suggest that this is held, possibly for rebasing until after that PR is merged. |
|
@vadi2 The proposed message would appear as, for example: [ ALERT ] - detected file being read is a later version (1.001) than this version
of Mudlet expects! It is possible that further issues may be found
or it may still load and work properly, this is merely an advisory
message!
Do you have a suggested shorter form for this text, given that the version of Mudlet that we will have immediately after this PR goes in (Version A) cannot know what it will get in the file saved from a future Mudlet version (Version Z) that was not configured to produce a file compatible with Version A! I would be tempted once/if we move away from a default version 1.000 to include that in the message as well which will help if someone has to diagnose a failure... Such a file might work but need some manual adjustment to compensate for things that the later version no longer includes or it might be totally unusable - c.f. what happens for the more rigid binary Map format compared to the flexibility that XML gives us for this type of data - a Mudlet instance (Version A) HAS to reject later map format versions that it does not understand (from Version Z). Note: we could always include something in (Version Z with XML format 1.xx) to report what will be a problem in each earlier format (<1.xx) when the user manually chooses to downgrade to save a file from their (Version Z) Mudlet - we could stipulate THAT as a requirement for anything that does need to revise the format to be used... |
|
See #369 - I realised another problem with having this. This actually adds problems for us and doesn't solve any existing ones. |
|
Replying to #369 (comment) in the correct PR:
|
Well it used to throw out a load of The absence of a <MudletPackage ...> in an XML file the user might try to import will stop them loading in a random file that they happen to have lying around their system, and as I checked we have been tagging files with version 1.0 as far as I can see history of (~2008 ish) - I just want to cover our asses should we ever break things in the future. |
|
I think it'll be okay, because I've been switching between 3.0 and 2.1 lots of times and haven't had issues - and we didn't have any complaints about it from the users so far either. I'm now leaning more towards allowing small 'errors' instead of bothering the user for every single detail - it seems to be working out for the modern web applications - rarely do you see error codes or messages anymore, all you instead see is that a button that was supposed to do something didn't do something, for example. Showing an error code to the user wouldnt've solved anything anyway. Thus unrecognised properties or etc should not be errors or even warnings, it's a given that if you use an older application with newer settings features that those features won't work. That in turn makes XML version numbers kind of moot - if Mudlet can understand it, it should do the best job it can, bothering the user as little as possible, to load the file - exactly what it does right now in fact. If it really can't and stumbles, then abort loading the file and don't save settings when exiting because you haven't loaded anything. Changing the format of the XML is a different topic for another time. |
|
You posted whilst I was still typing so you hadn't seen my last post before you responded. 😄 |
|
That's why you've gotta stop editing comments. I don't get notifications and it's really hard to see edits. Just add another one instead of editing! |
|
It wasn't an edit it was a fresh post - wasn't it - oh bother I'm loosing it! |
|
OK, let's put one in in the very extreme case that we'll need to hit the switch sometime. I'm sure you see now though that such a switch does warrant being enabled if we add new properties to the XML or little things like that - things so far have worked fine since the beginning. If it ain't broke, don't fix it sorta thing. |
Shirley, that should be doesn't should it not? |
|
Yes, doesn't warrant being enabled, sorry. |
|
Sometimes I forget whether I'm returning to write a new comment after switching back from the "preview" tab to check how a post goes or I've gone to the edit option to grab something like a link or other previously posted element and accidentally gone on to emending it... |
|
oops, emend not "emending" |
I foresee the need to tweak the Xml format in the future, however though there once was some checks for this in the code in the past it was commented out. This commit is a revised version of a pull request (Mudlet#370) originally aimed at the release_30 branch but which has changed so much it was easier to restart from a more up to date point. This version checked the "version" attribute of the MudletPackage element of most types of XML files read (not Maps) and will allow through without comment a string value that works out to a float less than 2.000f (three decimal place resolution) but will cause XMLimport::importPackage(...) to return a FALSE value - {the return is largely ignored currently) - to not read the file further and to cause an "[ ALERT ]" message on the main console should the version value be 2.000 or greater. This is to cover the CURRENT code against problems that might arise in the future if the XML format/structure gets changed too much which will otherwise go *undetected* by the Mudlet application as it is currently. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
|
Closing and replacing with #870 - as code has changed too much to make it easy to resolve conflicts. |

I foresee the need to tweak the Xml format in the future, however though
there once was some checks for this in the code in the past it was
commented out. This commit - which should go into both development and
release_30 branches despite it not being technically a "BugFix" will now
alert the user if they load any code which does not have a "version"
attribute with a numeric value equivalent to 1.000f in the "MudletPackage"
element of the Xml.
It will not STOP the code being loaded, just issue the alert!
This is to cover the CURRENT code against problems that might arise in the
future if the XML format/structure gets changed which will otherwise go
undetected by the Mudlet application as it is currently.
This performs the same changes as #369 does to the development branch.
Signed-off-by: Stephen Lyons slysven@virginmedia.com