compatibilityHack restore empty string response on no room user data#340
Merged
SlySven merged 1 commit intoMudlet:developmentfrom Nov 7, 2016
Conversation
When I introduce area and map user data storage I also revised the room user data code - specifically TLuaInterpreter::getRoomUserData(...) to provide informative error messages on various failures, unintentionally though, this introduced an incompatibility with the documented behaviour for this function in that, as of commit-79a8905c it was expected to return an empty string if the given room id (first argument) number did not exist or the data key (second argument) string was not found for that room. As it happens the past and current code DOES allow an empty string to be stored against a given key but the past code did not allow the user to differentiate it from the case where the room didn't exist (though that could be found out with other code) or the case where the key was not present - no workaround. This commit adds an optional third argument (bool) enableFullErrorReporting that enables a nil + error message if provided and is true, but which is false otherwise so that previous scripts retain their expected results from using the two-argument usage. Obviously new scripts should use the third option and set it to be true but they may wish to check for the availability of getAreaUserData() as an indication that they will get a nil response if the room does not exist or does not contain the requested key if they anticipate being used on older version of Mudlet with the non-ideal getRoomUserData() code. Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
SlySven
commented
Oct 28, 2016
| // This fix is specific to the Room User Data as the need for it was introduced | ||
| // at the same time as Area and Map User Data was added but they were not | ||
| // documented until later and their Wiki entries did/will not mention returning | ||
| // an empty string in the cases of no room with id or no key with given name. |
Member
Author
There was a problem hiding this comment.
Well actually it would be "no area with id" and only apply to the area case anyhow but that is not really of great concern here...
Member
Author
Member
|
Not yet - haven't tested it yet. Thanks for keeping scope of the PR small though. |
Member
Author
|
Well _that_ one was a relatively small cock-up...! |
vadi2
approved these changes
Nov 5, 2016
Chris7
pushed a commit
to Chris7/Mudlet
that referenced
this pull request
Jan 2, 2022
…4768) This was introduced by Mudlet#4661. Also switch to using raw string literal empty strings for two lua related function calls that do not work with `QString`s directly - which was introduced in Mudlet#340 by myself! Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When I introduced area and map user data storage I also revised the room user data code - specifically
TLuaInterpreter::getRoomUserData(...)to provide informative error messages on various failures, unintentionally though, this introduced an incompatibility with the documented behaviour for this function in that, as of commit-79a8905 it was expected to return an empty string if the given room id (first argument) number did not exist or the data key (second argument) string was not found for that room.As it happens the past and current code DOES allow an empty string to be stored against a given key but the past code did not allow the user to differentiate it from the case where the room didn't exist (though that could be found out with other code) or the case where the key was not present - no workaround.
This commit adds an optional third argument
(bool) enableFullErrorReportingthat enables a nil + error message if provided and is true, but which is false otherwise so that previous scripts retain their expected results from using the two-argument usage.Obviously new scripts should use the third option and set it to be true but they may wish to check for the availability of
getAreaUserData()as an indication that they will get a nil response if the room does not exist or does not contain the requested key if they anticipate being used on older version of Mudlet with the non-idealgetRoomUserData()code.Signed-off-by: Stephen Lyons slysven@virginmedia.com