Mercurial > prosody-modules
comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 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 | 4786bf0a9334 |
| children | 7f9bf161f640 |
comparison
equal
deleted
inserted
replaced
| 2395:2e641ab995b3 | 2396:544ee057a23f |
|---|---|
| 128 end | 128 end |
| 129 | 129 |
| 130 local q_with, q_start, q_end = query.with, query.start, query["end"]; | 130 local q_with, q_start, q_end = query.with, query.start, query["end"]; |
| 131 for i = first_item, last_item, step do | 131 for i = first_item, last_item, step do |
| 132 local item = items[i]; | 132 local item = items[i]; |
| 133 if not item then | |
| 134 module:log("warn", "data[%q][%d] is nil", dates[d], i); | |
| 135 break; | |
| 136 end | |
| 133 local i_when, i_with = item.when, item.with; | 137 local i_when, i_with = item.when, item.with; |
| 134 if type(i_when) == "string" then | 138 if type(i_when) == "string" then |
| 135 i_when = dt.parse(i_when); | 139 i_when = dt.parse(i_when); |
| 136 end | 140 end |
| 137 if type(i_when) ~= "number" then | 141 if type(i_when) ~= "number" then |
| 138 module:log("warn", "data[%q][%d].when is invalid", dates[d], i); | 142 module:log("warn", "data[%q][%d].when is invalid", dates[d], i); |
| 139 break; | |
| 140 end | |
| 141 if not item then | |
| 142 module:log("warn", "data[%q][%d] is nil", dates[d], i); | |
| 143 break; | 143 break; |
| 144 end | 144 end |
| 145 if xmlfile and in_range | 145 if xmlfile and in_range |
| 146 and (not q_with or i_with == q_with) | 146 and (not q_with or i_with == q_with) |
| 147 and (not q_start or i_when >= q_start) | 147 and (not q_start or i_when >= q_start) |
