Changeset

2396:544ee057a23f

mod_storage_xmlarchive: Check if item exists before checking if its fields
author Kim Alvefur <zash@zash.se>
date Fri, 25 Nov 2016 23:08:18 +0100
parents 2395:2e641ab995b3
children 2397:7f9bf161f640
files mod_storage_xmlarchive/mod_storage_xmlarchive.lua
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)