load call details on finished calls, too
[auerswald-callnotifier.git] / src / callnotifier / CallMonitor / Detailler / OpenGeoDb.php
index 2b4800483a72ba5d46c32a0d36a5e4b5457d0dfb..46711b08baae3dfe29a403a51d0f74581de41cdb 100644 (file)
@@ -58,9 +58,13 @@ class CallMonitor_Detailler_OpenGeoDb implements CallMonitor_Detailler
     public function loadCallDetails(CallMonitor_Call $call)
     {
         if ($call->type == CallMonitor_Call::INCOMING) {
-            $call->fromLocation = $this->loadLocation($call->from);
+            if (!isset($call->fromLocation) || $call->fromLocation === null) {
+                $call->fromLocation = $this->loadLocation($call->from);
+            }
         } else {
-            $call->toLocation = $this->loadLocation($call->to);
+            if (!isset($call->toLocation) || $call->toLocation === null) {
+                $call->toLocation = $this->loadLocation($call->to);
+            }
         }
     }
 
@@ -85,6 +89,12 @@ class CallMonitor_Detailler_OpenGeoDb implements CallMonitor_Detailler
             . ' OR vorwahl = ' . $this->db->quote(substr($number, 0, 6))
             . ' ORDER BY einwohner DESC'
         );
+        if ($stm === false) {
+            throw new \Exception(
+                implode(' - ', $this->db->errorInfo())
+            );
+        }
+
         $res = $stm->fetch();
         if ($res === false) {
             return null;