# HG changeset patch # User Kim Alvefur # Date 1480111698 -3600 # Node ID 544ee057a23fd70bc15f68393aba0b8c3e0c537b # Parent 2e641ab995b37725a605502c5552c1fe62ae9352 mod_storage_xmlarchive: Check if item exists before checking if its fields diff -r 2e641ab995b3 -r 544ee057a23f mod_storage_xmlarchive/mod_storage_xmlarchive.lua --- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Thu Nov 24 01:15:08 2016 +0100 +++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Fri Nov 25 23:08:18 2016 +0100 @@ -130,6 +130,10 @@ local q_with, q_start, q_end = query.with, query.start, query["end"]; for i = first_item, last_item, step do local item = items[i]; + if not item then + module:log("warn", "data[%q][%d] is nil", dates[d], i); + break; + end local i_when, i_with = item.when, item.with; if type(i_when) == "string" then i_when = dt.parse(i_when); @@ -138,10 +142,6 @@ module:log("warn", "data[%q][%d].when is invalid", dates[d], i); break; end - if not item then - module:log("warn", "data[%q][%d] is nil", dates[d], i); - break; - end if xmlfile and in_range and (not q_with or i_with == q_with) and (not q_start or i_when >= q_start)