Fix #114 : subdef substitution fails

This commit is contained in:
Romain Neutron
2011-12-26 16:07:05 +01:00
parent 9427baf8b6
commit 1bb1469108

View File

@@ -617,7 +617,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
throw new Exception_Media_SubdefNotFound (); throw new Exception_Media_SubdefNotFound ();
if (isset($this->subdefs[$name])) if (isset($this->subdefs[$name]))
return $this->subdefs[$name]; return $this->subdefs[$name];
if (!$this->subdefs) if (!$this->subdefs)
@@ -757,10 +756,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if ($data) if ($data)
{ {
if (isset($this->technical_datas[$data])) if (isset($this->technical_datas[$data]))
return $this->technical_datas[$data]; return $this->technical_datas[$data];
else else
return false; return false;
} }
@@ -951,7 +948,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$base_url = ''; $base_url = '';
$original_file = $subdef_def = false; $original_file = $subdef_def = false;
$subdefs = $this->get_databox()->get_subdef_structure(); $subdefs = $this->get_databox()->get_subdef_structure();
foreach ($subdefs as $type => $datas) foreach ($subdefs as $type => $datas)
@@ -972,7 +968,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
try try
{ {
$value = $this->get_subdef($name); $value = $this->get_subdef($name);
$original_file = p4string::addEndSlash($value['path']) . $value['file']; $original_file = p4string::addEndSlash($value->get_path()) . $value->get_file();
unlink($original_file); unlink($original_file);
} }
catch (Exception $e) catch (Exception $e)
@@ -987,7 +983,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (trim($subdef_def->get_baseurl()) !== '') if (trim($subdef_def->get_baseurl()) !== '')
{ {
$base_url = str_replace( $base_url = str_replace(
array((string) $subdef_def->get_path(), $newfilename), array((string) $subdef_def->get_baseurl(), ''), $path_file_dest array((string) $subdef_def->get_path(), $newfilename)
, array((string) $subdef_def->get_baseurl(), '')
, $path_file_dest
); );
} }
@@ -997,7 +995,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name'; $sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->record_id, ':name' => $name)); $stmt->execute(
array(
':record_id' => $this->record_id
, ':name' => $name
)
);
$registry = registry::get_instance(); $registry = registry::get_instance();
@@ -1032,7 +1035,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id'; $sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->bindParam(':record_id', $this->get_record_id()); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->execute(); $stmt->execute();
$this->delete_data_from_cache(self::CACHE_SUBDEFS); $this->delete_data_from_cache(self::CACHE_SUBDEFS);
@@ -1257,7 +1260,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_reg_name() public function get_reg_name()
{ {
if (!$this->is_grouping()) if (!$this->is_grouping())
return false; return false;
$balisename = ''; $balisename = '';
@@ -1296,14 +1298,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$registry = registry::get_instance(); $registry = registry::get_instance();
if ($this->bitly_link !== null) if ($this->bitly_link !== null)
return $this->bitly_link; return $this->bitly_link;
$this->bitly_link = false; $this->bitly_link = false;
if (trim($registry->get('GV_bitly_user')) == '' if (trim($registry->get('GV_bitly_user')) == ''
&& trim($registry->get('GV_bitly_key')) == '') && trim($registry->get('GV_bitly_key')) == '')
return $this->bitly_link; return $this->bitly_link;
try try
@@ -1356,7 +1356,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
else else
{ {
$uuid = $system_file->read_uuid(); $uuid = $system_file->read_uuid();
if(!uuid::is_valid($uuid)) if (!uuid::is_valid($uuid))
{ {
$uuid = uuid::generate_v4(); $uuid = uuid::generate_v4();
} }
@@ -1504,7 +1504,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
$hd = $this->get_subdef('document'); $hd = $this->get_subdef('document');
if ($hd->is_physically_present()) if ($hd->is_physically_present())
return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file()); return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file());
return null; return null;
} }
@@ -1844,7 +1843,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_container_baskets() public function get_container_baskets()
{ {
if ($this->container_basket) if ($this->container_basket)
return $this->container_basket; return $this->container_basket;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();