Check inventory script

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Check Inventory Script)
m (Remove duplicates)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{Quicklinks}}
 +
 
== Check Inventory Script ==
 
== Check Inventory Script ==
  
Line 20: Line 22:
  
  
=== How to resolve issues ===
+
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.
 +
 
 +
<pre style="color: red"> php check_inventory.php everyone true</pre> Will run the script looking for optional duplicate folders of the same type for all users in UserAccounts table.
 +
 
 +
 
 +
 
 +
 
 +
<div style="background-color:#FFA0A0; padding:10px; padding-bottom:5px; border: 1px #FF544F solid">
 +
'''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 [http://opensimulator.org/wiki/FAQ#OpenSimulator_in_the_Wild providers of OpenSim hosted services].'''
 +
</div>
 +
 
 +
== 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.
 
Inventory setup was meant to have a single root folder, called "My Inventory". All folders should be sorted underneath this folder.
Line 29: Line 42:
  
 
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 [https://dbeaver.io/ DBeaver] or [https://www.navicat.com/en/ Navicat] whichever you prefer.
 
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 [https://dbeaver.io/ DBeaver] or [https://www.navicat.com/en/ 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 ====
 
==== Find the user ====
Line 60: Line 79:
 
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.
 
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.
  
<pre style="color: darkblue"> UPDATE inventoryfolders SET `type` = '-1' WHERE `AgentID` = 'user-uuid' AND `parentFolderID` != 'folderID of My Inventory'; </pre>
+
<pre style="color: darkblue"> UPDATE inventoryfolders SET `type` = '-1' WHERE `AgentID` = 'user-uuid' AND `parentFolderID` != 'folderID of My Inventory' AND `parentFolderID` != '00000000-0000-0000-0000-000000000000'; </pre>
  
 
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.
 
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.
Line 66: Line 85:
 
==== Checking bad root 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 "-1" as well.
+
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".
  
<pre style="color: darkblue"> UPDATE inventoryfolders SET `type` = '-1' WHERE `AgentID` = 'user-uuid' AND `folderName` = 'My Suitcase'; </pre>
+
<pre style="color: darkblue"> UPDATE inventoryfolders SET `type` = '100' WHERE `AgentID` = 'user-uuid' AND `folderName` = 'My Suitcase'; </pre>
  
 
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".
 
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".

Latest revision as of 21:04, 12 May 2022

Contents

[edit] 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.

[edit] The script

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

Check Inventory Script

[edit] 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.

[edit] 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.


[edit] 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!


[edit] 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' ;

[edit] 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' ;

[edit] 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.

[edit] 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.

[edit] 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