Fix feeds migration & disable email transport

This commit is contained in:
Nicolas Le Goff
2015-02-12 17:35:13 +01:00
parent 4cd2ef9a6d
commit 37c667113f
4 changed files with 74 additions and 11 deletions

View File

@@ -331,6 +331,15 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
return $this->publishers; return $this->publishers;
} }
public function get_owner()
{
if (!$this->owner) {
$this->load_publishers();
}
return $this->owner;
}
/** /**
* *
* @return int * @return int

View File

@@ -559,7 +559,11 @@ class User_Query implements User_QueryInterface
$users = new ArrayCollection(); $users = new ArrayCollection();
foreach ($rs as $row) { foreach ($rs as $row) {
try {
$users[] = User_Adapter::getInstance($row['usr_id'], $this->app); $users[] = User_Adapter::getInstance($row['usr_id'], $this->app);
} catch (\Exception $e) {
}
} }
$this->results = $users; $this->results = $users;

View File

@@ -813,6 +813,9 @@ abstract class base implements cache_cacheableInterface
$success = true; $success = true;
// disable mail
$app['swiftmailer.transport'] = null;
foreach ($list_patches as $patch) { foreach ($list_patches as $patch) {
if ( ! $patch->apply($this, $app)) if ( ! $patch->apply($this, $app))
$success = false; $success = false;

View File

@@ -11,6 +11,7 @@
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/** /**
* *
@@ -87,20 +88,40 @@ class patch_320alpha4b implements patchInterface
continue; continue;
} }
$publishers = $feed->get_publishers(); $sql = 'INSERT INTO feed_entries (id, feed_id, publisher, title, description, created_on, updated_on, author_name, author_email)
$entry = Feed_Entry_Adapter::create($app, $feed, array_shift($publishers), $row['name'], $row['descript'], $user->get_display_name(), $user->get_email()); VALUES (null, :feed_id, :publisher_id, :title, :description, :created, :updated, :author_name, :author_email)';
$params = array(
':feed_id' => $feed->get_id(),
':publisher_id' => $feed->get_owner()->get_id(),
':title' => trim($row['name']),
':description' => trim($row['descript']),
':author_name' => trim($user->get_display_name()),
':author_email' => trim($user->get_email()),
':updated' => $row['updater'],
':created' => $row['pub_date'],
);
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
$entry_id = $app['phraseanet.appbox']->get_connection()->lastInsertId();
$feed->delete_data_from_cache();
unset($stmt);
$date_create = new DateTime($row['pub_date']); $date_create = new DateTime($row['pub_date']);
if ($date_create < $date_ref) { if ($date_create < $date_ref) {
$date_ref = $date_create; $date_ref = $date_create;
} }
$entry->set_created_on($date_create);
if ($row['updater'] != '0000-00-00 00:00:00') {
$date_update = new DateTime($row['updater']);
$entry->set_updated_on($date_update);
}
$sql = 'SELECT sselcont_id, ssel_id, base_id, record_id $sql = 'SELECT sselcont_id, ssel_id, base_id, record_id
FROM sselcont WHERE ssel_id = :ssel_id ORDER BY ord ASC'; FROM sselcont
WHERE ssel_id = :ssel_id
ORDER BY ord ASC';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ssel_id' => $row['ssel_id'])); $stmt->execute(array(':ssel_id' => $row['ssel_id']));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -109,7 +130,33 @@ class patch_320alpha4b implements patchInterface
foreach ($rs as $row) { foreach ($rs as $row) {
try { try {
$record = new record_adapter($app, phrasea::sbasFromBas($app, $row['base_id']), $row['record_id']); $record = new record_adapter($app, phrasea::sbasFromBas($app, $row['base_id']), $row['record_id']);
$item = Feed_Entry_Item::create($appbox, $entry, $record);
$sql = 'SELECT (MAX(ord)+1) as sorter FROM feed_entry_elements
WHERE entry_id = :entry_id';
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':entry_id' => $entry_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($stmt);
$sorter = ($row && $row['sorter'] > 0) ? (int) $row['sorter'] : 1;
$sql = 'INSERT INTO feed_entry_elements (id, entry_id, sbas_id, record_id, ord)
VALUES (null, :entry_id, :sbas_id, :record_id, :ord)';
$params = array(
':entry_id' => $entry_id,
':sbas_id' => $record->get_sbas_id(),
':record_id' => $record->get_record_id(),
':ord' => $sorter
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$stmt->closeCursor();
unset($stmt);
} catch (NotFoundHttpException $e) { } catch (NotFoundHttpException $e) {
} }