commit b6a70d4b278d394b36a5f5b85300cf899b5e23c3
parent 57238f61a627c5e3c19149569dbbed1444803adf
Author: Felicitus <felicitus@felicitus.org>
Date: Tue, 21 Jun 2011 14:21:33 +0200
Reworked setup to skip adding an attachment if the source file could not be read
Diffstat:
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/testing/SetupDatabase.php b/testing/SetupDatabase.php
@@ -161,15 +161,21 @@ foreach ($data as $footprintName => $footprintData) {
echo $footprintName ." has a string attachment\n";
}
if (array_key_exists("url", $attachment)) {
- $footprintAttachment = new FootprintAttachment();
- $footprintAttachment->setFootprint($footprint);
- $footprintAttachment->replaceFromURL($attachment["url"]);
-
- if (array_key_exists("description", $attachment)) {
- $footprintAttachment->setDescription($attachment["description"]);
+ try {
+ $footprintAttachment = new FootprintAttachment();
+ $footprintAttachment->setFootprint($footprint);
+ $footprintAttachment->replaceFromURL($attachment["url"]);
+ if (array_key_exists("description", $attachment)) {
+ $footprintAttachment->setDescription($attachment["description"]);
+ }
+
+ $footprint->getAttachments()->add($footprintAttachment);
+ } catch (\Exception $e) {
+ echo "error with url ".$attachment["url"]."\n";
}
- $footprint->getAttachments()->add($footprintAttachment);
+
+
}
}
@@ -331,6 +337,8 @@ while ($supplier = mysql_fetch_assoc($r)) {
$aDistributors[$supplier["id"]] = $distributor;
}
+PartKeepr::getEM()->flush();
+
$r = mysql_query("SELECT * FROM parts");
$aRandomUnitNames = array("Spannung", "Strom", "Leitfähigkeit", "Viskosität", "Nessis");
@@ -359,13 +367,15 @@ while ($part = mysql_fetch_assoc($r)) {
$datasheetQuery = "SELECT datasheeturl FROM datasheets WHERE part_id = ".$part["id"];
$r3 = mysql_query($datasheetQuery);
while ($res = mysql_fetch_assoc($r3)) {
- $attachment = new PartAttachment();
- $attachment->setPart($oPart);
- $attachment->replaceFromURL($res["datasheeturl"]);
- $attachment->setDescription(PartKeepr::i18n("Datasheet"));
- $oPart->getAttachments()->add($attachment);
-
-
+ try {
+ $attachment = new PartAttachment();
+ $attachment->setPart($oPart);
+ $attachment->replaceFromURL($res["datasheeturl"]);
+ $attachment->setDescription(PartKeepr::i18n("Datasheet"));
+ $oPart->getAttachments()->add($attachment);
+ } catch (\Exception $e) {
+ echo "error with url ".$res["datasheeturl"]."\n";
+ }
}
PartKeepr::getEM()->persist($oPart);