Skip to content

Commit

Permalink
Fix migration of incomplete items by creating a dummy field entry whe…
Browse files Browse the repository at this point in the history
…n a mandatory item field is empty in the old item record. In most cases this will be set to 'Untitled'
  • Loading branch information
dleffler committed Jul 15, 2011
1 parent 9ef2747 commit dd01891
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions framework/modules/migration/controllers/migrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,10 @@ private function convert($iloc, $module, $hc=0) {
$lnk = new links();
$loc = expUnserialize($link['location_data']);
$loc->mod = "links";
$lnk->title = $link['name'];
$lnk->title = (!empty($link['name'])) ? $link['name'] : 'Untitled';
$lnk->body = $link['description'];
$lnk->new_window = $link['opennew'];
$lnk->url = $link['url'];
$lnk->url = (!empty($link['url'])) ? $link['url'] : '#';
$lnk->rank = $link['rank'];
$lnk->poster = 1;
$lnk->editor = 1;
Expand Down Expand Up @@ -959,10 +959,10 @@ private function convert($iloc, $module, $hc=0) {
$lnk = new links();
$loc = expUnserialize($link['location_data']);
$loc->mod = "links";
$lnk->title = $link['name'];
$lnk->title = (!empty($link['name'])) ? $link['name'] : 'Untitled';
$lnk->body = $link['description'];
$lnk->new_window = $link['opennew'];
$lnk->url = $link['url'];
$lnk->url = (!empty($link['url'])) ? $link['url'] : '#';
$lnk->rank = $link['rank'];
$lnk->poster = 1;
$lnk->editor = 1;
Expand Down Expand Up @@ -1069,6 +1069,8 @@ private function convert($iloc, $module, $hc=0) {
$loc = expUnserialize($ni['location_data']);
$loc->mod = "news";
$news->location_data = serialize($loc);
$news->title = (!empty($ni['title'])) ? $ni['title'] : 'Untitled';
$news->body = (!empty($ni['body'])) ? $ni['body'] : '(empty)';
$news->save();
// default is to create with current time
$news->created_at = $ni['posted'];
Expand Down Expand Up @@ -1142,7 +1144,7 @@ private function convert($iloc, $module, $hc=0) {
$filedownload = new filedownload($ri);
$loc = expUnserialize($ri['location_data']);
$loc->mod = "filedownload";
$filedownload->title = $ri['name'];
$filedownload->title = (!empty($ri['name'])) ? $ri['name'] : 'Untitled';
$filedownload->body = $ri['description'];
$filedownload->downloads = $ri['num_downloads'];
$filedownload->location_data = serialize($loc);
Expand Down Expand Up @@ -1210,8 +1212,7 @@ private function convert($iloc, $module, $hc=0) {
$photo = new photo();
$loc = expUnserialize($gallery['location_data']);
$loc->mod = "photos";
$photo->title = $gi['name'];
if (empty($photo->title)) { $photo->title = 'Untitled'; }
$photo->title = (!empty($gi['name'])) ? $gi['name'] : 'Untitled';
$photo->body = $gi['description'];
$photo->alt = $gi['alt'];
$photo->location_data = serialize($loc);
Expand Down Expand Up @@ -1252,8 +1253,7 @@ private function convert($iloc, $module, $hc=0) {
$photo = new photo();
$loc = expUnserialize($gallery['location_data']);
$loc->mod = "photos";
$photo->title = $gi['name'];
if (empty($photo->title)) { $photo->title = 'Untitled'; }
$photo->title = (!empty($gi['name'])) ? $gi['name'] : 'Untitled';
$photo->body = $gi['description'];
$photo->alt = $gi['alt'];
$photo->location_data = serialize($loc);
Expand Down Expand Up @@ -1344,6 +1344,8 @@ private function convert($iloc, $module, $hc=0) {
$loc = expUnserialize($bi['location_data']);
$loc->mod = "blog";
$post->location_data = serialize($loc);
$post->title = (!empty($bi['title'])) ? $bi['title'] : 'Untitled';
$post->body = (!empty($bi['body'])) ? $bi['body'] : '(empty)';
$post->save();
// default is to create with current time
$post->created_at = $bi['posted'];
Expand Down Expand Up @@ -1408,10 +1410,12 @@ private function convert($iloc, $module, $hc=0) {
$loc = expUnserialize($fqi['location_data']);
$loc->mod = "faq";
$faq->location_data = serialize($loc);
$faq->question = $fqi['question'];
$faq->question = (!empty($fqi['question'])) ? $fqi['question'] : 'Untitled?';
$faq->answer = $fqi['answer'];
$faq->rank = $fqi['rank'];
$faq->include_in_faq = 1;
$faq->submitter_name = 'Unknown';
$faq->submitter_email = 'address@website.com';
$faq->save();
@$this->msg['migrated'][$iloc->mod]['count']++;
@$this->msg['migrated'][$iloc->mod]['name'] = $this->new_modules[$iloc->mod];
Expand All @@ -1438,7 +1442,7 @@ private function convert($iloc, $module, $hc=0) {
foreach ($listingitems as $li) {
unset($li['id']);
$listing = new portfolio($li);
$listing->title = $li['name'];
$listing->title = (!empty($li['name'])) ? $li['name'] : 'Untitled?';
$loc = expUnserialize($li['location_data']);
$loc->mod = "portfolio";
$listing->location_data = serialize($loc);
Expand Down Expand Up @@ -1651,12 +1655,13 @@ private function convert($iloc, $module, $hc=0) {
$loc = expUnserialize($bi['location_data']);
$loc->mod = "banner";
$banner->title = $bi['name'];
$banner->url = (!empty($bi['url'])) ? $bi['url'] : '#';
if (empty($banner->title)) { $banner->title = 'Untitled'; }
$banner->location_data = serialize($loc);
$newcompany = $db->selectObject('companies', "title='".$oldcompany->name."'");
if ($newcompany == null) {
$newcompany = new company();
$newcompany->title = $oldcompany->name;
$newcompany->title = (!empty($oldcompany->name)) ? $oldcompany->name : 'Untitled';
$newcompany->body = $oldcompany->contact_info;
$newcompany->location_data = $banner->location_data;
$newcompany->save();
Expand Down

0 comments on commit dd01891

Please sign in to comment.