Check inventory script

From OpenSimulator

Revision as of 22:04, 12 May 2022 by Tampa (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Check Inventory Script

Prior to 2022 the viewers accepted any form of inventory outside of completely malformed setups. This has now changed with new code added to viewers designed to validate whether the inventory structure is properly setup. Unfortunately due to bugs and changes in OpenSim some older inventories of users created prior to 2015 exhibit problematic structures that can cause inventory failing to load or login to be blocked entirely. This script aims to give grid operators a way to validate the inventory of a user or all users to see which are likely to encounter issues and what exactly is wrong. We also outline the steps and tools on how to fix these issues here.

The script

Currently a github gist for convenience, please direct issues or requests at IRC

Check Inventory Script

Usage

The script requires a server with PHP7.4 installed on it.

  • Open the script with your favorite editor and check the top setup for $database_info variables. Set them to connect to your grid database containing the inventoryfolders table.
  • Run the script via
     php check_inventory.php FirstName LastName 
    This will run the script looking for fatal inventory errors.
  • Run the script via
     php check_inventory.php FirstName LastName true
    Will run the script looking for optional duplicate folders of the same type.


The script can also be run for all users, but the output will be quite large. It is best to pipe the output to file if possible.

 php check_inventory.php everyone true
Will run the script looking for optional duplicate folders of the same type for all users in UserAccounts table.



If this seems complicated or dangerous that is because making changes to the database directly usually is. If this is something you rather leave to someone with more knowledge feel free to reach out to people on IRC for help or contact one of the many providers of OpenSim hosted services.

How to resolve issues

Inventory setup was meant to have a single root folder, called "My Inventory". All folders should be sorted underneath this folder.

The usual folders for Clothing, Objects and even Trash have specific types designed to give them their icons and provide a way to sort incoming items accordingly. Only one set of these is meant to exist, but OpenSim adds a second set of these folders to the inventory under the "My Suitcase" folder used for the HG1.0 protocol.

You can read more about the folder types in the Database documentation

To resolve issues the inventory structure needs to be returned to the proper setup accepted by the viewers. To do this you will need to edit the inventoryfolders database table. This can be done from the command line or via external programs such as DBeaver or Navicat whichever you prefer.


Create a backup

Using tools like sqldump or the aforementioned database tools create a backup of the inventoryfolders table first before making edits to the table!


Find the user

Using either filters or an SQL query to select just the user we are concerned with filter for the "AgentID" in inventoryfolders.

 SELECT * FROM inventoryfolders WHERE `AgentID` = 'user-uuid' ;

Check the specific folders

The script will check for folders that are not "-1" of type, which signifies a normal folder a user might create. To fetch just these folders add a filter to only show folders not of this type.

 SELECT * FROM inventoryfolders WHERE `AgentID` = 'user-uuid' AND `type` != '-1' ;

Find the duplicates

To find the folders under "My Suitcase" is easy now. You should see the "My Inventory" folder in the selected set of rows showing also the parentFolderID, which should be a null key i.e. "00000000-0000-0000-0000-000000000000". You can see it's folderID as well here. This UUID will be what all proper other inventory folders, such as Clothing, Objects and Trash, will show in their respective parentFolderID. This creates a hierarchy starting with "My Inventory" and cascading down to all folders in the inventory structure.

Now sorting the query by the folderName will easily show the duplicates and their parentFolderID pointing not to "My Inventory" but the "My Suitcase" folder and its folderID.

 SELECT * FROM inventoryfolders WHERE `AgentID` = 'user-uuid' AND `type` != '-1' ORDER BY folderName DESC;

Observe, the "My Suitcase" folder's parent folder is also "My Inventory" folder.

Remove duplicates

Unless you are running the HG1.0 protocol using the "My Suitcase" folder to share items on the hypergrid without exposing your entire inventory you don't actually need the folder or it's sub-folders.

However, removing the folder entirely when it might contain items the user placed there might not be the best idea. Instead simply change the type of each duplicate folder to "-1" to make them regular folders.

 UPDATE inventoryfolders SET `type` = '-1' WHERE `AgentID` = 'user-uuid' AND `parentFolderID` != 'folderID of My Inventory' AND `parentFolderID` != '00000000-0000-0000-0000-000000000000'; 

This will set all folders to type "-1" for that specific user if the parent folder is not "My Inventory", which will change all "My Suitcase" sub-folders.

Checking bad root folders

Newer versions of OpenSim will put the "My Suitcase" folder as a type that does not conflict, usually type "100", but older versions will have put it as type "8" or "9", which causes a fatal error. To resolve this change the type to "100".

 UPDATE inventoryfolders SET `type` = '100' WHERE `AgentID` = 'user-uuid' AND `folderName` = 'My Suitcase'; 

In some cases the "My Inventory" folder might still be of the old type "9", which will also causes issues. To resolve this it needs to be changed to type "8".

 UPDATE inventoryfolders SET `type` = '8' WHERE `AgentID` = 'user-uuid' AND `folderName` = 'My Inventory'; 

These queries can, but probably should not be, run for all users by omitting the where clause specifying the agent UUID. We strongly suggest you look at each users inventory separately and make changes as required!!

Personal tools
General
About This Wiki