(release_30)compatibilityHack: restore empty string response on no room user data#341
Merged
SlySven merged 1 commit intoMudlet:release_30from 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>
This was referenced Oct 31, 2016
vadi2
approved these changes
Nov 5, 2016
mehulmathur16
pushed a commit
to mehulmathur16/Mudlet
that referenced
this pull request
Feb 16, 2024
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