ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilValidator Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilValidator:

Public Member Functions

 __construct (bool $a_log=false)
 
 getPossibleModes ()
 get possible ilValidator modes More...
 
 setMode (string $a_mode, bool $a_value)
 set mode of ilValidator Usage: setMode("restore",true) => enable object restorey setMode("all",true) => enable all features For all possible modes see variables declaration More...
 
 isModeEnabled (string $a_mode)
 
 isLogEnabled ()
 
 setModeDependencies ()
 Sets modes by considering mode dependencies; some modes require other modes to be activated. More...
 
 validate ()
 Performs the validation for each enabled mode. More...
 
 findMissingObjects ()
 Search database for all object entries with missing reference and/or tree entry and stores result in $this->missing_objects. More...
 
 findInvalidRolefolders ()
 Search database for all rolefolder object entries with missing reference entry. More...
 
 findInvalidRBACEntries ()
 Search database for all role entries that are linked to invalid ref_ids, stores results in $this->invalid_rolefolders. More...
 
 getMissingObjects ()
 Gets all object entries with missing reference and/or tree entry. More...
 
 findInvalidReferences ()
 Search database for all reference entries that are not linked with a valid object id and stores result in $this->invalid_references. More...
 
 getInvalidReferences ()
 Gets all reference entries that are not linked with a valid object id. More...
 
 findInvalidChilds ()
 Search database for all tree entries without any link to a valid object and stores result in $this->invalid_childs. More...
 
 getInvalidChilds ()
 Gets all tree entries without any link to a valid object. More...
 
 findUnboundObjects ()
 Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result does not contain childs that are marked as deleted! Deleted childs have a negative number. More...
 
 findDeletedObjects ()
 Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result also contains childs that are marked as deleted! Deleted childs has a negative number in ["deleted"] otherwise NULL. More...
 
 getUnboundObjects ()
 Gets all tree entries having no valid parent (=> no valid path to root node) Returns an array with child => actual entry with broken uplink to its parent parent => parent of child that does not exist grandparent => grandparent of child (where path to root node continues) deleted => containing a negative number (= parent in trash) or NULL (parent does not exist at all) More...
 
 getDeletedObjects ()
 Gets all object in trash. More...
 
 getInvalidRolefolders ()
 Gets invalid rolefolders (same as missing objects) More...
 
 removeInvalidReferences (array $a_invalid_refs=null)
 Removes all reference entries that are linked with invalid object IDs. More...
 
 removeInvalidChilds (array $a_invalid_childs=null)
 Removes all tree entries without any link to a valid object. More...
 
 removeInvalidRolefolders (array $a_invalid_rolefolders=null)
 Removes invalid rolefolders. More...
 
 restoreMissingObjects (array $a_missing_objects=null)
 Restores missing reference and/or tree entry for all objects found by this::getMissingObjects() Restored object are placed in RecoveryFolder. More...
 
 restoreReference (int $a_obj_id)
 restore a reference for an object Creates a new reference entry in DB table object_reference for $a_obj_id More...
 
 restoreUnboundObjects (array $a_unbound_objects=null)
 Restore objects (and their subobjects) to RecoveryFolder that are valid but not linked correctly in the hierarchy because they point to an invalid parent_id. More...
 
 restoreTrash (array $a_deleted_objects=null)
 Restore all objects in trash to RecoveryFolder NOTE: All objects will be restored to top of RecoveryFolder regardless of existing hierarchical structure! More...
 
 restoreDeletedObjects (array $a_nodes)
 Restore deleted objects (and their subobjects) to RecoveryFolder. More...
 
 restoreSubTrees (array $a_nodes)
 Restore objects (and their subobjects) to RecoveryFolder. More...
 
 purgeTrash (array $a_nodes=null)
 Removes all objects in trash from system. More...
 
 purgeUnboundObjects (array $a_nodes=null)
 Removes all invalid objects from system. More...
 
 purgeMissingObjects (array $a_nodes=null)
 Removes all missing objects from system. More...
 
 purgeObjects (array $a_nodes)
 removes objects from system More...
 
 initGapsInTree ()
 Initializes gaps in lft/rgt values of a tree. More...
 
 handleErr (object $error)
 Callback function handles PEAR_error and outputs detailed infos about error TODO: implement that in global errorhandler of ILIAS (via templates) More...
 
 writeScanLogArray (array $a_arr)
 
 writeScanLogLine (string $a_msg)
 
 hasScanLog ()
 Quickly determine if there is a scan log. More...
 
 deleteScanLog ()
 Delete scan log. More...
 
 readScanLog ()
 
 get_last_scan (array $a_scan_log)
 
 checkTreeStructure ()
 
 dumpTree ()
 Dumps the Tree structure into the scan log. More...
 

Data Fields

array $rbac_object_types
 
array $workspace_object_ids = []
 
array $invalid_rbac_entries
 
array $object_types_exclude
 list of object types to exclude from recovering More...
 
array $mode
 
array dump_tree
 
array $invalid_references = []
 
array $invalid_childs = []
 
array $missing_objects = []
 
array $unbound_objects = []
 
array $deleted_objects = []
 
array $invalid_rolefolders = []
 contains missing objects that are rolefolders. More...
 
array $invalid_objects = []
 contains correct registrated objects but data are corrupted (experimental) More...
 
bool $logging = false
 
ilLog $scan_log = null
 
string $scan_log_file = "scanlog.log"
 
string $scan_log_separator = "<!-- scan log start -->"
 

Protected Member Functions

 isMediaFolder (int $a_obj_id)
 
 isExcludedFromRecovery (string $a_type, int $a_obj_id)
 
 initWorkspaceObjects ()
 
 filterWorkspaceObjects (array &$a_data, string $a_index="obj_id")
 

Protected Attributes

ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLanguage $lng
 
ilLogger $log
 
ilRbacAdmin $rbacadmin
 
ilTree $tree
 
ilObjUser $user
 
array $media_pool_ids = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning ILIAS Data Validator & Recovery Tool

Author
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e

Definition at line 24 of file class.ilValidator.php.

Constructor & Destructor Documentation

◆ __construct()

ilValidator::__construct ( bool  $a_log = false)

Definition at line 88 of file class.ilValidator.php.

References $DIC, $ilDB, CLIENT_DATA_DIR, deleteScanLog(), ILIAS\Repository\lng(), ILIAS\Repository\user(), and writeScanLogLine().

90  {
91  global $DIC;
92 
93  $this->obj_definition = $DIC["objDefinition"];
94  $this->db = $DIC->database();
95  $this->lng = $DIC->language();
96  $this->log = $DIC["ilLog"];
97  $this->rbacadmin = $DIC->rbac()->admin();
98  $this->tree = $DIC->repositoryTree();
99  $this->user = $DIC->user();
100  $objDefinition = $DIC["objDefinition"];
101  $ilDB = $DIC->database();
102 
103  $this->db = &$ilDB;
104  $this->rbac_object_types = $objDefinition->getAllRBACObjects();
105 
106  if ($a_log === true) {
107  $this->logging = true;
108 
109  // should be available thru inc.header.php
110  // TODO: move log functionality to new class ilScanLog
111  // Delete old scan log
112  $this->deleteScanLog();
113 
114  // create scan log
115  $this->scan_log = new ilLog(CLIENT_DATA_DIR, "scanlog.log");
116  $this->scan_log->setLogFormat("");
117  $this->writeScanLogLine($this->scan_log_separator);
118  $this->writeScanLogLine("\n[Systemscan from " . date("y-m-d H:i]"));
119  }
120  }
writeScanLogLine(string $a_msg)
deleteScanLog()
Delete scan log.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: class.ilLog.php:30
global $DIC
Definition: feed.php:28
const CLIENT_DATA_DIR
Definition: constants.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ checkTreeStructure()

ilValidator::checkTreeStructure ( )

Definition at line 1757 of file class.ilValidator.php.

References writeScanLogLine().

Referenced by validate().

1757  : bool
1758  {
1759  $this->writeScanLogLine("\nchecking tree structure is disabled");
1760 
1761  return false;
1762  }
writeScanLogLine(string $a_msg)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteScanLog()

ilValidator::deleteScanLog ( )

Delete scan log.

Definition at line 1724 of file class.ilValidator.php.

References CLIENT_DATA_DIR.

Referenced by __construct().

1724  : void
1725  {
1726  unlink(CLIENT_DATA_DIR . "/" . $this->scan_log_file);
1727  }
const CLIENT_DATA_DIR
Definition: constants.php:46
+ Here is the caller graph for this function:

◆ dumpTree()

ilValidator::dumpTree ( )

Dumps the Tree structure into the scan log.

Returns
int number of errors found while dumping tree

Definition at line 1768 of file class.ilValidator.php.

References $GLOBALS, $i, ilDBConstants\FETCHMODE_OBJECT, initWorkspaceObjects(), and writeScanLogLine().

Referenced by validate().

1768  : int
1769  {
1770  $this->writeScanLogLine("BEGIN dumpTree:");
1771 
1772  // collect nodes with duplicate child Id's
1773  // (We use this, to mark these nodes later in the output as being
1774  // erroneous.).
1775  $q = 'SELECT child FROM tree GROUP BY child HAVING COUNT(*) > 1';
1776  $r = $this->db->query($q);
1777  $duplicateNodes = [];
1778  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1779  $duplicateNodes[] = $row->child;
1780  }
1781 
1782  // dump tree
1783  $q = "SELECT tree.*,ref.ref_id,dat.obj_id objobj_id,ref.obj_id refobj_id,ref.deleted,dat.* "
1784  . "FROM tree "
1785  . "RIGHT JOIN object_reference ref ON tree.child = ref.ref_id "
1786  . "RIGHT JOIN object_data dat ON ref.obj_id = dat.obj_id "
1787 // ."LEFT JOIN usr_data usr ON usr.usr_id = dat.owner "
1788  . "ORDER BY tree, lft, type, dat.title";
1789  $r = $this->db->query($q);
1790 
1791  $this->writeScanLogLine(
1792  '<table><tr>'
1793  . '<td>tree, child, parent, lft, rgt, depth</td>'
1794  . '<td>ref_id, ref.obj_id, deleted</td>'
1795  . '<td>obj_id, type, owner, title</td>'
1796  . '</tr>'
1797  );
1798 
1799  // We use a stack to represent the path to the current node.
1800  // This allows us to do analyze the tree structure without having
1801  // to implement a recursive algorithm.
1802  $stack = [];
1803  $error_count = 0;
1804  $repository_tree_count = 0;
1805  $trash_trees_count = 0;
1806  $other_trees_count = 0;
1807  $not_in_tree_count = 0;
1808 
1809  // The previous number is used for gap checking
1810  $previousNumber = 0;
1811 
1812  $this->initWorkspaceObjects();
1813 
1814  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1815  // workspace objects are not to be processed
1816  if ($this->workspace_object_ids &&
1817  in_array($row->objobj_id, $this->workspace_object_ids)) {
1818  continue;
1819  }
1820 
1821  // If there is no entry in table tree for the object, we display it here
1822  if (is_null($row->child)) {
1823  switch ($row->type) {
1824  case 'crsg':
1825  case 'usr':
1826  case 'typ':
1827  case 'lng':
1828  case 'rolt':
1829  case 'role':
1830  case 'mob':
1831  case 'sty':
1832  case 'tax': // #13798
1833  // We are not interested in dumping these object types.
1834  continue 2;
1835  //break; NOT REACHED
1836  case 'file':
1837  if (is_null($row->ref_id)) {
1838  // File objects can be part of a learning module.
1839  // In this case, they do not have a row in table object_reference.
1840  // We are not interested in dumping these file objects.
1841  continue 2;
1842  }
1843 
1844  // File objects which have a row in table object_reference, but
1845  // none in table tree are an error.
1846  $error_count++;
1847  $isRowOkay = false;
1848  $isParentOkay = false;
1849  $isLftOkay = false;
1850  $isRgtOkay = false;
1851  $isDepthOkay = false;
1852  break;
1853 
1854  default:
1855  // ignore folders on media pools
1856  if ($row->type === "fold" && $this->isMediaFolder($row->obj_id)) {
1857  continue 2;
1858  }
1859  $error_count++;
1860  $isRowOkay = false;
1861  $isParentOkay = false;
1862  $isLftOkay = false;
1863  $isRgtOkay = false;
1864  $isDepthOkay = false;
1865  break;
1866  }
1867 
1868  // moved here (below continues in switch)
1869  $not_in_tree_count++;
1870 
1871  $this->writeScanLogLine(
1872  '<tr>'
1873  . '<td>'
1874  . (($isRowOkay) ? '' : '<font color=#ff0000>')
1875  . $row->tree . ', '
1876  . $row->child . ', '
1877  . (($isParentOkay) ? '' : 'parent:<b>')
1878  . $row->parent
1879  . (($isParentOkay) ? '' : '</b>')
1880  . ', '
1881  . (($isLftOkay) ? '' : 'lft:<b>')
1882  . $row->lft
1883  . (($isLftOkay) ? '' : '</b>')
1884  . ', '
1885  . (($isRgtOkay) ? '' : 'rgt:<b>')
1886  . $row->rgt
1887  . (($isRgtOkay) ? '' : '</b>')
1888  . ', '
1889  . (($isDepthOkay) ? '' : 'depth:<b>')
1890  . $row->depth
1891  . (($isDepthOkay) ? '' : '</b>')
1892  . (($isRowOkay) ? '' : '</font>')
1893  . '</td><td>'
1894  . (($isRowOkay) ? '' : '<font color=#ff0000>')
1895  . (($isRefRefOkay && $isChildOkay) ? '' : 'ref.ref_id:<b>')
1896  . $row->ref_id
1897  . (($isRefRefOkay && $isChildOkay) ? '' : '</b>')
1898  . ', '
1899  . (($isRefObjOkay) ? '' : 'ref.obj_id:<b>')
1900  . $row->refobj_id
1901  . (($isRefObjOkay) ? '' : '</b>')
1902  . (($isRowOkay) ? '' : '<font color=#ff0000>')
1903  . (($row->deleted != null) ? ', ' . $row->deleted : '')
1904  . '</td><td>'
1905  . (($isRowOkay) ? '' : '<font color=#ff0000>')
1906  . $indent
1907  . $row->obj_id . ', '
1908  . $row->type . ', '
1909  . $row->login . ', '
1910  . $row->title
1911  . (($isRowOkay) ? '' : ' <b>*ERROR*</b><font color=#ff0000>')
1912  . '</td>'
1913  . '</tr>'
1914  );
1915  continue;
1916  }
1917 
1918  // Update stack
1919  // -------------------
1920  $indent = "";
1921  for ($i = 1; $i < $row->depth; $i++) {
1922  $indent .= ". ";
1923  }
1924 
1925  // Initialize the stack and the previous number if we are in a new tree
1926  if (count($stack) === 0 || $stack[0]->tree != $row->tree) {
1927  $stack = [];
1928  $previousNumber = $row->lft - 1;
1929  $this->writeScanLogLine('<tr><td>&nbsp;</td></tr>');
1930  }
1931  // Pop old stack entries
1932 
1933 
1934  while (count($stack) > 0 && $stack[count($stack) - 1]->rgt < $row->lft) {
1935  $popped = array_pop($stack);
1936 
1937  // check for gap
1938  $gap = $popped->rgt - $previousNumber - 1;
1939  if ($gap > 0) {
1940  $poppedIndent = "";
1941  for ($i = 1; $i < $popped->depth; $i++) {
1942  $poppedIndent .= ". ";
1943  }
1944  $this->writeScanLogLine(
1945  '<tr>'
1946  . '<td colspan=2><div align="right">'
1947  . '<font color=#00cc00>*gap* for ' . ($gap / 2) . ' nodes at end of&nbsp;</font>'
1948  . '</div></td>'
1949  . '<td>'
1950  . '<font color=#00cc00>'
1951  . $poppedIndent
1952  . $popped->obj_id . ', '
1953  . $popped->type . ', '
1954  . $popped->login . ', '
1955  . $popped->title
1956  . '</font>'
1957  . '</td>'
1958  . '</tr>'
1959  );
1960  }
1961  $previousNumber = $popped->rgt;
1962  unset($popped);
1963  }
1964 
1965  // Check row integrity
1966  // -------------------
1967  $isRowOkay = true;
1968 
1969  // Check tree structure
1970  $isChildOkay = true;
1971  $isParentOkay = true;
1972  $isLftOkay = true;
1973  $isRgtOkay = true;
1974  $isDepthOkay = true;
1975  $isGap = false;
1976 
1977  if (count($stack) > 0) {
1978  $parent = $stack[count($stack) - 1];
1979  if ($parent->depth + 1 != $row->depth) {
1980  $isDepthOkay = false;
1981  $isRowOkay = false;
1982  }
1983  if ($parent->child != $row->parent) {
1984  $isParentOkay = false;
1985  $isRowOkay = false;
1986  }
1987  if ($GLOBALS['ilSetting']->get('main_tree_impl', 'ns') === 'ns') {
1988  if ($parent->lft >= $row->lft) {
1989  $isLftOkay = false;
1990  $isRowOkay = false;
1991  }
1992  if ($parent->rgt <= $row->rgt) {
1993  $isRgtOkay = false;
1994  $isRowOkay = false;
1995  }
1996  }
1997  }
1998 
1999  // Check lft rgt
2000  if ($row->lft >= $row->rgt && $GLOBALS['ilSetting']->get('main_tree_impl', 'ns') === 'ns') {
2001  $isLftOkay = false;
2002  $isRgtOkay = false;
2003  $isRowOkay = false;
2004  }
2005  if (in_array($row->child, $duplicateNodes)) {
2006  $isChildOkay = false;
2007  $isRowOkay = false;
2008  }
2009 
2010  // Check object reference
2011  $isRefRefOkay = true;
2012  $isRefObjOkay = true;
2013  if ($row->ref_id == null) {
2014  $isRefRefOkay = false;
2015  $isRowOkay = false;
2016  }
2017  if ($row->obj_id == null) {
2018  $isRefObjOkay = false;
2019  $isRowOkay = false;
2020  }
2021 
2022  if (!$isRowOkay) {
2023  $error_count++;
2024  }
2025 
2026  // Check for gap between siblings,
2027  // and eventually write a log line
2028  if ($GLOBALS['ilSetting']->get('main_tree_impl', 'ns') === 'ns') {
2029  $gap = $row->lft - $previousNumber - 1;
2030  $previousNumber = $row->lft;
2031  if ($gap > 0) {
2032  $this->writeScanLogLine(
2033  '<tr>'
2034  . '<td colspan=2><div align="right">'
2035  . '<font color=#00cc00>*gap* for ' . ($gap / 2) . ' nodes between&nbsp;</font>'
2036  . '</div></td>'
2037  . '<td>'
2038  . '<font color=#00cc00>siblings</font>'
2039  . '</td>'
2040  . '</tr>'
2041  );
2042  }
2043  }
2044 
2045  // Write log line
2046  // -------------------
2047  $this->writeScanLogLine(
2048  '<tr>'
2049  . '<td>'
2050  . (($isRowOkay) ? '' : '<font color=#ff0000>')
2051  . $row->tree . ', '
2052  . $row->child . ', '
2053  . (($isParentOkay) ? '' : 'parent:<b>')
2054  . $row->parent
2055  . (($isParentOkay) ? '' : '</b>')
2056  . ', '
2057  . (($isLftOkay) ? '' : 'lft:<b>')
2058  . $row->lft
2059  . (($isLftOkay) ? '' : '</b>')
2060  . ', '
2061  . (($isRgtOkay) ? '' : 'rgt:<b>')
2062  . $row->rgt
2063  . (($isRgtOkay) ? '' : '</b>')
2064  . ', '
2065  . (($isDepthOkay) ? '' : 'depth:<b>')
2066  . $row->depth
2067  . (($isDepthOkay) ? '' : '</b>')
2068  . (($isRowOkay) ? '' : '</font>')
2069  . '</td><td>'
2070  . (($isRowOkay) ? '' : '<font color=#ff0000>')
2071  . (($isRefRefOkay && $isChildOkay) ? '' : 'ref.ref_id:<b>')
2072  . $row->ref_id
2073  . (($isRefRefOkay && $isChildOkay) ? '' : '</b>')
2074  . ', '
2075  . (($isRefObjOkay) ? '' : 'ref.obj_id:<b>')
2076  . $row->refobj_id
2077  . (($isRefObjOkay) ? '' : '</b>')
2078  . (($isRowOkay) ? '' : '<font color=#ff0000>')
2079  . (($row->tree < 0) ? ', ' . $row->deleted : '')
2080  . '</td><td>'
2081  . (($isRowOkay) ? '' : '<font color=#ff0000>')
2082  . $indent
2083  . $row->obj_id . ', '
2084  . $row->type . ', '
2085  . $row->login . ', '
2086  . $row->title
2087  . (($isRowOkay) ? '' : ' <b>*ERROR*</b><font color=#ff0000>')
2088  . '</td>'
2089  . '</tr>'
2090  );
2091 
2092  // Update stack
2093  // -------------------
2094  // Push node on stack
2095  $stack[] = $row;
2096 
2097  // Count nodes
2098  // -----------------
2099  if ($row->tree == 1) {
2100  $repository_tree_count++;
2101  } elseif ($row->tree < 0) {
2102  $trash_trees_count++;
2103  } else {
2104  $other_trees_count++;
2105  }
2106  }
2107  //
2108  // Pop remaining stack entries
2109 
2110  while (count($stack) > 0) {
2111  $popped = array_pop($stack);
2112 
2113  // check for gap
2114  $gap = $popped->rgt - $previousNumber - 1;
2115  if ($gap > 0) {
2116  $poppedIndent = "";
2117  for ($i = 1; $i < $popped->depth; $i++) {
2118  $poppedIndent .= ". ";
2119  }
2120  $this->writeScanLogLine(
2121  '<tr>'
2122  . '<td colspan=2><div align="right">'
2123  . '<font color=#00cc00>*gap* for ' . ($gap / 2) . ' nodes at end of&nbsp;</font>'
2124  . '</div></td>'
2125  . '<td>'
2126  . '<font color=#00cc00>'
2127  . $poppedIndent
2128  . $popped->obj_id . ', '
2129  . $popped->type . ', '
2130  . $popped->login . ', '
2131  . $popped->title
2132  . '</font>'
2133  . '</td>'
2134  . '</tr>'
2135  );
2136  }
2137  $previousNumber = $popped->rgt;
2138  unset($popped);
2139  }
2140 
2141  //
2142  $this->writeScanLogLine("</table>");
2143 
2144  if ($error_count > 0) {
2145  $this->writeScanLogLine('<font color=#ff0000>' . $error_count . ' errors found while dumping tree.</font>');
2146  } else {
2147  $this->writeScanLogLine('No errors found while dumping tree.');
2148  }
2149  $this->writeScanLogLine("$repository_tree_count nodes in repository tree");
2150  $this->writeScanLogLine("$trash_trees_count nodes in trash trees");
2151  $this->writeScanLogLine("$other_trees_count nodes in other trees");
2152  $this->writeScanLogLine("$not_in_tree_count nodes are not in a tree");
2153  $this->writeScanLogLine("END dumpTree");
2154 
2155  return $error_count;
2156  }
writeScanLogLine(string $a_msg)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ filterWorkspaceObjects()

ilValidator::filterWorkspaceObjects ( array &  $a_data,
string  $a_index = "obj_id" 
)
protected

Definition at line 2209 of file class.ilValidator.php.

References initWorkspaceObjects().

Referenced by findInvalidRBACEntries(), findInvalidReferences(), findInvalidRolefolders(), findMissingObjects(), removeInvalidReferences(), removeInvalidRolefolders(), and restoreMissingObjects().

2212  : void {
2213  if (count($a_data)) {
2214  $this->initWorkspaceObjects();
2215 
2216  // remove workspace objects from result objects
2217  if (is_array($this->workspace_object_ids)) {
2218  foreach ($a_data as $idx => $item) {
2219  if (in_array($item[$a_index], $this->workspace_object_ids)) {
2220  unset($a_data[$idx]);
2221  }
2222  }
2223  }
2224  }
2225  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDeletedObjects()

ilValidator::findDeletedObjects ( )

Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result also contains childs that are marked as deleted! Deleted childs has a negative number in ["deleted"] otherwise NULL.

Returns
bool false if analyze mode disabled or nothing found

Definition at line 786 of file class.ilValidator.php.

References $query, ilDBConstants\FETCHMODE_OBJECT, IL_CAL_DATETIME, IL_CAL_UNIX, writeScanLogArray(), and writeScanLogLine().

Referenced by validate().

786  : bool
787  {
788  // check mode: analyze
789  if ($this->mode["scan"] !== true) {
790  return false;
791  }
792 
793  // init
794  $this->deleted_objects = [];
795 
796  $this->writeScanLogLine("\nfindDeletedObjects:");
797 
798  // Delete objects, start with the oldest objects first
799  $query = "SELECT object_data.*,tree.tree,tree.child,tree.parent,deleted " .
800  "FROM object_data " .
801  "LEFT JOIN object_reference ON object_data.obj_id=object_reference.obj_id " .
802  "LEFT JOIN tree ON tree.child=object_reference.ref_id " .
803  " WHERE tree != 1 " .
804  " ORDER BY deleted";
805  $r = $this->db->query($query);
806 
807  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
808  $tmp_date = new ilDateTime($row->deleted, IL_CAL_DATETIME);
809 
810  $this->deleted_objects[] = [
811  "child" => $row->child,
812  "parent" => $row->parent,
813  "tree" => $row->tree,
814  "type" => $row->type,
815  "title" => $row->title,
816  "desc" => $row->description,
817  "owner" => $row->owner,
818  "deleted" => $row->deleted,
819  "deleted_timestamp" => $tmp_date->get(IL_CAL_UNIX),
820  "create_date" => $row->create_date,
821  "last_update" => $row->last_update
822  ];
823  }
824 
825  if (count($this->deleted_objects) > 0) {
826  $this->writeScanLogArray([array_keys($this->deleted_objects[0])]);
827  $this->writeScanLogArray($this->deleted_objects);
828  return true;
829  }
830  $this->writeScanLogLine("none");
831  return false;
832  }
const IL_CAL_DATETIME
writeScanLogLine(string $a_msg)
const IL_CAL_UNIX
writeScanLogArray(array $a_arr)
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findInvalidChilds()

ilValidator::findInvalidChilds ( )

Search database for all tree entries without any link to a valid object and stores result in $this->invalid_childs.

Returns
bool false if analyze mode disabled or nothing found

Definition at line 688 of file class.ilValidator.php.

References ilDBConstants\FETCHMODE_OBJECT, writeScanLogArray(), and writeScanLogLine().

Referenced by purgeObjects(), restoreSubTrees(), and validate().

688  : bool
689  {
690  // check mode: analyze
691  if ($this->mode["scan"] !== true) {
692  return false;
693  }
694 
695  // init
696  $this->invalid_childs = [];
697 
698  $this->writeScanLogLine("\nfindInvalidChilds:");
699 
700  $q = "SELECT tree.*,object_reference.ref_id FROM tree " .
701  "LEFT JOIN object_reference ON tree.child = object_reference.ref_id " .
702  "LEFT JOIN object_data ON object_reference.obj_id = object_data.obj_id " .
703  "WHERE object_reference.ref_id IS NULL or object_data.obj_id IS NULL";
704  $r = $this->db->query($q);
705  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
706  $this->invalid_childs[] = [
707  "child" => $row->child,
708  "ref_id" => $row->ref_id,
709  "msg" => "No object found"
710  ];
711  }
712 
713  if (count($this->invalid_childs) > 0) {
714  $this->writeScanLogLine("child\t\tref_id");
715  $this->writeScanLogArray($this->invalid_childs);
716  return true;
717  }
718 
719  $this->writeScanLogLine("none");
720  return false;
721  }
writeScanLogLine(string $a_msg)
writeScanLogArray(array $a_arr)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findInvalidRBACEntries()

ilValidator::findInvalidRBACEntries ( )

Search database for all role entries that are linked to invalid ref_ids, stores results in $this->invalid_rolefolders.

Returns
bool false if analyze mode disabled or nothing found

Definition at line 551 of file class.ilValidator.php.

References $db, $ilDB, ilDBConstants\FETCHMODE_OBJECT, filterWorkspaceObjects(), RECOVERY_FOLDER_ID, writeScanLogArray(), and writeScanLogLine().

551  : bool
552  {
553  $ilDB = $this->db;
554 
555  // check mode: analyze
556  if ($this->mode["scan"] !== true) {
557  return false;
558  }
559 
560  // init
561  $this->invalid_rbac_entries = [];
562 
563  $this->writeScanLogLine("\nfindInvalidRBACEntries:");
564 
565  $q = "SELECT object_data.*, ref_id FROM object_data " .
566  "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id " .
567  "LEFT JOIN tree ON object_reference.ref_id = tree.child " .
568  "WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) " .
569  "AND object_data.type='rolf'";
570  $r = $this->db->query($q);
571 
572  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
573  $this->invalid_rolefolders[] = [
574  "obj_id" => $row->obj_id,
575  "type" => $row->type,
576  "ref_id" => $row->ref_id,
577  "child" => $row->child,
578  "title" => $row->title,
579  "desc" => $row->description,
580  "owner" => $row->owner,
581  "create_date" => $row->create_date,
582  "last_update" => $row->last_update
583  ];
584  }
585 
586  // find rolfs within RECOVERY FOLDER
587  $q = "SELECT object_data.*, ref_id FROM object_data " .
588  "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id " .
589  "LEFT JOIN tree ON object_reference.ref_id = tree.child " .
590  "WHERE object_reference.ref_id =" . $ilDB->quote(RECOVERY_FOLDER_ID, "integer") . " " .
591  "AND object_data.type='rolf'";
592  $r = $this->db->query($q);
593 
594  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
595  $this->invalid_rolefolders[] = [
596  "obj_id" => $row->obj_id,
597  "type" => $row->type,
598  "ref_id" => $row->ref_id,
599  "child" => $row->child,
600  "title" => $row->title,
601  "desc" => $row->description,
602  "owner" => $row->owner,
603  "create_date" => $row->create_date,
604  "last_update" => $row->last_update
605  ];
606  }
607 
608  $this->filterWorkspaceObjects($this->invalid_rolefolders);
609  if (count($this->invalid_rolefolders) > 0) {
610  $this->writeScanLogLine("obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
611  $this->writeScanLogArray($this->invalid_rolefolders);
612  return true;
613  }
614 
615  $this->writeScanLogLine("none");
616  return false;
617  }
ilDBInterface $db
writeScanLogLine(string $a_msg)
writeScanLogArray(array $a_arr)
filterWorkspaceObjects(array &$a_data, string $a_index="obj_id")
const RECOVERY_FOLDER_ID
Definition: constants.php:37
+ Here is the call graph for this function:

◆ findInvalidReferences()

ilValidator::findInvalidReferences ( )

Search database for all reference entries that are not linked with a valid object id and stores result in $this->invalid_references.

Returns
bool false if analyze mode disabled or nothing found

Definition at line 637 of file class.ilValidator.php.

References $db, $ilDB, ilDBConstants\FETCHMODE_OBJECT, filterWorkspaceObjects(), writeScanLogArray(), and writeScanLogLine().

Referenced by validate().

637  : bool
638  {
639  $ilDB = $this->db;
640 
641  // check mode: analyze
642  if ($this->mode["scan"] !== true) {
643  return false;
644  }
645 
646  // init
647  $this->invalid_references = [];
648 
649  $this->writeScanLogLine("\nfindInvalidReferences:");
650  $q = "SELECT object_reference.* FROM object_reference " .
651  "LEFT JOIN object_data ON object_data.obj_id = object_reference.obj_id " .
652  "WHERE object_data.obj_id IS NULL " .
653  "OR " . $ilDB->in('object_data.type', $this->rbac_object_types, true, 'text');
654  $r = $this->db->query($q);
655 
656  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
657  $this->invalid_references[] = [
658  "ref_id" => $row->ref_id,
659  "obj_id" => $row->obj_id,
660  "msg" => "Object does not exist."
661  ];
662  }
663 
664  $this->filterWorkspaceObjects($this->invalid_references);
665  if (count($this->invalid_references) > 0) {
666  $this->writeScanLogLine("ref_id\t\tobj_id");
667  $this->writeScanLogArray($this->invalid_references);
668  return true;
669  }
670 
671  $this->writeScanLogLine("none");
672  return false;
673  }
ilDBInterface $db
writeScanLogLine(string $a_msg)
writeScanLogArray(array $a_arr)
filterWorkspaceObjects(array &$a_data, string $a_index="obj_id")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findInvalidRolefolders()

ilValidator::findInvalidRolefolders ( )

Search database for all rolefolder object entries with missing reference entry.

Furthermore gets all rolefolders that are placed accidently in RECOVERY_FOLDER from earlier versions of System check. Result is stored in $this->invalid_rolefolders

Returns
bool false if analyze mode disabled or nothing found

Definition at line 477 of file class.ilValidator.php.

References $db, $ilDB, ilDBConstants\FETCHMODE_OBJECT, filterWorkspaceObjects(), RECOVERY_FOLDER_ID, writeScanLogArray(), and writeScanLogLine().

Referenced by validate().

477  : bool
478  {
479  $ilDB = $this->db;
480 
481  // check mode: analyze
482  if ($this->mode["scan"] !== true) {
483  return false;
484  }
485 
486  // init
487  $this->invalid_rolefolders = [];
488 
489  $this->writeScanLogLine("\nfindInvalidRolefolders:");
490 
491  // find rolfs without reference/tree entry
492  $q = "SELECT object_data.*, ref_id FROM object_data " .
493  "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id " .
494  "LEFT JOIN tree ON object_reference.ref_id = tree.child " .
495  "WHERE (object_reference.obj_id IS NULL OR tree.child IS NULL) " .
496  "AND object_data.type='rolf'";
497  $r = $this->db->query($q);
498 
499  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
500  $this->invalid_rolefolders[] = [
501  "obj_id" => $row->obj_id,
502  "type" => $row->type,
503  "ref_id" => $row->ref_id,
504  "child" => $row->child,
505  "title" => $row->title,
506  "desc" => $row->description,
507  "owner" => $row->owner,
508  "create_date" => $row->create_date,
509  "last_update" => $row->last_update
510  ];
511  }
512 
513  // find rolfs within RECOVERY FOLDER
514  $q = "SELECT object_data.*, ref_id FROM object_data " .
515  "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id " .
516  "LEFT JOIN tree ON object_reference.ref_id = tree.child " .
517  "WHERE object_reference.ref_id = " . $ilDB->quote(RECOVERY_FOLDER_ID, 'integer') . " " .
518  "AND object_data.type='rolf'";
519  $r = $this->db->query($q);
520 
521  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
522  $this->invalid_rolefolders[] = [
523  "obj_id" => $row->obj_id,
524  "type" => $row->type,
525  "ref_id" => $row->ref_id,
526  "child" => $row->child,
527  "title" => $row->title,
528  "desc" => $row->description,
529  "owner" => $row->owner,
530  "create_date" => $row->create_date,
531  "last_update" => $row->last_update
532  ];
533  }
534 
535  $this->filterWorkspaceObjects($this->invalid_rolefolders);
536  if (count($this->invalid_rolefolders) > 0) {
537  $this->writeScanLogLine("obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
538  $this->writeScanLogArray($this->invalid_rolefolders);
539  return true;
540  }
541 
542  $this->writeScanLogLine("none");
543  return false;
544  }
ilDBInterface $db
writeScanLogLine(string $a_msg)
writeScanLogArray(array $a_arr)
filterWorkspaceObjects(array &$a_data, string $a_index="obj_id")
const RECOVERY_FOLDER_ID
Definition: constants.php:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findMissingObjects()

ilValidator::findMissingObjects ( )

Search database for all object entries with missing reference and/or tree entry and stores result in $this->missing_objects.

Definition at line 413 of file class.ilValidator.php.

References $db, $ilDB, ilDBConstants\FETCHMODE_OBJECT, filterWorkspaceObjects(), isExcludedFromRecovery(), writeScanLogArray(), and writeScanLogLine().

Referenced by validate().

413  : bool
414  {
415  $ilDB = $this->db;
416 
417  // check mode: analyze
418  if ($this->mode["scan"] !== true) {
419  return false;
420  }
421 
422  // init
423  $this->missing_objects = [];
424 
425  $this->writeScanLogLine("\nfindMissingObjects:");
426 
427  // Repair missing objects.
428  // We only repair file objects which have an entry in table object_reference.
429  // XXX - We should check all references to file objects which don't
430  // have an object_reference. If we can't find any reference to such
431  // a file object, we should repair it too!
432  $q = "SELECT object_data.*, ref_id FROM object_data " .
433  "LEFT JOIN object_reference ON object_data.obj_id = object_reference.obj_id " .
434  "LEFT JOIN tree ON object_reference.ref_id = tree.child " .
435  "WHERE tree.child IS NULL " .
436  "AND (object_reference.obj_id IS NOT NULL " .
437  " OR object_data.type <> 'file' AND " .
438  $ilDB->in('object_data.type', $this->rbac_object_types, false, 'text') .
439  ")";
440  $r = $this->db->query($q);
441 
442  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
443  #if (!in_array($row->type,$this->object_types_exclude))
444  if (!$this->isExcludedFromRecovery($row->type, $row->obj_id)) {
445  $this->missing_objects[] = [
446  "obj_id" => $row->obj_id,
447  "type" => $row->type,
448  "ref_id" => $row->ref_id,
449  "child" => $row->child,
450  "title" => $row->title,
451  "desc" => $row->description,
452  "owner" => $row->owner,
453  "create_date" => $row->create_date,
454  "last_update" => $row->last_update
455  ];
456  }
457  }
458 
459  $this->filterWorkspaceObjects($this->missing_objects);
460  if (count($this->missing_objects) > 0) {
461  $this->writeScanLogLine("obj_id\ttype\tref_id\tchild\ttitle\tdesc\towner\tcreate_date\tlast_update");
462  $this->writeScanLogArray($this->missing_objects);
463  return true;
464  }
465 
466  $this->writeScanLogLine("none");
467  return false;
468  }
ilDBInterface $db
writeScanLogLine(string $a_msg)
isExcludedFromRecovery(string $a_type, int $a_obj_id)
writeScanLogArray(array $a_arr)
filterWorkspaceObjects(array &$a_data, string $a_index="obj_id")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findUnboundObjects()

ilValidator::findUnboundObjects ( )

Search database for all tree entries having no valid parent (=> no valid path to root node) and stores result in $this->unbound_objects Result does not contain childs that are marked as deleted! Deleted childs have a negative number.

Returns
bool false if analyze mode disabled or nothing found

Definition at line 738 of file class.ilValidator.php.

References ilDBConstants\FETCHMODE_OBJECT, writeScanLogArray(), and writeScanLogLine().

Referenced by validate().

738  : bool
739  {
740  // check mode: analyze
741  if ($this->mode["scan"] !== true) {
742  return false;
743  }
744 
745  // init
746  $this->unbound_objects = [];
747 
748  $this->writeScanLogLine("\nfindUnboundObjects:");
749 
750  $q = "SELECT T1.tree,T1.child,T1.parent," .
751  "T2.tree deleted,T2.parent grandparent " .
752  "FROM tree T1 " .
753  "LEFT JOIN tree T2 ON T2.child=T1.parent " .
754  "WHERE (T2.tree!=1 OR T2.tree IS NULL) AND T1.parent!=0";
755  $r = $this->db->query($q);
756 
757  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
758  // exclude deleted nodes
759  if ($row->deleted === null) {
760  $this->unbound_objects[] = [
761  "child" => $row->child,
762  "parent" => $row->parent,
763  "tree" => $row->tree,
764  "msg" => "No valid parent node found"
765  ];
766  }
767  }
768 
769  if (count($this->unbound_objects) > 0) {
770  $this->writeScanLogLine("child\t\tparent\ttree");
771  $this->writeScanLogArray($this->unbound_objects);
772  return true;
773  }
774 
775  $this->writeScanLogLine("none");
776  return false;
777  }
writeScanLogLine(string $a_msg)
writeScanLogArray(array $a_arr)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_last_scan()

ilValidator::get_last_scan ( array  $a_scan_log)

Definition at line 1746 of file class.ilValidator.php.

Referenced by readScanLog().

1746  : ?array
1747  {
1748  $logs = array_keys($a_scan_log, $this->scan_log_separator . "\n");
1749 
1750  if (count($logs) > 0) {
1751  return array_slice($a_scan_log, array_pop($logs) + 2);
1752  }
1753 
1754  return null;
1755  }
+ Here is the caller graph for this function:

◆ getDeletedObjects()

ilValidator::getDeletedObjects ( )

Gets all object in trash.

Definition at line 851 of file class.ilValidator.php.

References $deleted_objects.

Referenced by validate().

851  : array
852  {
853  return $this->deleted_objects;
854  }
+ Here is the caller graph for this function:

◆ getInvalidChilds()

ilValidator::getInvalidChilds ( )

Gets all tree entries without any link to a valid object.

Definition at line 726 of file class.ilValidator.php.

References $invalid_childs.

Referenced by validate().

726  : array
727  {
728  return $this->invalid_childs;
729  }
+ Here is the caller graph for this function:

◆ getInvalidReferences()

ilValidator::getInvalidReferences ( )

Gets all reference entries that are not linked with a valid object id.

Definition at line 678 of file class.ilValidator.php.

References $invalid_references.

Referenced by validate().

678  : array
679  {
681  }
array $invalid_references
+ Here is the caller graph for this function:

◆ getInvalidRolefolders()

ilValidator::getInvalidRolefolders ( )

Gets invalid rolefolders (same as missing objects)

Definition at line 859 of file class.ilValidator.php.

References $invalid_rolefolders.

Referenced by validate().

859  : array
860  {
862  }
array $invalid_rolefolders
contains missing objects that are rolefolders.
+ Here is the caller graph for this function:

◆ getMissingObjects()

ilValidator::getMissingObjects ( )

Gets all object entries with missing reference and/or tree entry.

Returns array with obj_id => actual object entry with missing reference or tree type => symbolic name of object type ref_id => reference entry of object (or NULL if missing) child => always NULL (only for debugging and verification)

Definition at line 627 of file class.ilValidator.php.

References $missing_objects.

Referenced by validate().

627  : array
628  {
629  return $this->missing_objects;
630  }
+ Here is the caller graph for this function:

◆ getPossibleModes()

ilValidator::getPossibleModes ( )

get possible ilValidator modes

Definition at line 125 of file class.ilValidator.php.

125  : array
126  {
127  return array_keys($this->mode);
128  }

◆ getUnboundObjects()

ilValidator::getUnboundObjects ( )

Gets all tree entries having no valid parent (=> no valid path to root node) Returns an array with child => actual entry with broken uplink to its parent parent => parent of child that does not exist grandparent => grandparent of child (where path to root node continues) deleted => containing a negative number (= parent in trash) or NULL (parent does not exist at all)

Definition at line 843 of file class.ilValidator.php.

References $unbound_objects.

Referenced by validate().

843  : array
844  {
845  return $this->unbound_objects;
846  }
+ Here is the caller graph for this function:

◆ handleErr()

ilValidator::handleErr ( object  $error)

Callback function handles PEAR_error and outputs detailed infos about error TODO: implement that in global errorhandler of ILIAS (via templates)

Parameters
object$error

Definition at line 1630 of file class.ilValidator.php.

References $type, and exit.

1632  : void {
1633  $call_loc = $error->backtrace[count($error->backtrace) - 1];
1634  $num_args = count($call_loc["args"]);
1635  $arg_list = [];
1636  $arg_str = "";
1637  if ($num_args > 0) {
1638  foreach ($call_loc["args"] as $arg) {
1639  $type = gettype($arg);
1640 
1641  switch ($type) {
1642  case "string":
1643  $value = strlen($arg);
1644  break;
1645 
1646  case "array":
1647  $value = count($arg);
1648  break;
1649 
1650  case "object":
1651  $value = get_class($arg);
1652  break;
1653 
1654  case "boolean":
1655  $value = ($arg) ? "true" : "false";
1656  break;
1657 
1658  default:
1659  $value = $arg;
1660  break;
1661  }
1662 
1663  $arg_list[] = [
1664  "type" => $type,
1665  "value" => "(" . $value . ")"
1666  ];
1667  }
1668 
1669  foreach ($arg_list as $arg) {
1670  $arg_str .= implode("", $arg) . " ";
1671  }
1672  }
1673 
1674  $err_msg = "<br/><b>" . $error->getCode() . ":</b> " . $error->getMessage() . " in " . $call_loc["class"] . $call_loc["type"] . $call_loc["function"] . "()" .
1675  "<br/>Called from: " . basename($call_loc["file"]) . " , line " . $call_loc["line"] .
1676  "<br/>Passed parameters: [" . $num_args . "] " . $arg_str . "<br/>";
1677  printf($err_msg);
1678 
1679  /*
1680  if ($error->getUserInfo()) {
1681  printf("<br/>Parameter details:");
1682  echo "<pre>";
1683  var_dump($call_loc["args"]);// TODO PHP8-REVIEW This should be removed and the ilLogger should be used instead
1684  echo "</pre>";
1685  }*/
1686 
1687  if ($error->getCode() == FATAL) {
1688  exit();
1689  }
1690  }
exit
Definition: login.php:28
$type

◆ hasScanLog()

ilValidator::hasScanLog ( )

Quickly determine if there is a scan log.

Definition at line 1715 of file class.ilValidator.php.

References CLIENT_DATA_DIR.

Referenced by readScanLog().

1715  : bool
1716  {
1717  // file check
1718  return is_file(CLIENT_DATA_DIR . "/" . $this->scan_log_file);
1719  }
const CLIENT_DATA_DIR
Definition: constants.php:46
+ Here is the caller graph for this function:

◆ initGapsInTree()

ilValidator::initGapsInTree ( )

Initializes gaps in lft/rgt values of a tree.

Depending on the value of the gap property of the tree, this function either closes all gaps in the tree, or equally distributes gaps all over the tree.

Wrapper for ilTree::renumber()

Returns
bool false if clean mode disabled

Definition at line 1600 of file class.ilValidator.php.

References $log, $message, $tree, ilTree\renumber(), ROOT_FOLDER_ID, and writeScanLogLine().

Referenced by validate().

1600  : bool
1601  {
1602  $tree = $this->tree;
1603  $ilLog = $this->log;
1604 
1605  $message = sprintf(
1606  '%s::initGapsInTree(): Started...',
1607  get_class($this)
1608  );
1609  $ilLog->write($message, $ilLog->WARNING);
1610 
1611  // check mode: clean
1612  if ($this->mode["clean"] !== true) {
1613  return false;
1614  }
1615  $this->writeScanLogLine("\nrenumberTree:");
1616 
1618 
1619  $this->writeScanLogLine("done");
1620 
1621  return true;
1622  }
const ROOT_FOLDER_ID
Definition: constants.php:32
writeScanLogLine(string $a_msg)
renumber(int $node_id=1, int $i=1)
Wrapper for renumber.
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initWorkspaceObjects()

ilValidator::initWorkspaceObjects ( )
protected

Definition at line 2188 of file class.ilValidator.php.

References $db, and $ilDB.

Referenced by dumpTree(), and filterWorkspaceObjects().

2188  : void
2189  {
2190  $ilDB = $this->db;
2191 
2192  if ($this->workspace_object_ids === null) {
2193  $this->workspace_object_ids = [];
2194 
2195  // workspace objects
2196  $set = $ilDB->query("SELECT DISTINCT(obj_id) FROM object_reference_ws");
2197  while ($row = $ilDB->fetchAssoc($set)) {
2198  $this->workspace_object_ids[] = $row["obj_id"];
2199  }
2200 
2201  // portfolios
2202  $set = $ilDB->query("SELECT id FROM usr_portfolio");
2203  while ($row = $ilDB->fetchAssoc($set)) {
2204  $this->workspace_object_ids[] = $row["id"];
2205  }
2206  }
2207  }
ilDBInterface $db
+ Here is the caller graph for this function:

◆ isExcludedFromRecovery()

ilValidator::isExcludedFromRecovery ( string  $a_type,
int  $a_obj_id 
)
protected

Definition at line 2175 of file class.ilValidator.php.

References isMediaFolder().

Referenced by findMissingObjects(), and restoreMissingObjects().

2178  : bool {
2179  switch ($a_type) {
2180  case 'fold':
2181  if (!$this->isMediaFolder($a_obj_id)) {
2182  return false;
2183  }
2184  }
2185  return in_array($a_type, $this->object_types_exclude);
2186  }
isMediaFolder(int $a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLogEnabled()

ilValidator::isLogEnabled ( )

Definition at line 171 of file class.ilValidator.php.

References $logging.

Referenced by writeScanLogArray(), and writeScanLogLine().

171  : bool
172  {
173  return $this->logging;
174  }
+ Here is the caller graph for this function:

◆ isMediaFolder()

ilValidator::isMediaFolder ( int  $a_obj_id)
protected

Definition at line 2158 of file class.ilValidator.php.

References $db, $ilDB, $query, and $res.

Referenced by isExcludedFromRecovery().

2158  : bool
2159  {
2160  $ilDB = $this->db;
2161 
2162  if (!is_array($this->media_pool_ids)) {
2163  $this->media_pool_ids = [];
2164  $query = "SELECT child FROM mep_tree ";
2165  $res = $ilDB->query($query);
2166  while ($row = $ilDB->fetchObject($res)) {
2167  $this->media_pool_ids[] = $row->child;
2168  }
2169  }
2170 
2171  return in_array($a_obj_id, $this->media_pool_ids);
2172  }
$res
Definition: ltiservices.php:69
ilDBInterface $db
$query
+ Here is the caller graph for this function:

◆ isModeEnabled()

ilValidator::isModeEnabled ( string  $a_mode)

Definition at line 160 of file class.ilValidator.php.

Referenced by validate().

162  : bool {
163  if (!array_key_exists($a_mode, $this->mode)) {
164  $this->throwError(VALIDATER_UNKNOWN_MODE, WARNING, DEBUG);
165  return false;
166  }
167 
168  return $this->mode[$a_mode];
169  }
+ Here is the caller graph for this function:

◆ purgeMissingObjects()

ilValidator::purgeMissingObjects ( array  $a_nodes = null)

Removes all missing objects from system.

Parameters
?array$a_nodes list of nodes to delete
Returns
bool true on success

Definition at line 1475 of file class.ilValidator.php.

References $log, $message, $missing_objects, purgeObjects(), and writeScanLogLine().

Referenced by validate().

1477  : bool {
1478  $ilLog = $this->log;
1479 
1480  // check mode: purge
1481  if ($this->mode["purge"] !== true) {
1482  return false;
1483  }
1484 
1485  $this->writeScanLogLine("\npurgeMissingObjects:");
1486 
1487  if ($a_nodes === null && isset($this->missing_objects)) {
1488  $a_nodes = $this->missing_objects;
1489  }
1490 
1491  $message = sprintf(
1492  '%s::purgeMissingObjects(): Started...',
1493  get_class($this)
1494  );
1495  $ilLog->write($message, $ilLog->WARNING);
1496 
1497  // start purge process
1498  return $this->purgeObjects($a_nodes);
1499  }
writeScanLogLine(string $a_msg)
purgeObjects(array $a_nodes)
removes objects from system
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ purgeObjects()

ilValidator::purgeObjects ( array  $a_nodes)

removes objects from system

Parameters
array$a_nodeslist of objects
Returns
bool

Definition at line 1506 of file class.ilValidator.php.

References $ilUser, $log, $message, $ref_id, $user, ilTree\_removeEntry(), findInvalidChilds(), ilObjectFactory\getInstanceByRefId(), removeInvalidChilds(), and writeScanLogLine().

Referenced by purgeMissingObjects(), purgeTrash(), and purgeUnboundObjects().

1508  : bool {
1509  $ilLog = $this->log;
1510  $ilUser = $this->user;
1511 
1512  // Get purge limits
1513  $count_limit = $ilUser->getPref("systemcheck_count_limit");
1514  if (!is_numeric($count_limit) || $count_limit < 0) {
1515  $count_limit = count($a_nodes);
1516  }
1517  $timestamp_limit = time();
1518  $age_limit = $ilUser->getPref("systemcheck_age_limit");
1519  if (is_numeric($age_limit) && $age_limit > 0) {
1520  $timestamp_limit -= $age_limit * 60 * 60 * 24;
1521  }
1522  $type_limit = $ilUser->getPref("systemcheck_type_limit");
1523  if ($type_limit) {
1524  $type_limit = trim($type_limit);
1525  if ($type_limit === '') {
1526  $type_limit = null;
1527  }
1528  }
1529 
1530  // handle wrong input
1531  if (!is_array($a_nodes)) {
1532  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1533  return false;
1534  }
1535 
1536  // start delete process
1537  $this->writeScanLogLine("action\tref_id\tobj_id\ttype\telapsed\ttitle");
1538  $count = 0;
1539  foreach ($a_nodes as $node) {
1540  if ($type_limit && $node['type'] != $type_limit) {
1541  $this->writeScanLogLine(
1542  "skip\t" .
1543  $node['child'] . "\t\t" . $node['type'] . "\t\t" . $node['title']
1544  );
1545  continue;
1546  }
1547 
1548 
1549  $count++;
1550  if ($count > $count_limit) {
1551  $this->writeScanLogLine("Stopped purging after " . ($count - 1) . " objects, because count limit was reached: " . $count_limit);
1552  break;
1553  }
1554  if ($node["deleted_timestamp"] > $timestamp_limit) {
1555  $this->writeScanLogLine("Stopped purging after " . ($count - 1) . " objects, because timestamp limit was reached: " . date("c", $timestamp_limit));
1556  continue;
1557  }
1558 
1559  $ref_id = ($node["child"]) ?: $node["ref_id"];
1560  $node_obj = ilObjectFactory::getInstanceByRefId($ref_id, false);
1561 
1562  if ($node_obj === false) {
1563  $this->invalid_objects[] = $node;
1564  continue;
1565  }
1566 
1567  $message = sprintf(
1568  '%s::purgeObjects(): Removing object (id:%s ref:%s)',
1569  get_class($this),
1570  $ref_id,
1571  $node_obj->getId()
1572  );
1573  $ilLog->write($message, $ilLog->WARNING);
1574 
1575  $startTime = microtime(true);
1576  $node_obj->delete();
1577  ilTree::_removeEntry($node["tree"], $ref_id);
1578  $endTime = microtime(true);
1579 
1580  $this->writeScanLogLine("purged\t" . $ref_id . "\t" . $node_obj->getId() .
1581  "\t" . $node['type'] . "\t" . round($endTime - $startTime, 1) . "\t" . $node['title']);
1582  }
1583 
1584  $this->findInvalidChilds();
1585  $this->removeInvalidChilds();
1586 
1587  return true;
1588  }
removeInvalidChilds(array $a_invalid_childs=null)
Removes all tree entries without any link to a valid object.
writeScanLogLine(string $a_msg)
findInvalidChilds()
Search database for all tree entries without any link to a valid object and stores result in $this->i...
$ref_id
Definition: ltiauth.php:67
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
$ilUser
Definition: imgupload.php:34
$message
Definition: xapiexit.php:32
static _removeEntry(int $a_tree, int $a_child, string $a_db_table="tree")
STATIC METHOD Removes a single entry from a tree.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ purgeTrash()

ilValidator::purgeTrash ( array  $a_nodes = null)

Removes all objects in trash from system.

Parameters
array$a_nodeslist of nodes to delete
Returns
bool true on success

Definition at line 1414 of file class.ilValidator.php.

References $deleted_objects, $log, $message, purgeObjects(), and writeScanLogLine().

Referenced by validate().

1416  : bool {
1417  $ilLog = $this->log;
1418 
1419  // check mode: purge_trash
1420  if ($this->mode["purge_trash"] !== true) {
1421  return false;
1422  }
1423 
1424  $this->writeScanLogLine("\npurgeTrash:");
1425 
1426  if ($a_nodes === null && isset($this->deleted_objects)) {
1427  $a_nodes = $this->deleted_objects;
1428  }
1429  $message = sprintf(
1430  '%s::purgeTrash(): Started...',
1431  get_class($this)
1432  );
1433  $ilLog->write($message, $ilLog->WARNING);
1434 
1435  // start purge process
1436  return $this->purgeObjects($a_nodes);
1437  }
writeScanLogLine(string $a_msg)
purgeObjects(array $a_nodes)
removes objects from system
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ purgeUnboundObjects()

ilValidator::purgeUnboundObjects ( array  $a_nodes = null)

Removes all invalid objects from system.

Parameters
array$a_nodeslist of nodes to delete
Returns
bool true on success

Definition at line 1444 of file class.ilValidator.php.

References $log, $message, $unbound_objects, purgeObjects(), and writeScanLogLine().

Referenced by validate().

1446  : bool {
1447  $ilLog = $this->log;
1448 
1449  // check mode: purge
1450  if ($this->mode["purge"] !== true) {
1451  return false;
1452  }
1453 
1454  $this->writeScanLogLine("\npurgeUnboundObjects:");
1455 
1456  if ($a_nodes === null && isset($this->unbound_objects)) {
1457  $a_nodes = $this->unbound_objects;
1458  }
1459 
1460  $message = sprintf(
1461  '%s::purgeUnboundObjects(): Started...',
1462  get_class($this)
1463  );
1464  $ilLog->write($message, $ilLog->WARNING);
1465 
1466  // start purge process
1467  return $this->purgeObjects($a_nodes);
1468  }
writeScanLogLine(string $a_msg)
purgeObjects(array $a_nodes)
removes objects from system
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readScanLog()

ilValidator::readScanLog ( )

Definition at line 1729 of file class.ilValidator.php.

References $scan_log, CLIENT_DATA_DIR, get_last_scan(), and hasScanLog().

1729  : ?array
1730  {
1731  // file check
1732  if (!$this->hasScanLog()) {
1733  return null;
1734  }
1735 
1736  $scanfile = file(CLIENT_DATA_DIR . "/" . $this->scan_log_file);
1737  if (!$scan_log = $this->get_last_scan($scanfile)) {
1738  return null;
1739  }
1740  // Ensure that memory is freed
1741  unset($scanfile);
1742 
1743  return $scan_log;
1744  }
hasScanLog()
Quickly determine if there is a scan log.
const CLIENT_DATA_DIR
Definition: constants.php:46
get_last_scan(array $a_scan_log)
+ Here is the call graph for this function:

◆ removeInvalidChilds()

ilValidator::removeInvalidChilds ( array  $a_invalid_childs = null)

Removes all tree entries without any link to a valid object.

Parameters
arrayinvalid IDs in tree (optional)
Returns
bool true if any ID were removed / false on error or clean mode disabled

Definition at line 933 of file class.ilValidator.php.

References $invalid_childs, $log, $message, and writeScanLogLine().

Referenced by purgeObjects(), restoreSubTrees(), and validate().

935  : bool {
936  $ilLog = $this->log;
937 
938  // check mode: clean
939  if ($this->mode["clean"] !== true) {
940  return false;
941  }
942 
943  $this->writeScanLogLine("\nremoveInvalidChilds:");
944 
945  if ($a_invalid_childs === null && isset($this->invalid_childs)) {
946  $a_invalid_childs = &$this->invalid_childs;
947  }
948 
949  // handle wrong input
950  if (!is_array($a_invalid_childs)) {
951  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
952  return false;
953  }
954 
955  // no unbound childs found. do nothing
956  if (count($a_invalid_childs) === 0) {
957  $this->writeScanLogLine("none");
958  return false;
959  }
960 
961  /*******************
962  removal starts here
963  ********************/
964 
965  $message = sprintf(
966  '%s::removeInvalidChilds(): Started...',
967  get_class($this)
968  );
969  $ilLog->write($message, $ilLog->WARNING);
970 
971  foreach ($a_invalid_childs as $entry) {
972  $q = "DELETE FROM tree WHERE child='" . $entry["child"] . "'";
973  $this->db->query($q);
974 
975  $message = sprintf(
976  '%s::removeInvalidChilds(): Entry child=%s removed',
977  get_class($this),
978  $entry["child"]
979  );
980  $ilLog->write($message, $ilLog->WARNING);
981 
982  $this->writeScanLogLine("Entry " . $entry["child"] . " removed");
983  }
984 
985  return true;
986  }
writeScanLogLine(string $a_msg)
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeInvalidReferences()

ilValidator::removeInvalidReferences ( array  $a_invalid_refs = null)

Removes all reference entries that are linked with invalid object IDs.

Parameters
arrayinvalid IDs in object_reference (optional)
Returns
bool true if any ID were removed / false on error or clean mode disabled

Definition at line 869 of file class.ilValidator.php.

References $db, $ilDB, $invalid_references, $log, $message, $query, $res, filterWorkspaceObjects(), and writeScanLogLine().

Referenced by validate().

871  : bool {
872  $ilLog = $this->log;
873  $ilDB = $this->db;
874 
875  // check mode: clean
876  if ($this->mode["clean"] !== true) {
877  return false;
878  }
879 
880  $this->writeScanLogLine("\nremoveInvalidReferences:");
881 
882  if ($a_invalid_refs === null && isset($this->invalid_references)) {
883  $a_invalid_refs = &$this->invalid_references;
884  }
885 
886  // handle wrong input
887  if (!is_array($a_invalid_refs)) {
888  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
889  return false;
890  }
891  // no unbound references found. do nothing
892  if (count($a_invalid_refs) === 0) {
893  $this->writeScanLogLine("none");
894  return false;
895  }
896 
897  /*******************
898  removal starts here
899  ********************/
900 
901  $message = sprintf(
902  '%s::removeInvalidReferences(): Started...',
903  get_class($this)
904  );
905  $ilLog->write($message, $ilLog->WARNING);
906 
907  // to make sure
908  $this->filterWorkspaceObjects($a_invalid_refs);
909 
910  foreach ($a_invalid_refs as $entry) {
911  $query = "DELETE FROM object_reference WHERE ref_id= " . $this->db->quote($entry["ref_id"], 'integer') .
912  " AND obj_id = " . $this->db->quote($entry["obj_id"], 'integer') . " ";
913  $res = $ilDB->manipulate($query);
914 
915  $message = sprintf(
916  '%s::removeInvalidReferences(): Reference %s removed',
917  get_class($this),
918  $entry["ref_id"]
919  );
920  $ilLog->write($message, $ilLog->WARNING);
921 
922  $this->writeScanLogLine("Entry " . $entry["ref_id"] . " removed");
923  }
924 
925  return true;
926  }
$res
Definition: ltiservices.php:69
ilDBInterface $db
writeScanLogLine(string $a_msg)
$query
filterWorkspaceObjects(array &$a_data, string $a_index="obj_id")
array $invalid_references
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeInvalidRolefolders()

ilValidator::removeInvalidRolefolders ( array  $a_invalid_rolefolders = null)

Removes invalid rolefolders.

Parameters
arrayobj_ids of rolefolder objects (optional)
Returns
bool true if any object were removed / false on error or remove mode disabled

Definition at line 994 of file class.ilValidator.php.

References $invalid_rolefolders, $log, $message, filterWorkspaceObjects(), ilObjectFactory\getInstanceByRefId(), restoreReference(), and writeScanLogLine().

Referenced by validate().

996  : bool {
997  $ilLog = $this->log;
998 
999  // check mode: clean
1000  if ($this->mode["clean"] !== true) {
1001  return false;
1002  }
1003 
1004  $this->writeScanLogLine("\nremoveInvalidRolefolders:");
1005 
1006  if ($a_invalid_rolefolders === null && isset($this->invalid_rolefolders)) {
1007  $a_invalid_rolefolders = $this->invalid_rolefolders;
1008  }
1009 
1010  // handle wrong input
1011  if (!is_array($a_invalid_rolefolders)) {
1012  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1013  return false;
1014  }
1015 
1016  // no invalid rolefolders found. do nothing
1017  if (count($a_invalid_rolefolders) === 0) {
1018  $this->writeScanLogLine("none");
1019  return false;
1020  }
1021 
1022  /*******************
1023  removal starts here
1024  ********************/
1025 
1026  $removed = false;
1027 
1028  $message = sprintf(
1029  '%s::removeInvalidRolefolders(): Started...',
1030  get_class($this)
1031  );
1032  $ilLog->write($message, $ilLog->WARNING);
1033 
1034  // to make sure
1035  $this->filterWorkspaceObjects($a_invalid_rolefolders);
1036 
1037  foreach ($a_invalid_rolefolders as $rolf) {
1038  // restore ref_id in case of missing
1039  if ($rolf["ref_id"] === null) {
1040  $rolf["ref_id"] = $this->restoreReference($rolf["obj_id"]);
1041 
1042  $this->writeScanLogLine("Created missing reference '" . $rolf["ref_id"] . "' for rolefolder object '" . $rolf["obj_id"] . "'");
1043  }
1044 
1045  // now delete rolefolder
1046  $obj_data = ilObjectFactory::getInstanceByRefId($rolf["ref_id"]);
1047  $obj_data->delete();
1048  unset($obj_data);
1049  $removed = true;
1050  $this->writeScanLogLine("Removed invalid rolefolder '" . $rolf["title"] . "' (id=" . $rolf["obj_id"] . ",ref=" . $rolf["ref_id"] . ") from system");
1051  }
1052 
1053  return $removed;
1054  }
writeScanLogLine(string $a_msg)
restoreReference(int $a_obj_id)
restore a reference for an object Creates a new reference entry in DB table object_reference for $a_o...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
array $invalid_rolefolders
contains missing objects that are rolefolders.
filterWorkspaceObjects(array &$a_data, string $a_index="obj_id")
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restoreDeletedObjects()

ilValidator::restoreDeletedObjects ( array  $a_nodes)

Restore deleted objects (and their subobjects) to RecoveryFolder.

Parameters
array$a_nodeslist of nodes
Returns
bool false on error or restore mode disabled
Exceptions
ilDatabaseException
ilInvalidTreeStructureException
ilObjectNotFoundException

Definition at line 1264 of file class.ilValidator.php.

References ILIAS\LTI\ToolProvider\$key, $log, $message, $rbacadmin, $tree, ilTree\deleteTree(), ilObjectFactory\getInstanceByRefId(), RECOVERY_FOLDER_ID, ilRbacAdmin\revokePermission(), and writeScanLogLine().

Referenced by restoreTrash().

1266  : bool {
1267  $tree = $this->tree;
1269  $ilLog = $this->log;
1270  // handle wrong input
1271  if (!is_array($a_nodes)) {
1272  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1273  return false;
1274  }
1275 
1276  // no invalid parents found. do nothing
1277  if (count($a_nodes) === 0) {
1278  $this->writeScanLogLine("none");
1279  return false;
1280  }
1281 
1282  $message = sprintf(
1283  '%s::restoreDeletedObjects()): Started...',
1284  get_class($this)
1285  );
1286  $ilLog->write($message, $ilLog->WARNING);
1287 
1288  // first delete all rolefolders
1289  // don't save rolefolders, remove them
1290  // TODO process ROLE_FOLDER_ID
1291  foreach ($a_nodes as $key => $node) {
1292  if ($node["type"] === "rolf") {
1293  // delete old tree entries
1294  $tree->deleteTree($node);
1295 
1296  $obj_data = ilObjectFactory::getInstanceByRefId($node["child"]);
1297  $obj_data->delete();
1298  unset($a_nodes[$key]);
1299  }
1300  }
1301 
1302  // process move
1303  foreach ($a_nodes as $node) {
1304  // delete old tree entries
1305  $tree->deleteTree($node);
1306 
1307  $rbacadmin->revokePermission((int) $node["child"]);
1308  $obj_data = ilObjectFactory::getInstanceByRefId($node["child"]);
1309  $obj_data->putInTree(RECOVERY_FOLDER_ID);
1310  $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1311  }
1312 
1313  return true;
1314  }
writeScanLogLine(string $a_msg)
deleteTree(array $a_node)
delete node and the whole subtree under this node
revokePermission(int $a_ref_id, int $a_rol_id=0, bool $a_keep_protected=true)
Revokes permissions of an object of one role.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
string $key
Consumer key/client ID value.
Definition: System.php:193
const RECOVERY_FOLDER_ID
Definition: constants.php:37
ilRbacAdmin $rbacadmin
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restoreMissingObjects()

ilValidator::restoreMissingObjects ( array  $a_missing_objects = null)

Restores missing reference and/or tree entry for all objects found by this::getMissingObjects() Restored object are placed in RecoveryFolder.

Parameters
arrayobj_ids of missing objects (optional)
Returns
bool true if any object were restored / false on error or restore mode disabled
Exceptions
ilDatabaseException
ilObjectNotFoundException

Definition at line 1064 of file class.ilValidator.php.

References $log, $message, $missing_objects, $rbacadmin, filterWorkspaceObjects(), ilObjectFactory\getInstanceByRefId(), isExcludedFromRecovery(), RECOVERY_FOLDER_ID, restoreReference(), ilRbacAdmin\revokePermission(), and writeScanLogLine().

Referenced by validate().

1066  : bool {
1068  $ilLog = $this->log;
1069 
1070  // check mode: restore
1071  if ($this->mode["restore"] !== true) {
1072  return false;
1073  }
1074 
1075  $this->writeScanLogLine("\nrestoreMissingObjects:");
1076 
1077  if ($a_missing_objects === null && isset($this->missing_objects)) {
1078  $a_missing_objects = $this->missing_objects;
1079  }
1080 
1081  // handle wrong input
1082  if (!is_array($a_missing_objects)) {
1083  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1084  return false;
1085  }
1086 
1087  // no missing objects found. do nothing
1088  if (count($a_missing_objects) === 0) {
1089  $this->writeScanLogLine("none");
1090  return false;
1091  }
1092 
1093  /*******************
1094  restore starts here
1095  ********************/
1096 
1097  $restored = false;
1098 
1099  $message = sprintf(
1100  '%s::restoreMissingObjects(): Started...',
1101  get_class($this)
1102  );
1103  $ilLog->write($message, $ilLog->WARNING);
1104 
1105  // to make sure
1106  $this->filterWorkspaceObjects($a_missing_objects);
1107 
1108  foreach ($a_missing_objects as $missing_obj) {
1109  // restore ref_id in case of missing
1110  if ($missing_obj["ref_id"] === null) {
1111  $missing_obj["ref_id"] = $this->restoreReference($missing_obj["obj_id"]);
1112 
1113  $this->writeScanLogLine("Created missing reference '" . $missing_obj["ref_id"] . "' for object '" . $missing_obj["obj_id"] . "'");
1114  }
1115 
1116  // put in tree under RecoveryFolder if not on exclude list
1117  #if (!in_array($missing_obj["type"],$this->object_types_exclude))
1118  if (!$this->isExcludedFromRecovery($missing_obj['type'], $missing_obj['obj_id'])) {
1119  $rbacadmin->revokePermission((int) $missing_obj["ref_id"]);
1120  $obj_data = ilObjectFactory::getInstanceByRefId($missing_obj["ref_id"]);
1121  $obj_data->putInTree(RECOVERY_FOLDER_ID);
1122  $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1123  unset($obj_data);
1124  //$tree->insertNode($missing_obj["ref_id"],RECOVERY_FOLDER_ID);
1125  $restored = true;
1126  $this->writeScanLogLine("Restored object '" . $missing_obj["title"] . "' (id=" . $missing_obj["obj_id"] . ",ref=" . $missing_obj["ref_id"] . ") in 'Restored objects folder'");
1127  }
1128 
1129  // TODO: process rolefolders
1130  }
1131 
1132  return $restored;
1133  }
writeScanLogLine(string $a_msg)
revokePermission(int $a_ref_id, int $a_rol_id=0, bool $a_keep_protected=true)
Revokes permissions of an object of one role.
isExcludedFromRecovery(string $a_type, int $a_obj_id)
restoreReference(int $a_obj_id)
restore a reference for an object Creates a new reference entry in DB table object_reference for $a_o...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
filterWorkspaceObjects(array &$a_data, string $a_index="obj_id")
const RECOVERY_FOLDER_ID
Definition: constants.php:37
ilRbacAdmin $rbacadmin
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restoreReference()

ilValidator::restoreReference ( int  $a_obj_id)

restore a reference for an object Creates a new reference entry in DB table object_reference for $a_obj_id

Returns
int|bool generated ref_id or false on error

Definition at line 1140 of file class.ilValidator.php.

References $db, $ilDB, $log, $message, $query, and $res.

Referenced by removeInvalidRolefolders(), and restoreMissingObjects().

1141  {
1142  $ilLog = $this->log;
1143  $ilDB = $this->db;
1144 
1145  if (empty($a_obj_id)) {
1146  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1147  return false;
1148  }
1149 
1150  $next_id = $ilDB->nextId('object_reference');
1151  $query = "INSERT INTO object_reference (ref_id, obj_id) " .
1152  "VALUES (" . $this->db->quote($next_id, 'integer') . ", " . $this->db->quote($a_obj_id, 'integer') . ")";
1153  $res = $ilDB->manipulate($query);
1154 
1155  $message = sprintf(
1156  '%s::restoreReference(): new reference %s for obj_id %s created',
1157  get_class($this),
1158  $next_id,
1159  $a_obj_id
1160  );
1161  $ilLog->write($message, $ilLog->WARNING);
1162 
1163  return $next_id;
1164  }
$res
Definition: ltiservices.php:69
ilDBInterface $db
$query
$message
Definition: xapiexit.php:32
+ Here is the caller graph for this function:

◆ restoreSubTrees()

ilValidator::restoreSubTrees ( array  $a_nodes)

Restore objects (and their subobjects) to RecoveryFolder.

Parameters
array$a_nodeslist of nodes
Returns
bool false on error or restore mode disabled

Definition at line 1321 of file class.ilValidator.php.

References ILIAS\LTI\ToolProvider\$key, $log, $message, $rbacadmin, $tree, ilTree\deleteTree(), findInvalidChilds(), ilObjectFactory\getInstanceByRefId(), ilTree\getNodeData(), ilTree\getSubTree(), RECOVERY_FOLDER_ID, removeInvalidChilds(), ilRbacAdmin\revokePermission(), and writeScanLogLine().

Referenced by restoreUnboundObjects().

1323  : bool {
1324  $tree = $this->tree;
1326  $ilLog = $this->log;
1327 
1328  // handle wrong input
1329  if (!is_array($a_nodes)) {
1330  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1331  return false;
1332  }
1333 
1334  // no invalid parents found. do nothing
1335  if (count($a_nodes) === 0) {
1336  $this->writeScanLogLine("none");
1337  return false;
1338  }
1339 
1340  /*******************
1341  restore starts here
1342  ********************/
1343 
1344  $subnodes = [];
1345  $topnode = [];
1346 
1347  $message = sprintf(
1348  '%s::restoreSubTrees(): Started...',
1349  get_class($this)
1350  );
1351  $ilLog->write($message, $ilLog->WARNING);
1352 
1353  // process move subtree
1354  foreach ($a_nodes as $node) {
1355  // get node data
1356  $topnode = $tree->getNodeData($node["child"], $node['tree']);
1357 
1358  // don't save rolefolders, remove them
1359  // TODO process ROLE_FOLDER_ID
1360  if ($topnode["type"] === "rolf") {
1361  $rolfObj = ilObjectFactory::getInstanceByRefId($topnode["child"]);
1362  $rolfObj->delete();
1363  unset($top_node, $rolfObj);
1364  continue;
1365  }
1366 
1367  // get subnodes of top nodes
1368  $subnodes[$node["child"]] = $tree->getSubTree($topnode);
1369 
1370  // delete old tree entries
1371  $tree->deleteTree($topnode);
1372  }
1373 
1374  // now move all subtrees to new location
1375  // TODO: this whole put in place again stuff needs revision. Permission settings get lost.
1376  foreach ($subnodes as $key => $subnode) {
1377 
1378  // first paste top_node ...
1380  $obj_data = ilObjectFactory::getInstanceByRefId($key);
1381  $obj_data->putInTree(RECOVERY_FOLDER_ID);
1382  $obj_data->setPermissions(RECOVERY_FOLDER_ID);
1383 
1384  $this->writeScanLogLine("Object '" . $obj_data->getId() . "' restored.");
1385 
1386  // ... remove top_node from list ...
1387  array_shift($subnode);
1388 
1389  // ... insert subtree of top_node if any subnodes exist
1390  if (count($subnode) > 0) {
1391  foreach ($subnode as $node) {
1392  $rbacadmin->revokePermission((int) $node["child"]);
1393  $obj_data = ilObjectFactory::getInstanceByRefId($node["child"]);
1394  $obj_data->putInTree($node["parent"]);
1395  $obj_data->setPermissions($node["parent"]);
1396 
1397  $this->writeScanLogLine("Object '" . $obj_data->getId() . "' restored.");
1398  }
1399  }
1400  }
1401 
1402  // final clean up
1403  $this->findInvalidChilds();
1404  $this->removeInvalidChilds();
1405 
1406  return true;
1407  }
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
removeInvalidChilds(array $a_invalid_childs=null)
Removes all tree entries without any link to a valid object.
writeScanLogLine(string $a_msg)
deleteTree(array $a_node)
delete node and the whole subtree under this node
revokePermission(int $a_ref_id, int $a_rol_id=0, bool $a_keep_protected=true)
Revokes permissions of an object of one role.
findInvalidChilds()
Search database for all tree entries without any link to a valid object and stores result in $this->i...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
string $key
Consumer key/client ID value.
Definition: System.php:193
const RECOVERY_FOLDER_ID
Definition: constants.php:37
ilRbacAdmin $rbacadmin
$message
Definition: xapiexit.php:32
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restoreTrash()

ilValidator::restoreTrash ( array  $a_deleted_objects = null)

Restore all objects in trash to RecoveryFolder NOTE: All objects will be restored to top of RecoveryFolder regardless of existing hierarchical structure!

Parameters
array$a_deleted_objectslist of deleted childs (optional)
Returns
bool false on error or restore mode disabled

Definition at line 1209 of file class.ilValidator.php.

References $deleted_objects, $log, $message, restoreDeletedObjects(), and writeScanLogLine().

Referenced by validate().

1211  : bool {
1212  $ilLog = $this->log;
1213 
1214  // check mode: restore
1215  if ($this->mode["restore_trash"] !== true) {
1216  return false;
1217  }
1218 
1219  $this->writeScanLogLine("\nrestoreTrash:");
1220 
1221  if ($a_deleted_objects === null && isset($this->deleted_objects)) {
1222  $a_deleted_objects = $this->deleted_objects;
1223  }
1224 
1225  // handle wrong input
1226  if (!is_array($a_deleted_objects)) {
1227  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1228  return false;
1229  }
1230 
1231  $message = sprintf(
1232  '%s::restoreTrash(): Started...',
1233  get_class($this)
1234  );
1235  $ilLog->write($message, $ilLog->WARNING);
1236 
1237  // start restore process
1238  $restored = $this->restoreDeletedObjects($a_deleted_objects);
1239 
1240  if ($restored) {
1241  $q = "DELETE FROM tree WHERE tree!=1";
1242  $this->db->query($q);
1243 
1244  $message = sprintf(
1245  '%s::restoreTrash(): Removed all trees with tree id <> 1',
1246  get_class($this)
1247  );
1248  $ilLog->write($message, $ilLog->WARNING);
1249 
1250  $this->writeScanLogLine("Old tree entries removed");
1251  }
1252 
1253  return $restored;
1254  }
writeScanLogLine(string $a_msg)
restoreDeletedObjects(array $a_nodes)
Restore deleted objects (and their subobjects) to RecoveryFolder.
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ restoreUnboundObjects()

ilValidator::restoreUnboundObjects ( array  $a_unbound_objects = null)

Restore objects (and their subobjects) to RecoveryFolder that are valid but not linked correctly in the hierarchy because they point to an invalid parent_id.

Returns
bool false on error or restore mode disabled

Definition at line 1171 of file class.ilValidator.php.

References $log, $message, $unbound_objects, restoreSubTrees(), and writeScanLogLine().

Referenced by validate().

1173  : bool {
1174  $ilLog = $this->log;
1175 
1176  // check mode: restore
1177  if ($this->mode["restore"] !== true) {
1178  return false;
1179  }
1180 
1181  $this->writeScanLogLine("\nrestoreUnboundObjects:");
1182 
1183  if ($a_unbound_objects === null && isset($this->unbound_objects)) {
1184  $a_unbound_objects = $this->unbound_objects;
1185  }
1186 
1187  // handle wrong input
1188  if (!is_array($a_unbound_objects)) {
1189  $this->throwError(INVALID_PARAM, WARNING, DEBUG);
1190  return false;
1191  }
1192 
1193  $message = sprintf(
1194  '%s::restoreUnboundObjects(): Started...',
1195  get_class($this)
1196  );
1197  $ilLog->write($message, $ilLog->WARNING);
1198 
1199  // start restore process
1200  return $this->restoreSubTrees($a_unbound_objects);
1201  }
writeScanLogLine(string $a_msg)
restoreSubTrees(array $a_nodes)
Restore objects (and their subobjects) to RecoveryFolder.
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMode()

ilValidator::setMode ( string  $a_mode,
bool  $a_value 
)

set mode of ilValidator Usage: setMode("restore",true) => enable object restorey setMode("all",true) => enable all features For all possible modes see variables declaration

Parameters
string$a_mode
bool$a_value
Returns
bool

Definition at line 139 of file class.ilValidator.php.

References $mode, and setModeDependencies().

139  : bool
140  {
141  if ((!array_key_exists($a_mode, $this->mode) && $a_mode !== "all") || !is_bool($a_value)) {
142  $this->throwError(INVALID_PARAM, FATAL, DEBUG);
143  return false;
144  }
145 
146  if ($a_mode === "all") {
147  foreach ($this->mode as $mode => $value) {
148  $this->mode[$mode] = $a_value;
149  }
150  } else {
151  $this->mode[$a_mode] = $a_value;
152  }
153 
154  // consider mode dependencies
155  $this->setModeDependencies();
156 
157  return true;
158  }
setModeDependencies()
Sets modes by considering mode dependencies; some modes require other modes to be activated...
+ Here is the call graph for this function:

◆ setModeDependencies()

ilValidator::setModeDependencies ( )

Sets modes by considering mode dependencies; some modes require other modes to be activated.

This functions set all modes that are required according to the current setting.

Definition at line 181 of file class.ilValidator.php.

Referenced by setMode().

181  : void
182  {
183  // DO NOT change the order
184 
185  if ($this->mode["restore"] === true) {
186  $this->mode["scan"] = true;
187  $this->mode["purge"] = false;
188  }
189 
190  if ($this->mode["purge"] === true) {
191  $this->mode["scan"] = true;
192  $this->mode["restore"] = false;
193  }
194 
195  if ($this->mode["restore_trash"] === true) {
196  $this->mode["scan"] = true;
197  $this->mode["purge_trash"] = false;
198  }
199 
200  if ($this->mode["purge_trash"] === true) {
201  $this->mode["scan"] = true;
202  $this->mode["restore_trash"] = false;
203  }
204 
205  if ($this->mode["clean"] === true) {
206  $this->mode["scan"] = true;
207  }
208  }
+ Here is the caller graph for this function:

◆ validate()

ilValidator::validate ( )

Performs the validation for each enabled mode.

Returns a validation summary for display to the user.

Definition at line 214 of file class.ilValidator.php.

References $lng, checkTreeStructure(), dumpTree(), findDeletedObjects(), findInvalidChilds(), findInvalidReferences(), findInvalidRolefolders(), findMissingObjects(), findUnboundObjects(), getDeletedObjects(), getInvalidChilds(), getInvalidReferences(), getInvalidRolefolders(), getMissingObjects(), getUnboundObjects(), initGapsInTree(), ILIAS\Repository\int(), isModeEnabled(), purgeMissingObjects(), purgeTrash(), purgeUnboundObjects(), removeInvalidChilds(), removeInvalidReferences(), removeInvalidRolefolders(), restoreMissingObjects(), restoreTrash(), restoreUnboundObjects(), and ilLanguage\txt().

214  : string
215  {
216  $lng = $this->lng;
217 
218  // The validation summary.
219  $summary = "";
220 
221 
222  // STEP 1: Scan
223  // -------------------
224  $summary .= $lng->txt("scanning_system");
225  if (!$this->isModeEnabled("scan")) {
226  $summary .= $lng->txt("disabled");
227  } else {
228  $summary .= "<br/>" . $lng->txt("searching_invalid_refs");
229  if ($this->findInvalidReferences()) {
230  $summary .= count($this->getInvalidReferences()) . " " . $lng->txt("found");
231  } else {
232  $summary .= $lng->txt("found_none");
233  }
234 
235  $summary .= "<br/>" . $lng->txt("searching_invalid_childs");
236  if ($this->findInvalidChilds()) {
237  $summary .= count($this->getInvalidChilds()) . " " . $lng->txt("found");
238  } else {
239  $summary .= $lng->txt("found_none");
240  }
241 
242  $summary .= "<br/>" . $lng->txt("searching_missing_objs");
243  if ($this->findMissingObjects()) {
244  $summary .= count($this->getMissingObjects()) . " " . $lng->txt("found");
245  } else {
246  $summary .= $lng->txt("found_none");
247  }
248 
249  $summary .= "<br/>" . $lng->txt("searching_unbound_objs");
250  if ($this->findUnboundObjects()) {
251  $summary .= count($this->getUnboundObjects()) . " " . $lng->txt("found");
252  } else {
253  $summary .= $lng->txt("found_none");
254  }
255 
256  $summary .= "<br/>" . $lng->txt("searching_deleted_objs");
257  if ($this->findDeletedObjects()) {
258  $summary .= count($this->getDeletedObjects()) . " " . $lng->txt("found");
259  } else {
260  $summary .= $lng->txt("found_none");
261  }
262 
263  $summary .= "<br/>" . $lng->txt("searching_invalid_rolfs");
264  if ($this->findInvalidRolefolders()) {
265  $summary .= count($this->getInvalidRolefolders()) . " " . $lng->txt("found");
266  } else {
267  $summary .= $lng->txt("found_none");
268  }
269 
270  $summary .= "<br/><br/>" . $lng->txt("analyzing_tree_structure");
271  if ($this->checkTreeStructure()) {
272  $summary .= $lng->txt("tree_corrupt");
273  } else {
274  $summary .= $lng->txt("done");
275  }
276  }
277 
278  // STEP 2: Dump tree
279  // -------------------
280  $summary .= "<br /><br />" . $lng->txt("dumping_tree");
281  if (!$this->isModeEnabled("dump_tree")) {
282  $summary .= $lng->txt("disabled");
283  } else {
284  $error_count = $this->dumpTree();
285  if ($error_count > 0) {
286  $summary .= $lng->txt("tree_corrupt");
287  } else {
288  $summary .= $lng->txt("done");
289  }
290  }
291 
292  // STEP 3: Clean Up
293  // -------------------
294  $summary .= "<br /><br />" . $lng->txt("cleaning");
295  if (!$this->isModeEnabled("clean")) {
296  $summary .= $lng->txt("disabled");
297  } else {
298  $summary .= "<br />" . $lng->txt("removing_invalid_refs");
299  if ($this->removeInvalidReferences()) {
300  $summary .= strtolower($lng->txt("done"));
301  } else {
302  $summary .= $lng->txt("nothing_to_remove") . $lng->txt("skipped");
303  }
304 
305  $summary .= "<br />" . $lng->txt("removing_invalid_childs");
306  if ($this->removeInvalidChilds()) {
307  $summary .= strtolower($lng->txt("done"));
308  } else {
309  $summary .= $lng->txt("nothing_to_remove") . $lng->txt("skipped");
310  }
311 
312  $summary .= "<br />" . $lng->txt("removing_invalid_rolfs");
313  if ($this->removeInvalidRolefolders()) {
314  $summary .= strtolower($lng->txt("done"));
315  } else {
316  $summary .= $lng->txt("nothing_to_remove") . $lng->txt("skipped");
317  }
318 
319  // find unbound objects again AFTER cleaning process!
320  // This updates the array 'unboundobjects' required for the further steps
321  // There might be other objects unbounded now due to removal of object_data/reference entries.
322  $this->findUnboundObjects();
323  }
324 
325  // STEP 4: Restore objects
326  $summary .= "<br /><br />" . $lng->txt("restoring");
327 
328  if (!$this->isModeEnabled("restore")) {
329  $summary .= $lng->txt("disabled");
330  } else {
331  $summary .= "<br />" . $lng->txt("restoring_missing_objs");
332  if ($this->restoreMissingObjects()) {
333  $summary .= strtolower($lng->txt("done"));
334  } else {
335  $summary .= $lng->txt("nothing_to_restore") . $lng->txt("skipped");
336  }
337 
338  $summary .= "<br />" . $lng->txt("restoring_unbound_objs");
339  if ($this->restoreUnboundObjects()) {
340  $summary .= strtolower($lng->txt("done"));
341  } else {
342  $summary .= $lng->txt("nothing_to_restore") . $lng->txt("skipped");
343  }
344  }
345 
346  // STEP 5: Restoring Trash
347  $summary .= "<br /><br />" . $lng->txt("restoring_trash");
348 
349  if (!$this->isModeEnabled("restore_trash")) {
350  $summary .= $lng->txt("disabled");
351  } elseif ($this->restoreTrash()) {
352  $summary .= strtolower($lng->txt("done"));
353  } else {
354  $summary .= $lng->txt("nothing_to_restore") . $lng->txt("skipped");
355  }
356 
357  // STEP 6: Purging...
358  $summary .= "<br /><br />" . $lng->txt("purging");
359 
360  if (!$this->isModeEnabled("purge")) {
361  $summary .= $lng->txt("disabled");
362  } else {
363  $summary .= "<br />" . $lng->txt("purging_missing_objs");
364  if ($this->purgeMissingObjects()) {
365  $summary .= strtolower($lng->txt("done"));
366  } else {
367  $summary .= $lng->txt("nothing_to_purge") . $lng->txt("skipped");
368  }
369 
370  $summary .= "<br />" . $lng->txt("purging_unbound_objs");
371  if ($this->purgeUnboundObjects()) {
372  $summary .= strtolower($lng->txt("done"));
373  } else {
374  $summary .= $lng->txt("nothing_to_purge") . $lng->txt("skipped");
375  }
376  }
377 
378  // STEP 7: Purging trash...
379  $summary .= "<br /><br />" . $lng->txt("purging_trash");
380 
381  if (!$this->isModeEnabled("purge_trash")) {
382  $summary .= $lng->txt("disabled");
383  } elseif ($this->purgeTrash()) {
384  $summary .= strtolower($lng->txt("done"));
385  } else {
386  $summary .= $lng->txt("nothing_to_purge") . $lng->txt("skipped");
387  }
388 
389  // STEP 8: Initialize gaps in tree
390  if ($this->isModeEnabled("clean")) {
391  $summary .= "<br /><br />" . $lng->txt("cleaning_final");
392  if ($this->initGapsInTree()) {
393  $summary .= "<br />" . $lng->txt("initializing_gaps") . " " . strtolower($lng->txt("done"));
394  }
395  }
396 
397  // check RBAC starts here
398  // ...
399 
400  // le fin
401  foreach ($this->mode as $mode => $value) {
402  $arr[] = $mode . "[" . (int) $value . "]";
403  }
404 
405  return $summary;
406  }
ilLanguage $lng
findDeletedObjects()
Search database for all tree entries having no valid parent (=> no valid path to root node) and store...
getDeletedObjects()
Gets all object in trash.
removeInvalidChilds(array $a_invalid_childs=null)
Removes all tree entries without any link to a valid object.
findMissingObjects()
Search database for all object entries with missing reference and/or tree entry and stores result in ...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
isModeEnabled(string $a_mode)
getInvalidChilds()
Gets all tree entries without any link to a valid object.
purgeUnboundObjects(array $a_nodes=null)
Removes all invalid objects from system.
dumpTree()
Dumps the Tree structure into the scan log.
findInvalidChilds()
Search database for all tree entries without any link to a valid object and stores result in $this->i...
getUnboundObjects()
Gets all tree entries having no valid parent (=> no valid path to root node) Returns an array with ch...
purgeMissingObjects(array $a_nodes=null)
Removes all missing objects from system.
restoreMissingObjects(array $a_missing_objects=null)
Restores missing reference and/or tree entry for all objects found by this::getMissingObjects() Resto...
restoreUnboundObjects(array $a_unbound_objects=null)
Restore objects (and their subobjects) to RecoveryFolder that are valid but not linked correctly in t...
getInvalidReferences()
Gets all reference entries that are not linked with a valid object id.
getMissingObjects()
Gets all object entries with missing reference and/or tree entry.
findInvalidReferences()
Search database for all reference entries that are not linked with a valid object id and stores resul...
removeInvalidReferences(array $a_invalid_refs=null)
Removes all reference entries that are linked with invalid object IDs.
findInvalidRolefolders()
Search database for all rolefolder object entries with missing reference entry.
getInvalidRolefolders()
Gets invalid rolefolders (same as missing objects)
findUnboundObjects()
Search database for all tree entries having no valid parent (=> no valid path to root node) and store...
restoreTrash(array $a_deleted_objects=null)
Restore all objects in trash to RecoveryFolder NOTE: All objects will be restored to top of RecoveryF...
removeInvalidRolefolders(array $a_invalid_rolefolders=null)
Removes invalid rolefolders.
initGapsInTree()
Initializes gaps in lft/rgt values of a tree.
purgeTrash(array $a_nodes=null)
Removes all objects in trash from system.
+ Here is the call graph for this function:

◆ writeScanLogArray()

ilValidator::writeScanLogArray ( array  $a_arr)

Definition at line 1692 of file class.ilValidator.php.

References isLogEnabled().

Referenced by findDeletedObjects(), findInvalidChilds(), findInvalidRBACEntries(), findInvalidReferences(), findInvalidRolefolders(), findMissingObjects(), and findUnboundObjects().

1692  : void
1693  {
1694  if (!$this->isLogEnabled()) {
1695  return;
1696  }
1697 
1698  foreach ($a_arr as $entry) {
1699  $this->scan_log->write(implode("\t", $entry));
1700  }
1701  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeScanLogLine()

ilValidator::writeScanLogLine ( string  $a_msg)

Field Documentation

◆ $db

◆ $deleted_objects

array ilValidator::$deleted_objects = []

Definition at line 70 of file class.ilValidator.php.

Referenced by getDeletedObjects(), purgeTrash(), and restoreTrash().

◆ $invalid_childs

array ilValidator::$invalid_childs = []

Definition at line 67 of file class.ilValidator.php.

Referenced by getInvalidChilds(), and removeInvalidChilds().

◆ $invalid_objects

array ilValidator::$invalid_objects = []

contains correct registrated objects but data are corrupted (experimental)

Definition at line 82 of file class.ilValidator.php.

◆ $invalid_rbac_entries

array ilValidator::$invalid_rbac_entries

Definition at line 36 of file class.ilValidator.php.

◆ $invalid_references

array ilValidator::$invalid_references = []

Definition at line 66 of file class.ilValidator.php.

Referenced by getInvalidReferences(), and removeInvalidReferences().

◆ $invalid_rolefolders

array ilValidator::$invalid_rolefolders = []

contains missing objects that are rolefolders.

found by this:: findMissingObjects()' these rolefolders must be removed before any restore operations

Definition at line 77 of file class.ilValidator.php.

Referenced by getInvalidRolefolders(), and removeInvalidRolefolders().

◆ $lng

ilLanguage ilValidator::$lng
protected

Definition at line 28 of file class.ilValidator.php.

Referenced by validate().

◆ $log

◆ $logging

bool ilValidator::$logging = false

Definition at line 83 of file class.ilValidator.php.

Referenced by isLogEnabled().

◆ $media_pool_ids

array ilValidator::$media_pool_ids = null
protected

Definition at line 33 of file class.ilValidator.php.

◆ $missing_objects

array ilValidator::$missing_objects = []

◆ $mode

array ilValidator::$mode
Initial value:
= [
"scan" => true

Definition at line 56 of file class.ilValidator.php.

Referenced by setMode().

◆ $obj_definition

ilObjectDefinition ilValidator::$obj_definition
protected

Definition at line 26 of file class.ilValidator.php.

◆ $object_types_exclude

array ilValidator::$object_types_exclude
Initial value:
= [
"adm", "root", "mail", "usrf", "objf", "lngf",
"trac", "taxf", "auth", "rolf", "assf", "svyf", "extt", "adve", "fold"
]

list of object types to exclude from recovering

i added folder due to bug #1860 (even if this will not completely fix it) and the fact, that media pool folders may find their way into the recovery folder (what results in broken pools, if the are deleted) Alex, 2006-07-21

I removed file objects from this exclusion list, because file objects can be in the repository tree, and thus can suffer from data inconsistencies as well. Werner, 2007-04-16

Definition at line 51 of file class.ilValidator.php.

◆ $rbac_object_types

array ilValidator::$rbac_object_types

Definition at line 34 of file class.ilValidator.php.

◆ $rbacadmin

ilRbacAdmin ilValidator::$rbacadmin
protected

◆ $scan_log

ilLog ilValidator::$scan_log = null

Definition at line 84 of file class.ilValidator.php.

Referenced by readScanLog().

◆ $scan_log_file

string ilValidator::$scan_log_file = "scanlog.log"

Definition at line 85 of file class.ilValidator.php.

◆ $scan_log_separator

string ilValidator::$scan_log_separator = "<!-- scan log start -->"

Definition at line 86 of file class.ilValidator.php.

◆ $tree

ilTree ilValidator::$tree
protected

Definition at line 31 of file class.ilValidator.php.

Referenced by initGapsInTree(), restoreDeletedObjects(), and restoreSubTrees().

◆ $unbound_objects

array ilValidator::$unbound_objects = []

◆ $user

ilObjUser ilValidator::$user
protected

Definition at line 32 of file class.ilValidator.php.

Referenced by purgeObjects().

◆ $workspace_object_ids

array ilValidator::$workspace_object_ids = []

Definition at line 35 of file class.ilValidator.php.

◆ dump_tree

array ilValidator::dump_tree
Initial value:
=> false,
"clean" => false,
"restore" => false,
"purge" => false,
"restore_trash" => false,
"purge_trash" => false
]

Definition at line 58 of file class.ilValidator.php.


The documentation for this class was generated from the following file: