Commit d3c8111baffaf977a7a8365316bbdff19365b98b

Authored by conradverm
1 parent a6dc1392

WSA-98

"Improve logging of sysdata updates - especially when exceptions are encountered"
Updated.

Committed By: Conrad Vermeulen
Reviewed By: Megan Watson

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7893 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 16 additions and 1 deletions
ktapi/KTAPIDocument.inc.php
@@ -1109,6 +1109,7 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1109,6 +1109,7 @@ class KTAPI_Document extends KTAPI_FolderItem
1109 */ 1109 */
1110 function update_sysdata($sysdata) 1110 function update_sysdata($sysdata)
1111 { 1111 {
  1112 + global $default;
1112 if (empty($sysdata)) 1113 if (empty($sysdata))
1113 { 1114 {
1114 return; 1115 return;
@@ -1182,10 +1183,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1182,10 +1183,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1182 $value = DBUtil::getResultArray($sql); 1183 $value = DBUtil::getResultArray($sql);
1183 if (PEAR::isError($value)) 1184 if (PEAR::isError($value))
1184 { 1185 {
  1186 + $default->log->error("Problem resolving mime type '$value' for document id $this->documentid. Reason: " . $value->getMessage());
1185 return $value; 1187 return $value;
1186 } 1188 }
1187 if (count($value) == 0) 1189 if (count($value) == 0)
1188 { 1190 {
  1191 + $default->log->error("Problem resolving mime type '$value' for document id $this->documentid. None found.");
1189 break; 1192 break;
1190 } 1193 }
1191 $value = $value[0]['id']; 1194 $value = $value[0]['id'];
@@ -1198,6 +1201,7 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1198,6 +1201,7 @@ class KTAPI_Document extends KTAPI_FolderItem
1198 $userId = DBUtil::getResultArray($sql); 1201 $userId = DBUtil::getResultArray($sql);
1199 if (PEAR::isError($userId)) 1202 if (PEAR::isError($userId))
1200 { 1203 {
  1204 + $default->log->error("Problem resolving user '$value' for document id $this->documentid. Reason: " . $userId->getMessage());
1201 return $userId; 1205 return $userId;
1202 } 1206 }
1203 if (empty($userId)) 1207 if (empty($userId))
@@ -1206,11 +1210,13 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1206,11 +1210,13 @@ class KTAPI_Document extends KTAPI_FolderItem
1206 $userId = DBUtil::getResultArray($sql); 1210 $userId = DBUtil::getResultArray($sql);
1207 if (PEAR::isError($userId)) 1211 if (PEAR::isError($userId))
1208 { 1212 {
  1213 + $default->log->error("Problem resolving username '$value' for document id $this->documentid. Reason: " . $userId->getMessage());
1209 return $userId; 1214 return $userId;
1210 } 1215 }
1211 } 1216 }
1212 if (empty($userId)) 1217 if (empty($userId))
1213 { 1218 {
  1219 + $default->log->error("Problem resolving user based on '$value' for document id $this->documentid. No user found");
1214 // if not found, not much we can do 1220 // if not found, not much we can do
1215 break; 1221 break;
1216 } 1222 }
@@ -1221,6 +1227,7 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1221,6 +1227,7 @@ class KTAPI_Document extends KTAPI_FolderItem
1221 $documents[$name] = $userId; 1227 $documents[$name] = $userId;
1222 break; 1228 break;
1223 default: 1229 default:
  1230 + $default->log->error("Problem updating field '$name' with value '$value' for document id $this->documentid. Field is unknown.");
1224 // TODO: we should do some logging 1231 // TODO: we should do some logging
1225 //return new PEAR_Error('Unexpected field: ' . $name); 1232 //return new PEAR_Error('Unexpected field: ' . $name);
1226 } 1233 }
@@ -1272,7 +1279,15 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1272,7 +1279,15 @@ class KTAPI_Document extends KTAPI_FolderItem
1272 if (!is_null($indexContent)) 1279 if (!is_null($indexContent))
1273 { 1280 {
1274 $indexer = Indexer::get(); 1281 $indexer = Indexer::get();
1275 - $indexer->updateDocumentIndex($this->documentid, $indexContent); 1282 + $result = $indexer->diagnose();
  1283 + if (empty($result))
  1284 + {
  1285 + $indexer->updateDocumentIndex($this->documentid, $indexContent);
  1286 + }
  1287 + else
  1288 + {
  1289 + $default->log->error("Problem updating index with value '$value' for document id $this->documentid. Problem with indexer.");
  1290 + }
1276 } 1291 }
1277 } 1292 }
1278 1293