System Integrity Scripts
This chapter describes the system integrity scripts available within Squiz Matrix. These scripts are designed to monitor the quality of your system and ensure it is functioning correctly.
Bookmarks to the headings on this page:
- system_integrity_check_indexes.php
- system_integrity_check_links.php
- system_integrity_clean_cache_dir.php
- system_integrity_clean_old_files.php
- system_integrity_content_links.php
-
system_integrity_deleted_user_
perms.php - system_integrity_fix_char_encoding.php
- system_integrity_fix_public_files.php
- system_integrity_fix_sort_orders.php
- system_integrity_foreign_keys.php
- system_integrity_form_submissions.php
-
system_integrity_incomplete_
attachments.php - system_integrity_internal_links.php
- system_integrity_invalid_links.php
- system_integrity_orphaned_assets.php
-
system_integrity_recover_file_
versions.php - system_integrity_run_tidy.php
system_integrity_check_indexes.php
The system_integrity_check_indexes.php script checks the Squiz Matrix database for any missing indexes. If missing indexes are found, this script will print an SQL query to run. Please note, however, the script will not automatically run returned SQL queries as any found issues may require a manual fix.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameter:
- The system root directory.
Example
$ php system_integrity_check_indexes.php [system_root]
------------------------------------
Checking Indexes
------------------------------------
Checking table sq_cal_date_val for a primary key [ OK ]
Checking table sq_rb_cal_date_val for a primary key [ OK ]
Checking table sq_hit_count for a primary key [ OK ] ...
Checking for index sq_sch_idx_type [ OK ]
Checking for index sq_sch_idx_component [ OK ]
Checking for index sq_sch_idx_contextid [ OK ]
------------------------------------
Checking locale settings
------------------------------------
------------------------------------
Check complete
------------------------------------
------------------------------------
Everything has been checked and no problems were found.
------------------------------------...
system_integrity_check_links.php
The system_integrity_check_links.php script checks that all hyperlinks to another asset (referenced as ./?a=xx) inside a WYSIWYG Editor (for example, a Standard Page) link to an existing asset. It highlights any asset that does not exist. You can then go to the content of the relevant asset within Squiz Matrix and fix the broken link.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameter:
- The system root directory.
Example
$ php system_integrity_check_links.php [system_root]
WARNING: You are running this integrity checker on the whole system.
This is fine but it may take a long time
YOU HAVE 5 SECONDS TO CANCEL THIS SCRIPT... 1 2 3 4 5
WYSIWYG #30 - LINK #3276 [ INVALID ]
system_integrity_clean_cache_dir.php
The system_integrity_clean_cache_dir.php script deletes any expired cache files in the cache directory of Squiz Matrix.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameter:
- The system root directory.
system_integrity_clean_old_files.php
The system_integrity_clean_old_files.php script checks for, and optionally deletes, files in the data directory that do not belong to an asset any more (orphaned files).
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- --delete-orphans (optional).
system_integrity_content_links.php
The system_integrity_content_links.php script verifies and updates asset NOTICE links for images or files in Bodycopy contents. This script locks each asset as it updates it, and also makes changes to the Squiz Matrix file system. It displays a Failed message for any asset that fails.
This script is for troubleshooting purposes and should only be run if you are experiencing problems with your system.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
Example
$ php system_integrity_content_links.php [system_root]
WARNING: You are running this integrity checker on the whole system.
This is fine but:
it may take a long time; and
it will acquire locks on many of your assets (meaning you wont be able to edit
content for a while)
Enter the root password for "The System": password
Container #22 [ OK ]
Container #26 [ OK ]
system_integrity_deleted_user_perms.php
The system_integrity_deleted_user_perms.php script deletes permissions that exist for deleted or non-existent users. For example, if an LDAP user is removed from the LDAP server, it does not notify Squiz Matrix, and hence the permissions for that user are not updated.
This script is for troubleshooting purposes and should only be run if you are experiencing problems with your system.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameter:
- The system root directory.
Example
$ php system_integrity_deleted_user_perms.php [system_root]
WARNING: You are running this integrity checker on the whole system.
This is fine but:
it may take a long time; and
it will acquire locks on many of your assets (meaning you wont be able to
edit content for a while)
Enter the root password for "The System": password
Cleaning up permissions...
Root User [ # 12 ] [ OK ]
Test User [ # 44 ] [ OK ]
Unknown Asset [ # 5001 ] [ FIXED ]
Unknown Asset [ # 5002 ] [ FIXED ]
Public User [ # 7 ] [ OK ]
Cleaning up roles...
Unknown Asset [ # 5001 ] [ FIXED ]
system_integrity_fix_char_encoding.php
The system_integrity_fix_char_encoding.php script replaces all non-utf8 smart quote chars by their respective regular counterpart chars. If a string is still invalid after these replacements, this script will perform charset conversion on the string.
Tip: You should backup your system before using this script.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- The previous charset of the system.
- The asset ID of the root node to process.
Example
$ php system_integrity_fix_char_encoding.php [system_root] UTF-8 100
Enter the root password for "The System": password
IMPORTANT: This script will replace all the smart quote chars by their regular counterpart chars. And if value string is still
invalid in the current system's charset then it performs charset conversion on string from older to current encoding
YOU MUST BACKUP YOUR SYSTEM BEFORE RUNNING THIS SCRIPT
Are you sure you want to proceed (Y/N)?
Y
Running the script in 5 4 3 2 1 0
Number of assets to look into : 55
Fixing characters in table sq_ast_attr_val .. Done.
Fixing characters in table sq_ast_mdata_val . Done.
Fixing characters in table sq_ast_mdata_dflt_val . Done.
Fixing characters in table sq_ast_attr_uniq_val . Done.
Number of db records with invalid char(s): 0
Number of db records replaced successfully: 0
Total errors recorded: 0
Total time taken to run the script: 0.06 second(s)
system_integrity_fix_public_files.php
The system_integrity_fix_public_files.php script is used to evaluate and fix the files on the public data directory, updating any out-of-date files, creating any missing files and removing any files that are private or should not be in the directory.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- The root ID of the asset to evaluate and repair under.
system_integrity_fix_sort_orders.php
The system_integrity_fix_sort_orders.php script is used to verify and correct the asset sort order in the database.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- The ID of the asset from which to start the repair.
An incorrect sort order can cause Asset Map errors, especially in paginated lists. This script is quite intensive and can potentially run for an extended period. It is recommended that these factors be considered before running this script on a Live system.
system_integrity_foreign_keys.php
The system_integrity_foreign_keys.php script reports on the integrity of foreign keys within a Squiz Matrix database. This script defines relations between certain key fields (for instance, the asset ID field in the sq_ast table) and fields in other tables. If it finds a field in any table with the same name as one defined as related, it will report any values in that table that do not exist in the key table.
This script does not attempt to fix the integrity of the database, rather it reports on potentially invalid foreign keys, as well as the number of invalid rows. This information could then be used by the user to write an SQL query to remove the invalid rows if desired.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameter:
- The system root directory.
Example
$ php system_integrity_foreign_keys.php [system_root]
Enter the root password for "The System": password
> checking table sq_ast...
sq_ast.assetid 0 found
sq_ast.created_userid 0 found
sq_ast.updated_userid 0 found
sq_ast.published_userid 0 found
sq_ast.status_changed_userid 0 found
sq_ast_typ.type_code 0 found
> checking table sq_ast_attr...
sq_ast_attr.attrid 0 found
sq_ast_typ.type_code 0 found
...
system_integrity_form_submissions.php
The system_integrity_form_submissions.php script ensures that form submissions only appear under their associated form assets.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameter:
- The system root directory.
Example
$ php system_integrity_form_submissions.php [system_root]
The following invalid Form Submissions will be deleted if you run this script with delete option:
Processing the form submission 1...
Processing the form submission 2...
Processing the form submission 3...
Processing the form submission 4...
Processing the form submission 5...
Processing the form submission 6...
There are 0 invalid form submission assets in the total of 6.
system_integrity_incomplete_attachments.php
The system_integrity_incomplete_attachments.php script will check for and/or delete any temporary incomplete attachments that were not autmatically removed from the Squiz Matrix file system. There are two modes to this script: check and fix, determined by the --check and --fix parameters. Running this script in check mode will display affected form asset IDs, whilst running this script in fix mode will remove the associated incomplete attachments. The list of incomplete attachments found and/or deleted is also displayed at the end of this script.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- Either --check or --fix.
Example
$ php system_integrity_incomplete_attachments.php [system_root] --check
$ php system_integrity_incomplete_attachments.php [system_root] --fix
system_integrity_internal_links.php
The system_integrity_internal_links.php script ensures all links to assets in the system in bodycopy contents are using the internal format of (./?a=xxx). For example, you may have www.example.com/?a=xxx. This script will convert this URL to./?a=xxx. It locks each asset as it updates it and displays a Failed message for any asset that fails.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- The asset ID to check links under (optional).
Example
$ php system_integrity_internal_links.php [system_root]
WARNING: You are running this integrity checker on the whole system.
This is fine but:
it may take a long time; and
it will acquire locks on many of your assets (meaning you wont be able to
edit content for a while)
Enter the root password for "The System": password
WYSIWYG #26 [ OK ]
WYSIWYG #30 [ OK ]
system_integrity_invalid_links.php
The system_integrity_invalid_links.php script removes any significant links under a specified asset ID, where one of both sides of the link does not exist.
Tip: This script will also report on any orphaned assets in the system and may recommend running the system_integrity_orphaned_assets.php script upon completion.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- Either -check or -delete.
Example
$php system_integrity_invalid_links.php [system_root] -delete
Found 1 invalid links
This script is about to be run SYSTEM WIDE in DELETE mode. Are you sure you want to continue (y/n): y Deleted Link ID: 14848 with Major ID: 3091 and Minor ID: 8976 There are 13 orphan assets found. You must run system_integrity_orphaned_assets.php on the root folder to rescue these assets.
system_integrity_orphaned_assets.php
The system_integrity_orphaned_assets.php script finds and links orphaned assets (i.e. ones with no links to them) underneath a specified asset ID, which should preferably be a folder.
This script is for troubleshooting purposes and should only be run if you are experiencing problems with your system.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameter:
- The system root directory.
Example
$ php system_integrity_orphaned_assets.php [system_root]
WARNING: You are running this integrity checker on the whole system.
This is fine, but it may take a long time
Enter the root password for "The System": password
[ #1 ] Root Folder [ -- ]
[ #35 ] Tag Manager [ -- ]
[ #36 ] Manage Pending Accounts Cron Job [ -- ]
[ #2 ] System Management [ -- ]
[ #16 ] Cron Manager [ -- ]
[ #68 ] Orphaned Asset [ OK ]
Below is an explanation for the output you may see from system_integrity_orphaned_assets.php
-
Indicates that the specified asset is not an orphan
[ # 50 ] Example Folder [ -- ]
-
Indicates that the asset is an orphan, and has been moved underneath the asset specified in the second argument passed to the script.
[ # 50 ] Example Folder [ OK ]
-
Indicates that the asset is an orphan, but was not able to be linked.
[ # 50 ] Example Folder [ FAILED ]
system_integrity_recover_file_versions.php
The system_integrity_recover_file_versions.php script will recover incorrect file versioning entries in Squiz Matrix.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- The running mode (test or recover).
- The asset ID of the root node to perform the recovery for.
The test running mode summarises any conflicts between file versions stored in the file system and the database.
Tip: You should backup your system before using this script.
system_integrity_run_tidy.php
The system_integrity_run_tidy.php script runs HTML Tidy across all WYSIWYG Editor cells in a system, or under a particular asset. Please note that this script requires HTML Tidy to be enabled and configured.
This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:
- The system root directory.
- The asset ID to run HTML Tidy under.
Example
$ php system_integrity_content_links.php [system_root]
WARNING: You are running this checker on the whole system.
This is fine but:
it may take along time; and
it will acquire locks on many of your assets (meaning you wont be able to edit
content for a while)
Enter the root password for "The System": password
WYSIWYG (#714) [TIDY PASS ]
Content DIV (#713) [CONTENT PASS ]
Page Contents (#712) [CONTENT PASS ]
Library (#709) [CONTENT PASS ]