Skip to content

compatibilityHack restore empty string response on no room user data#340

Merged
SlySven merged 1 commit intoMudlet:developmentfrom
SlySven:CompatibilityHack_restoreEmptyStringResponseOnNoRoomUserData
Nov 7, 2016
Merged

compatibilityHack restore empty string response on no room user data#340
SlySven merged 1 commit intoMudlet:developmentfrom
SlySven:CompatibilityHack_restoreEmptyStringResponseOnNoRoomUserData

Conversation

@SlySven
Copy link
Copy Markdown
Member

@SlySven SlySven commented Oct 26, 2016

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) 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

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 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.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Oct 31, 2016

@vadi2 Is this and #341 good to go?

@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Oct 31, 2016

Not yet - haven't tested it yet. Thanks for keeping scope of the PR small though.

@SlySven
Copy link
Copy Markdown
Member Author

SlySven commented Oct 31, 2016

Well _that_ one was a relatively small cock-up...!

@SlySven SlySven merged commit d5f952f into Mudlet:development Nov 7, 2016
@SlySven SlySven deleted the CompatibilityHack_restoreEmptyStringResponseOnNoRoomUserData branch November 7, 2016 17:17
@SlySven SlySven restored the CompatibilityHack_restoreEmptyStringResponseOnNoRoomUserData branch June 22, 2020 17:56
@SlySven SlySven deleted the CompatibilityHack_restoreEmptyStringResponseOnNoRoomUserData branch June 22, 2020 18:51
SlySven added a commit that referenced this pull request Feb 10, 2021
This was introduced by #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 #340 by myself!

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants