[Fusionforge-commits] r13051 - trunk/src/cronjobs

Franck VILLAUME nerville at fusionforge.org
Fri Apr 8 11:25:03 CEST 2011


Author: nerville
Date: 2011-04-08 11:25:02 +0200 (Fri, 08 Apr 2011)
New Revision: 13051

Modified:
   trunk/src/cronjobs/update_docdata_dataword.php
Log:
make it more robust

Modified: trunk/src/cronjobs/update_docdata_dataword.php
===================================================================
--- trunk/src/cronjobs/update_docdata_dataword.php	2011-04-08 08:51:23 UTC (rev 13050)
+++ trunk/src/cronjobs/update_docdata_dataword.php	2011-04-08 09:25:02 UTC (rev 13051)
@@ -5,7 +5,7 @@
  *
  * Copyright 2005, Fabio Bertagnin
  * Copyright 2009, Roland Mas
- * Copyright 2010, Franck Villaume
+ * Copyright 2010-2011, Franck Villaume - Capgemini
  *
  * This file is part of FusionForge.
  *
@@ -13,7 +13,7 @@
  * it under the terms of the GNU General Public License as published
  * by the Free Software Foundation; either version 2 of the License,
  * or (at your option) any later version.
- * 
+ *
  * FusionForge is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
@@ -33,37 +33,44 @@
 require_once $gfcommon.'docman/DocumentGroupFactory.class.php';
 
 $engine_path = dirname(__FILE__).'/../common/docman/engine/';
-$p = new Parsedata ($engine_path);
+$p = new Parsedata($engine_path);
 
 $timestarttrait = microtime_float();
 // documents list
 $resarr = array();
-$result = db_query_params ('SELECT doc_data.docid, doc_data.group_id, doc_data.filename, doc_data.title, doc_data.createdate, doc_data.filename, doc_data.description, doc_data.filetype,doc_data.data from doc_data,groups where doc_data.group_id = groups.group_id and groups.force_docman_reindex = $1',
+$result = db_query_params('SELECT doc_data.docid, doc_data.group_id, doc_data.filename, doc_data.title, doc_data.filename, doc_data.description, doc_data.filetype from doc_data, groups where doc_data.group_id = groups.group_id and groups.force_docman_reindex = $1',
 			   array('1'));
-if ($result)
-{
-	while ($arr = db_fetch_array($result))
-	{
+if (!$result) {
+	die(db_error());
+}
+
+if ($result) {
+	while ($arr = db_fetch_array($result)) 	{
 		$resarr[] = $arr;
 	}
 }
 
 $compt = 0;
-$rapp = "";
-foreach ($resarr as $item)
-{
+$errorFlag = 0;
+foreach ($resarr as $item) {
 	$compt++;
 	$timestart = microtime_float();
-	$data1 = base64_decode($item["data"]);
+	$doc_dataData = db_query_params('SELECT data from doc_data where docid = $1', array($item["docid"]));
+	if (!$doc_dataData) {
+		die("unable to get data: ".db_error());
+	}
+	$data1 = base64_decode($doc_dataData["data"]);
 	$lenin = strlen($data1);
-	$res = $p->get_parse_data ($data1, $item["title"], $item["description"], $item["filetype"]);
+	$res = $p->get_parse_data($data1, $item["title"], $item["description"], $item["filetype"]);
 	$len = strlen($res);
-	db_query_params ('UPDATE doc_data SET data_words=$1 WHERE docid=$2',
-			 array ($res,
-				$item['docid'])) ;
+	$resUp = db_query_params('UPDATE doc_data SET data_words=$1 WHERE docid=$2',
+			 array ($res, $item["docid"]));
+	if (!$resUp) {
+		die("unable to update data: ".db_error());
+	}
 	$timeend = microtime_float();
 	$timetrait = $timeend - $timestart;
-	print_debug ("analyze $item[filename]  type=$item[filetype]  octets in=$lenin  octets out=$len   time=$timetrait sec");
+	print_debug("analyze $item[filename]  type=$item[filetype]  octets in=$lenin  octets out=$len   time=$timetrait sec");
 }
 $timeendtrait = microtime_float();
 $timetot = $timeendtrait - $timestarttrait;
@@ -71,13 +78,11 @@
 //print_debug ("End analyze : $compt files, $timetot secs.");
 
 
-function print_debug ($text)
-{
+function print_debug ($text) {
 	echo "$text\n";
 }
 
-function microtime_float()
-{
+function microtime_float() {
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
 }




More information about the Fusionforge-commits mailing list