Index: trunk/extensions/Wikidata/util/copy.php |
— | — | @@ -203,6 +203,9 @@ |
204 | 204 | function dupSyntrans($dc1, $dc2, $olddmid, $oldexpid, $newdmid, $newexpid) { |
205 | 205 | $syntrans=getOldSyntrans($dc1, $olddmid, $oldexpid); |
206 | 206 | $copier=new ObjectCopier($syntrans["syntrans_sid"], "syntrans", $dc1, $dc2); |
| 207 | + if ($copier->already_there()) { |
| 208 | + return; |
| 209 | + } |
207 | 210 | $newid=$copier->dup(); |
208 | 211 | $syntrans["syntrans_sid"]=$newid; |
209 | 212 | writeSyntrans($syntrans, $newdmid, $newexpid, $dc2); |
— | — | @@ -219,11 +222,12 @@ |
220 | 223 | |
221 | 224 | $copier=new ObjectCopier($expression["expression_id"], "expression_ns", $dc1, $dc2); |
222 | 225 | $target_expid1=$copier->dup(); |
223 | | - var_dump($target_expid1); |
224 | 226 | $save_expression=$expression; |
225 | 227 | $save_expression["expression_id"]=$target_expid1; |
226 | 228 | $target_table=mysql_real_escape_string("${dc2}_expression_ns"); |
227 | | - mysql_insert_assoc($target_table,$save_expression); |
| 229 | + if (!($copier->already_there())) { |
| 230 | + mysql_insert_assoc($target_table,$save_expression); |
| 231 | + } |
228 | 232 | dupsyntrans( |
229 | 233 | $dc1, |
230 | 234 | $dc2, |
— | — | @@ -270,6 +274,12 @@ |
271 | 275 | $target_table=mysql_real_escape_string("translated_content"); |
272 | 276 | $copier=new ObjectCopier($tcid, $target_table, $dc1, $dc2); |
273 | 277 | $new_tcid=$copier->dup(); |
| 278 | + # note the issue where translated content is added later: |
| 279 | + # since all translated content for a single dm |
| 280 | + # shares one UUID, we can't check for that eventuality. |
| 281 | + if ($copier->already_there()) { |
| 282 | + return; |
| 283 | + } |
274 | 284 | foreach ($translated_content as $item) { |
275 | 285 | write_translated_content($dc1, $dc2, $new_tcid, $item); |
276 | 286 | } |
— | — | @@ -301,6 +311,9 @@ |
302 | 312 | function write_meaning_relation($dc1, $dc2, $new_dmid, $relation) { |
303 | 313 | $copier=new ObjectCopier($relation["relation_id"], "meaning_relations", $dc1, $dc2); |
304 | 314 | $relation["relation_id"]=$copier->dup; |
| 315 | + if ($copier->already_there()) { |
| 316 | + return; |
| 317 | + } |
305 | 318 | $relation["meaning1_mid"]=$new_dmid; |
306 | 319 | $relation["meaning2_mid"]=dup_defined_meaning($relation["meaning2_mid"],$dc1, $dc2); |
307 | 320 | } |
— | — | @@ -352,25 +365,29 @@ |
353 | 366 | $this->save_meaning=$this->defined_meaning; |
354 | 367 | $this->save_meaning["defined_meaning_id"]=$target_dmid; |
355 | 368 | |
356 | | - # exp |
357 | | - $target_table=mysql_real_escape_string("${dc2}_expression_ns"); |
358 | | - $exp_copier=new ObjectCopier($defining_expression["expression_id"], $target_table, $dc1, $dc2); |
359 | | - $target_expid1=$exp_copier->dup(); |
360 | | - var_dump($target_expid1); |
361 | | - $save_expression=$defining_expression; |
362 | | - $save_expression["expression_id"]=$target_expid1; |
363 | | - mysql_insert_assoc($target_table,$save_expression); |
364 | | - # and insert that info into the dm |
365 | | - $this->save_meaning["expression_id"]=$target_expid1; |
| 369 | + if (!($copier->already_there())) { |
| 370 | + # exp |
| 371 | + $target_table=mysql_real_escape_string("${dc2}_expression_ns"); |
| 372 | + $exp_copier=new ObjectCopier($defining_expression["expression_id"], $target_table, $dc1, $dc2); |
| 373 | + $target_expid1=$exp_copier->dup(); |
| 374 | + var_dump($target_expid1); |
| 375 | + $save_expression=$defining_expression; |
| 376 | + $save_expression["expression_id"]=$target_expid1; |
| 377 | + mysql_insert_assoc($target_table,$save_expression); |
| 378 | + # and insert that info into the dm |
| 379 | + $this->save_meaning["expression_id"]=$target_expid1; |
| 380 | + } |
366 | 381 | $this->save_meaning["meaning_text_tcid"]=dup_translated_content($dc1, $dc2, $this->defined_meaning["meaning_text_tcid"]); |
367 | 382 | |
368 | | - mysql_insert_assoc($dm_target_table, $this->save_meaning); |
| 383 | + if (!($copier->already_there())) { |
| 384 | + mysql_insert_assoc($dm_target_table, $this->save_meaning); |
369 | 385 | |
370 | | - $title_name=$defining_expression["spelling"]; |
371 | | - $title_number=$target_dmid; |
372 | | - $title=str_replace(" ","_",$title_name)."_(".$title_number.")"; |
373 | | - $pagedata=array("page_namespace"=>24, "page_title"=>$title); |
374 | | - mysql_insert_assoc("page",$pagedata); |
| 386 | + $title_name=$defining_expression["spelling"]; |
| 387 | + $title_number=$target_dmid; |
| 388 | + $title=str_replace(" ","_",$title_name)."_(".$title_number.")"; |
| 389 | + $pagedata=array("page_namespace"=>24, "page_title"=>$title); |
| 390 | + mysql_insert_assoc("page",$pagedata); |
| 391 | + } |
375 | 392 | |
376 | 393 | $concepts=array( |
377 | 394 | $dc1 => $this->defined_meaning["defined_meaning_id"], |