| @@ -90,9 +90,9 @@ | ||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $file = $this->getIndexFile($key); |
| 93 | 93 | if (!file_exists($file)) { |
| 94 | - throw new FileException("Config Index File Not Found: " . $file); | |
| 94 | + throw new FileException(sprintf(__("Config Index File Not Found: %s", 'jc-importer'), $file)); | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $fh = fopen($file, 'r'); |
| 98 | 98 | $counter = 0; |
| @@ -157,9 +157,9 @@ | ||
| 157 | 157 | $counter += $separator_line_count; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (count($cache) < 2) { |
| 161 | - throw new FileException("Unable to located record: " . ($record + 1) . "."); | |
| 161 | + throw new FileException(sprintf(__("Unable to located record: %s.", 'jc-importer'), ($record + 1))); | |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // store cache |
| 165 | 165 | $this->config['cached_indices'] = [ |
| @@ -187,9 +187,18 @@ | ||
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | public function readIndexes($key) |
| 190 | 190 | { |
| 191 | - return $this->hasIndexed($key); | |
| 191 | + if (!$this->hasIndexed($key)) { | |
| 192 | + return false; | |
| 193 | + } | |
| 194 | + | |
| 195 | + // Treat a zero-record index as missing so it can be rebuilt | |
| 196 | + if (!isset($this->config['count'][$key]) || intval($this->config['count'][$key]) < 1) { | |
| 197 | + return false; | |
| 198 | + } | |
| 199 | + | |
| 200 | + return true; | |
| 192 | 201 | } |
| 193 | 202 | |
| 194 | 203 | public function storeIndexes($key, $buffer = false) |
| 195 | 204 | { |
| @@ -233,9 +242,13 @@ | ||
| 233 | 242 | } |
| 234 | 243 | |
| 235 | 244 | public function getRecordCount($key) |
| 236 | 245 | { |
| 237 | - return $this->config['count'][$key]; | |
| 246 | + if (!isset($this->config['count'][$key])) { | |
| 247 | + return 0; | |
| 248 | + } | |
| 249 | + | |
| 250 | + return intval($this->config['count'][$key]); | |
| 238 | 251 | } |
| 239 | 252 | |
| 240 | 253 | public function getIndexFile($key) |
| 241 | 254 | { |