From b31ca0cd3632ff0ad6801c20fbb722cccb136abb Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Wed, 8 Jul 2009 14:28:22 +0000 Subject: [PATCH] prevent creating badxml when pubsub_state is not accessible SVN Revision: 2360 --- src/mod_pubsub/node_hometree.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mod_pubsub/node_hometree.erl b/src/mod_pubsub/node_hometree.erl index 45c695ae2..764b511d4 100644 --- a/src/mod_pubsub/node_hometree.erl +++ b/src/mod_pubsub/node_hometree.erl @@ -723,8 +723,11 @@ set_subscriptions(NodeId, Owner, Subscriptions) -> %% ```get_states(NodeId) -> %% node_default:get_states(NodeId).'''

get_states(NodeId) -> - States = mnesia:match_object( - #pubsub_state{stateid = {'_', NodeId}, _ = '_'}), + States = case catch mnesia:match_object( + #pubsub_state{stateid = {'_', NodeId}, _ = '_'}) of + List when is_list(List) -> List; + _ -> [] + end, {result, States}. %% @spec (NodeId, JID) -> [State] | [] @@ -734,7 +737,7 @@ get_states(NodeId) -> %% @doc

Returns a state (one state list), given its reference.

get_state(NodeId, JID) -> StateId = {JID, NodeId}, - case mnesia:read({pubsub_state, StateId}) of + case catch mnesia:read({pubsub_state, StateId}) of [State] when is_record(State, pubsub_state) -> State; _ -> #pubsub_state{stateid=StateId} end.