25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-10 15:47:30 +01:00

Nidx may be integer or binary, so use jlib:i2l instead

As reported in
https://www.ejabberd.im/forum/28580/erlang-function-integertobinary1-throwing-badargs-exception
This commit is contained in:
Badlop 2016-10-20 21:56:19 +02:00
parent 0212559ca7
commit 2ab72bcd00

View File

@ -688,7 +688,7 @@ get_items(Nidx, _From,
before -> {<<">">>, <<"asc">>}; before -> {<<">">>, <<"asc">>};
_ -> {<<"is not">>, <<"desc">>} _ -> {<<"is not">>, <<"desc">>}
end, end,
SNidx = integer_to_binary(Nidx), SNidx = jlib:i2l(Nidx),
[AttrName, Id] = case I of [AttrName, Id] = case I of
undefined when IncIndex =/= undefined -> undefined when IncIndex =/= undefined ->
case catch case catch
@ -790,7 +790,7 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM
get_last_items(Nidx, _From, Count) -> get_last_items(Nidx, _From, Count) ->
Limit = jlib:i2l(Count), Limit = jlib:i2l(Count),
SNidx = integer_to_binary(Nidx), SNidx = jlib:i2l(Nidx),
Query = fun(mssql, _) -> Query = fun(mssql, _) ->
ejabberd_sql:sql_query_t( ejabberd_sql:sql_query_t(
[<<"select top ">>, Limit, [<<"select top ">>, Limit,
@ -890,7 +890,7 @@ del_items(Nidx, [ItemId]) ->
del_item(Nidx, ItemId); del_item(Nidx, ItemId);
del_items(Nidx, ItemIds) -> del_items(Nidx, ItemIds) ->
I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>), I = str:join([[<<"'">>, ejabberd_sql:escape(X), <<"'">>] || X <- ItemIds], <<",">>),
SNidx = integer_to_binary(Nidx), SNidx = jlib:i2l(Nidx),
catch catch
ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>, ejabberd_sql:sql_query_t([<<"delete from pubsub_item where itemid in (">>,
I, <<") and nodeid='">>, SNidx, <<"';">>]). I, <<") and nodeid='">>, SNidx, <<"';">>]).