Trash empty but shows number of files

Not a big deal this but we emptied the trash in 3.28.4 but it still has (104) beside the icon.


Either there's 104 files we're not seeing or the 104 should be zero.

Are you sure thats not the asset id?


Just a thought.



Steve

[quote]
Are you sure thats not the asset id?



Just a thought.



Steve

[/quote]

The asset id for the trash is 10

[quote]
The asset id for the trash is 10

[/quote]



Check the DB: select count(minorid) from sq_ast_lnk where majorid='10';



Maybe the database could have some bad entries on it? You can check this with the system_check script found in the scripts dir.

If it persists, it could mean your link tree is incorrect. I have no idea why it would be.


The link tree is a second copy of the system structure that we can use to do fast parent/child lookups. But it also caches the number of children for each asset so we don't have to figure that out each time.



While you can run a script to recreate it, it's often better to just force an update. Putting something into the trash might correct it when it updates that field.

    select count(minorid) from sq_ast_lnk where majorid='10'

gives 104


    php system_check.php -system=/home/web/mysource_matrix/ -verbose

gives the list of the 104 assets

saying they 'were not found on the system'


    Invalid Number of Kids on Link Tree Test         [  OK  ]
    Fragmented Attributes Test                       [  OK  ]
    Invalid Matrix Links Test                        [  !!  ]
    There are 1 content types with problems found


Putting stuff in the trash then purging it doesn't reset the number to zero

Is it safe to

    DELETE FROM sq_ast_lnk WHERE majorid='10'
?

[quote]

    select count(minorid) from sq_ast_lnk where majorid='10'

gives 104


    php system_check.php -system=/home/web/mysource_matrix/ -verbose

gives the list of the 104 assets

saying they 'were not found on the system'


    Invalid Number of Kids on Link Tree Test         [  OK  ]
    Fragmented Attributes Test                       [  OK  ]
    Invalid Matrix Links Test                        [  !!  ]
    There are 1 content types with problems found


Putting stuff in the trash then purging it doesn't reset the number to zero

Is it safe to

    DELETE FROM sq_ast_lnk WHERE majorid='10'
?
[/quote]

It may correct the problem, but it may damage your system by doing that. You would have to be confident in the command fixing the problem while not affecting the rest of your system. Based on the output you posted I think it should be fine, but I am not familiar with your system. I would suggest if you are a Squiz client, contact Support to help you with this, otherwise read on...

Double check what is in there first by: SELECT minorid FROM sq_ast_lnk WHERE majorid='10';

Then if those assets are safe to delete from your system, then do the following:

Back up your system first (always backup when playing with the database).

Then run:
    BEGIN;
    DELETE FROM sq_ast_lnk WHERE majorid='10' AND minorid NOT IN (SELECT assetid FROM sq_ast);


Then if you get the correct number deleted and the original query returns 0, type: COMMIT otherwise issue ROLLBACK to revert the changes. (I would double check the system here before committing, if you want some good queries to check the database look in the scripts/system_tests, these are used by the system check script. Unfortunately you cannot use the script to double check until you commit the changes)

The sq_ast_lnk_tree should update like Greg said.

This relates to a bug I lodged…


http://bugs.matrix.squiz.net/view_bug.php?bug_id=4762



Most people don't notice this because they don't have anything that views the links in their normal work, but on big systems this isn't remotely uncommon:

    
    matrix=# select count(*) from sq_ast_lnk where (majorid not in (select assetid from sq_ast) or minorid not in (select assetid from sq_ast)) and majorid not like '%:%' and minorid not like '%:%';
    count
    -------
    21249
    (1 row)


I'd probably be inclined to wait for Labs to develop a sensible cleanup mechanism for that issue, than trying to fix this manually as you have to check both the lnk and lnk_tree tables as well as the shdw_lnk table and possibly others.



Edit: actually I just reread Ben's post, I think maybe that's the script I'm asking for in the bug report...

Those links with non-existing assetids are most likely caused by aborting of asset creation process.
For example,

in previous Matrix system, if user tries to create asset using asset builder and failed due to some error, it will leave those bad links in the db.





Fortunately, there are some fixes in recent Matrix system should have already addressed this issue. See below bug reports.



#4359 (fixed in 3.28.1)

#4576 (fixed in 3.28.4)

The sql delete works fine and seems to have no adverse affects to Matrix.


However, running the system check reports that we had orphaned assets. Subsequently, we ran the orphaned assets script and put these assets in a folder - orphan issue resolved.



We then ran the system check once more and it reported that there were dead assets. I decided to call it a day then and we restored the database back.