Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix #29 Uncategorized items (no category) get moved into wrong category

This also fixes a bug where articles having a missing category get lost.
  • Loading branch information...
commit 7390b8746c34f5f5d93cdc2f48689e6c0eec0349 1 parent ebce57f
Matias Griese authored

Showing 1 changed file with 19 additions and 6 deletions. Show diff stats Hide diff stats

  1. +19 6 trunk/admin/includes/migrate_content.php
25 trunk/admin/includes/migrate_content.php
@@ -45,15 +45,25 @@ protected function &getSourceData()
45 45
46 46 $rows = parent::getSourceData(
47 47 '`id`, `title`, `alias`, `title_alias`, `introtext`, `fulltext`, `state`, '
48   - .'`mask`, o.new AS catid, `created`, `created_by`, `created_by_alias`, '
49   - .'`modified`, `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, '
50   - .'`images`, `urls`, `attribs`, `version`, `parentid`, `ordering`, `metakey`, `metadesc`, '
51   - .'`access`, `hits` ',
52   - 'LEFT JOIN jupgrade_categories AS o ON o.old = c.catid',
53   - $where,
  48 + .'`mask`, `catid`, `created`, `created_by`, `created_by_alias`, '
  49 + .'`modified`, `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, '
  50 + .'`images`, `urls`, `attribs`, `version`, `parentid`, `ordering`, `metakey`, `metadesc`, '
  51 + .'`access`, `hits` ',
  52 + null,
  53 + null,
54 54 'id'
55 55 );
56 56
  57 + // Get category mapping
  58 + $query = "SELECT * FROM jupgrade_categories WHERE section REGEXP '^[\\-\\+]?[[:digit:]]*\\.?[[:digit:]]*$' AND old>0";
  59 + $this->db_new->setQuery($query);
  60 + $catidmap = $this->db_new->loadObjectList('old');
  61 +
  62 + // Find uncategorised category id
  63 + $query = "SELECT id FROM #__categories WHERE extension='com_content' AND path='uncategorised' LIMIT 1";
  64 + $this->db_new->setQuery($query);
  65 + $defaultId = $this->db_new->loadResult();
  66 +
57 67 // Do some custom post processing on the list.
58 68 foreach ($rows as &$row)
59 69 {
@@ -65,6 +75,9 @@ protected function &getSourceData()
65 75 if ($row['state'] == -1) {
66 76 $row['state'] = 2;
67 77 }
  78 +
  79 + // Map catid
  80 + $row['catid'] = isset($catidmap[$row['catid']]) ? $catidmap[$row['catid']]->new : $defaultId;
68 81
69 82 /*
70 83 * Prevent JGLOBAL_ARTICLE_MUST_HAVE_TEXT error

0 comments on commit 7390b87

Please sign in to comment.
Something went wrong with that request. Please try again.