Summary

The table "j16_categories" looks ok, but "j16_assets" has 1.561 rows and all categories + articles have a column parent_id = 0 and level = 0 so they arent nested. I dont know if the lft and rgt column has the right information. Title and rules columns look ok.

I have the example table j16_assets. the trouble starts at id 32 as far as i know: unnested category. I only have example rows, because the rest of the table looks similar (only the title, id and lft and right differ)

Example table j16_assets attached as file to this post.

The components look as if they are nested ok.
Opened On:
19 Apr 2011, 11:28 by Mark Boos
Status:
Open

Filed Under

  • 1.5 to 1.6
  • Apache 2.2.x
  • com_jupgrade
  • Firefox 3.x
  • MySQL 5.1.x
  • PHP 5.3.x

Responses

Posted on 1 Sep 2011, 1:56 by Demon Demon
same problem when mirgating 1.5 to 1.7. assets table filled wrong. Permissions not inherited from root.
Posted on 6 Sep 2011, 1:19 by Demon Demon
additional. after jupgrade assets table parent_id fields on assets for categories and articles set to 0. I applied patch (http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=26210) then wrought such code (to restore parent_id):

//articles
$query = 'SELECT c.asset_id AS asset_id_toupdate, ctg.asset_id AS parent
FROM `#__content` AS c, #__categories AS ctg
WHERE c.catid = ctg.id';

$db->setQuery( $query );
$rows = $db->loadObjectList();

// Send mail to all superadministrators id
foreach( $rows as $row )
{
$query="update #__assets set parent_id=".$row->parent." where id=".$row->asset_id_toupdate;
$db->setQuery( $query );
$db->Query();
echo $row->asset_id_toupdate."-".$row->parent." ";
}
// categories
$query = 'SELECT cat.extension, cat.parent_id, cat.asset_id AS asset_id_toupdate, ctg.asset_id AS parent
FROM `#__categories` AS cat, #__categories AS ctg
WHERE cat.parent_id = ctg.id';

$db->setQuery( $query );
$rows = $db->loadObjectList();

// Send mail to all superadministrators id
foreach( $rows as $row )
{
if ($row->parent_id<>1)
{
$parent=$row->parent;
} else
{
$query = "SELECT id FROM `#__assets` WHERE title='".$row->extension."'";
$db->setQuery( $query );
$parent = $db->loadResult();
echo "<b>".$parent."</b>";
}
$query="update #__assets set parent_id=".$parent." where id=".$row->asset_id_toupdate;
$db->setQuery( $query );
$db->Query();
echo $row->asset_id_toupdate."-".$parent." ";
}



$assets = JTable::getInstance('asset');
$success = $assets->rebuild();
if($success)echo "<div>ta da!</div>";
else echo $assets->getError();

it helped me to fully restore group rights assignments functionality
Posted on 6 Sep 2011, 8:02 by Mark Boos
I also wrote some code, to calculate lft and rgt but it isnt optimal:

$i = 0;
#childs level1
$c_childs1= mysql_query("SELECT * from j16_assets WHERE parent_id=1");

while($rowchild1 = mysql_fetch_array($c_childs1))
{
$i=$i+1;
$updatelft = "UPDATE j16_assets set j16_assets.lft = ".$i." WHERE id=".$rowchild1['id'];
echo $updatelft."<br>";
$update = mysql_query($updatelft);
$query_child2="SELECT * from j16_assets WHERE parent_id=".$rowchild1['id'];
$c_childs2= mysql_query($query_child2);
$num_rows = mysql_num_rows($c_childs2);
if ($num_rows!=0) {
while($rowchild2 = mysql_fetch_array($c_childs2)) {
$i=$i+1;
$updatelft = "UPDATE j16_assets set j16_assets.lft = ".$i." WHERE id=".$rowchild2['id'];
echo $updatelft."<br>";
$update = mysql_query($updatelft);

$query_child3="SELECT * from j16_assets WHERE parent_id=".$rowchild2['id'];
$c_childs3= mysql_query($query_child3);
$num_rows = mysql_num_rows($c_childs3);
if ($num_rows!=0) {
while($rowchild3 = mysql_fetch_array($c_childs3)) {
$i=$i+1;
$updatelft = "UPDATE j16_assets set j16_assets.lft = ".$i." WHERE id=".$rowchild3['id'];
echo $updatelft."<br>";
$update = mysql_query($updatelft);

$query_child4="SELECT * from j16_assets WHERE parent_id=".$rowchild3['id'];
$c_childs4= mysql_query($query_child4);
$num_rows = mysql_num_rows($c_childs4);
if ($num_rows!=0) {
while($rowchild4 = mysql_fetch_array($c_childs4)) {
$i=$i+1;
$updatelft = "UPDATE j16_assets set j16_assets.lft = ".$i." WHERE id=".$rowchild4['id'];
echo $updatelft."<br>";
$update = mysql_query($updatelft);

$i=$i+1;
$updatergt = "UPDATE j16_assets set j16_assets.rgt = ".$i.", level=4 WHERE id=".$rowchild4['id'];
echo $updatergt."<br>";
$update = mysql_query($updatergt);

}
}
$i=$i+1;
$updatergt = "UPDATE j16_assets set j16_assets.rgt = ".$i.", level=3 WHERE id=".$rowchild3['id'];
echo $updatergt."<br>";
$update = mysql_query($updatergt);
}
}
$i=$i+1;
$updatergt = "UPDATE j16_assets set j16_assets.rgt = ".$i.", level=2 WHERE id=".$rowchild2['id'];
echo $updatergt."<br>";
$update = mysql_query($updatergt);
}

}
$i=$i+1;
$updatergt = "UPDATE j16_assets set j16_assets.rgt = ".$i.", level=1 WHERE id=".$rowchild1['id'];
echo $updatergt."<br>";
$update = mysql_query($updatergt);

}
$i=$i+354;
echo "root i: ".$i."<br>";
$updatergt = "UPDATE j16_assets set j16_assets.rgt = ".$i." WHERE id=1";
echo $updatergt."<br>";
$update = mysql_query($updatergt);

It should calculate the levels by itself, not going to maximum of 4 levels.
Posted on 1 Mar 2012, 0:24 by Ilari Kajaste
I've written a little command line php script that will rummage through a broken asset table, and try to fix it. Though it's designed for Joomla 2.5. Available at: https://github.com/ikajaste/Joomla-2.5-Asset-Weaver

(I bumped to this issue while researching the problem, and thought it might be good idea to mention this here in case someone else comes searching as well.)
Posted on 30 Dec 2012, 8:23 by Elin Waring
https://github.com/elinw/AssetFix also will help. Save() will already calculate lft and rgt for you correctly if the parent is correctly known.