System Integrity Scripts

Last Updated: 20 Sep 2017

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

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)

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)

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 performs a charset conversion on content within the system. This script uses PHP's iconv conversion module to perform the charset conversion for content stored in within Squiz  Matrix.

Any content that cannot be converted will be logged by this script. Manual review of this content is recommended. Please also note that the quality of the conversion is reliant on the original content. If your content contains improper or non-standard encoded characters, then it is likely that this content will not be converted and will be logged for review.

Content that will be converted by this script includes all attributes and metadata values for an asset. This script will also regenerate the metadata, design and bodycopy content files of affected assets, following the charset conversion.

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 new charset of the system.
  • The asset ID of the root node to process.
  • --report (optional): displays a report outlining any issues before performing the charset conversion.

If your original charset is ISO-8859-1, we recommend using Windows-1252 as the previous charset argument when running this script. Windows-1252 is a super set of ISO-8859-1 and will allow this script to fix Windows-1252 encoded characters copied across from Microsoft Word.

Example
$ php system_integrity_fix_char_encoding.php --system=[system_root] --old=UTF-8 --new=iso-8859-11 --rootnode=100 --report
Number of assets to look into : 148

Number of db records with invalid char(s): 1
        Asset: 2085 in table sq_ast_attr_val Possibly problematic characters: ... (26085), ... (26412)

Getting the list of assetids that needs content regeneration ... done.
Number of db records that need replacing: 0
Total time taken to run the script: 0.27 second(s)

Please check ./data/private/logs/system_integrity_fix_char_encoding.php.log file for errors

system_integrity_fix_duplicate_rollback_entries.php

The system_integrity_fix_duplicate_rollback_entries.php script is used to report and fix any overlapping (and thus duplicate) entries in the rollback table, determined by an entry's eff_to date value.

This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:

  • -s <system_root>: the root directory of your system.
  • --show-records: specifies to show any overlapping rollback table entries found (optional).
  • --fix-table=<table_name>: fixes the overlapping rollback entries in the specified table. Use all to fix overlapping entries in all tables (optional).

Example

$ php scripts/system_integrity_fix_duplicate_rollback_entries.php -s <SYSTEM_ROOT> --show-records --fix-table=all

IMPORTANT: You have selected the option to fix the duplicate rollback entries from the Rollback table "sq_rb_ast_attr_val"
This will remove all duplicate entries in the table(s) except the one with oldest "eff_from" date in the duplicate entries set.
Backing up db is recommended before running this script.
Are you sure you want to proceed (Y/n)? Y

Checking table sq_rb_ast ... [ OK ]
Checking table sq_rb_ast_lnk ... [OK]
Checking table sq_rb_shdw_ast_lnk ... [ OK ]
Checking table sq_rb_ast_lnk_tree ... [ OK ]
Checking table sq_rb_ast_attr_val ... 2 set(s) of overlapping entries found.
------------------------------------
0 => array (
    "assetid" => "260",
    "attrid" => "3081",
    "contextid" => "0",
    "sq_eff_to" => "2013-06-18 10:26:28",
    "occ" => "2"
),
1 => array (
    "assetid" => "260",
    "attrid" => "3081",
    "contextid" => "1",
    "sq_eff_to" => "2013-06-18 10:26:28",
    "occ" => "2"
)

------------------------------------
[ NOT OK ]
Fixing the rollback table sq_rb_ast_attr_val [ FIXED ]
 
Checking table sq_rb_ast_attr_uniq_val ... [ OK ]
Checking table sq_rb_ast_url ... [ OK ]
Checking table sq_rb_ast_path ... [ OK ]
Checking table sq_rb_ast_lookup ... [ OK ]
Checking table sq_rb_ast_lookup_value ... [ OK ]
Checking table sq_rb_ast_lookup_remap ... [ OK ]
Checking table sq_rb_ast_perm ... [ OK ]
Checking table sq_rb_ast_edit_access ... [ OK ]
Checking table sq_rb_ast_mdata ... [ OK ]
Checking table sq_rb_ast_mdata_val ... [ OK ]
Checking table sq_rb_ast_mdata_dflt_val ... [ OK ]
Checking table sq_rb_ast_wflow ... [ OK ]
Checking table sq_rb_trig ... [ OK ]
Checking table sq_rb_ast_role ... [ OK ]
Checking table sq_rb_ctx_def ... [ OK ]
Checking table sq_rb_saml_lnk ... [ OK ]
Checking table sq_rb_cal_date_val ... [ OK ] 

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_rollback_gaps.php

The system_integrity_fix_rollback_gaps.php script is used to identify time gaps in rollback tables, and fix them if required.

The script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:

  • -s <system_root>: the root directory of your system.
  • --show-details: specifies to show any found rollback record gaps.
  • --fix=<table_name>: fixes the rollback gaps in the specified table. Use all to fix gaps in all tables (optional).
Example
$ php scripts/system_integrity_fix_rollback_gaps.php -s <SYSTEM_ROOT> --show-details --fix=allIMPORTANT: You have selected the option to fix gaps in rollback entries for ALL Rollback tables.This will remove all time gaps in the specified rollback tables.Backing up db is recommended before running this script.Are you sure you want to proceed (Y/n)? YChecking table sq_rb_ast ... [ OK ]Checking table sq_rb_ast_lnk ... [ OK ]Checking table sq_rb_shdw_ast_lnk ... [ OK ]Checking table sq_rb_ast_lnk_tree ... 3 gaps found. ------------------------------------0 => array (    "treeid" => "0006",    "gap_starts" => "2014-02-13 11:00:08",    "gap_ends" => "2014-03-10 14:07:17" ),1 => array (    "treeid" => "000600000000",    "gap_starts" => "2014-02-13 11:00:08",    "gap_ends" => "2014-03-10 14:10:30" ),2 => array (    "treeid" => "0006000000000001",    "gap_starts" => "2014-02-13 11:00:08",    "gap_ends" => "2014-04-17 16:22:11" )------------------------------------[ NOT OK ]Fixing the rollback table sq_rb_ast_lnk_tree. 3 gaps removed. [ FIXED ]Checking table sq_rb_ast_attr_val ... [ OK ]Checking table sq_rb_ast_attr_uniq_val ... [ OK ]Checking table sq_rb_ast_url ... [ OK ]Checking table sq_rb_ast_path ... [ OK ]Checking table sq_rb_ast_lookup ... [ OK ]Checking table sq_rb_ast_lookup_value ... [ OK ]Checking table sq_rb_ast_lookup_remap ... [ OK ]Checking table sq_rb_ast_perm ... [ OK ]Checking table sq_rb_ast_edit_access ... [ OK ]Checking table sq_rb_ast_mdata ... [ OK ]Checking table sq_rb_ast_mdata_val ... [ OK ]Checking table sq_rb_ast_mdata_dflt_val ... [ OK ]Checking table sq_rb_ast_wflow ... [ OK ]Checking table sq_rb_trig ... [ OK ]Checking table sq_rb_ast_role ... [ OK ]Checking table sq_rb_ctx_def ... [ OK ]Checking table sq_rb_saml_lnk ... [ OK ]Checking table sq_rb_cal_date_val ... [ OK ]

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]

> 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_inconsistent_workflow_status.php

The system_integrity_inconsistent_workflow_status.php script will detect and fix assets with a status that is inconsistent with its current workflow statuses.

This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:

  • --system=<SYSTEM_ROOT> where <SYSTEM_ROOT> is the root directory of your Squiz Matrix system.
  • --email=<EMAIL_ADDRESS> : this optional parameter allows you to specify an email address to send the report generated by this script.
  • --fix : this optional parameter allows you to fix any inconsistencies detected by this script.
Example
$ php scripts/system_integrity_inconsistent_workflow_status.php --system=[system_root].                               

Following assets are found to be in running workflow state but not in workflow status
#154 has status 16  

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)

WYSIWYG #26          [ OK ]
WYSIWYG #30          [ OK ]  

system_integrity_invalid_links.php

The system_integrity_invalid_links.php script removes any significant links for all assets in the system where one of both sides of the link does not exist (invalid links).

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): yDeleted Link ID: 14848 with Major ID: 3091 and Minor ID: 8976There are 13 orphan assets found. You must run system_integrity_orphaned_assets.php on the root folder to rescue these assets. 

system_integrity_invalid_remaps.php

The system_integrity_invalid_remaps.php script cleans any invalid remaps, including useless remaps that lead to non-existent pages and infinite redirect loops.

This script is located in the /scripts directory of your Squiz Matrix system and takes the following parameters:

  • --system=<SYSTEM_ROOT> where <SYSTEM_ROOT> is the root directory of your Squiz Matrix system.
  • [--expired_remaps] : identify remaps that have expired (optional).
  • [--invalid_old_url] : identify remaps that have old, invalid URLs that match to existing assets (optional).
  • [--invalid_new_url] : identify remaps with invalid new, invalid URLs, for example, redirecting to an non-existent asset URL (optional).
  • [--redirect_chain] : identify redirect chains, shortening remaps if execute is specified (optional).
  • [--execute] : clean the invalid remaps found in above reports (optional).
Example
$ php scripts/system_integrity_invalid_remaps.php --system=<SYSTEM_ROOT> [--invalid_new_url]

## Invalid New URL ##
1 remaps deleted 

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.
  • The asset ID of the asset that orphaned assets will be mapped to.

Example

$ php system_integrity_orphaned_assets.php [system_root] 100
Enter the root password for "The System": ******
[ #1 ] Root Folder                                                     [ -- ]
[ #35 ] Tag Manager                                                    [ -- ]
[ #36 ] Manage Pending Accounts Scheduled Job                          [ -- ]
[ #2 ] System Management                                               [ -- ]

[ #16 ] Scheduled Jobs 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.

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

        WYSIWYG (#714)                            [TIDY PASS ]
        Content DIV (#713)                        [CONTENT PASS ]
        Page Contents (#712)                      [CONTENT PASS ]
        Library (#709)                            [CONTENT PASS ]

Previous Chapter Next Chapter

The Latest

Let Us Know What You Think

Let us know if you spot any errors or if you have any ideas on how we can improve the Matrix Community Website.

Contact Squiz for Demo

Let us show you the true power of Squiz Matrix by giving you a personalised demonstration.