Skip to content

Commit 293f105

Browse files
committed
2.1.4
1 parent 63dc662 commit 293f105

File tree

5 files changed

+109
-108
lines changed

5 files changed

+109
-108
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
This module replaces the older Database Integrity module. It offers a few simple, quick tests to run on your Form Tools
44
installation: kind of like taking your car to get it serviced.
55

6+
67
### Documentation
78

89
- [https://docs.formtools.org/modules/system_check/](https://docs.formtools.org/modules/system_check/)

code/Module.class.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88

99
class Module extends FormToolsModule
1010
{
11-
protected $moduleName = "System Check";
12-
protected $moduleDesc = "This module offers a few tests to analyze and repair your Form Tools installation.";
13-
protected $author = "Ben Keen";
14-
protected $authorEmail = "[email protected]";
15-
protected $authorLink = "http://formtools.org";
16-
protected $version = "2.1.3";
17-
protected $date = "2017-12-20";
18-
protected $originLanguage = "en_us";
19-
protected $jsFiles = array("scripts/tests.js");
20-
protected $cssFiles = array("css/styles.css");
11+
protected $moduleName = "System Check";
12+
protected $moduleDesc = "This module offers a few tests to analyze and repair your Form Tools installation.";
13+
protected $author = "Ben Keen";
14+
protected $authorEmail = "[email protected]";
15+
protected $authorLink = "http://formtools.org";
16+
protected $version = "2.1.4";
17+
protected $date = "2018-12-23";
18+
protected $originLanguage = "en_us";
19+
protected $jsFiles = array("scripts/tests.js");
20+
protected $cssFiles = array("css/styles.css");
2121

22-
protected $nav = array(
23-
"module_name" => array("index.php", false),
24-
"phrase_file_verification" => array("files.php", true),
25-
"phrase_table_verification" => array("tables.php", true),
26-
"phrase_hook_verification" => array("hooks.php", true),
27-
"phrase_orphan_clean_up" => array("orphans.php", true),
28-
"phrase_environment_info" => array("env.php", false),
29-
"word_help" => array("help.php", false)
30-
);
22+
protected $nav = array(
23+
"module_name" => array("index.php", false),
24+
"phrase_file_verification" => array("files.php", true),
25+
"phrase_table_verification" => array("tables.php", true),
26+
"phrase_hook_verification" => array("hooks.php", true),
27+
"phrase_orphan_clean_up" => array("orphans.php", true),
28+
"phrase_environment_info" => array("env.php", false),
29+
"word_help" => array("help.php", false)
30+
);
3131
}

code/Tables.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static function checkComponentTableColumns($component_info, $table_name)
6666
$invalid_columns = array();
6767

6868
// get the actual content of the db table (should be moved to helper)
69-
$db->query("SHOW COLUMNS FROM $table_name");
69+
$db->query("SHOW COLUMNS FROM `$table_name`");
7070
$db->execute();
7171

7272
$actual_column_info = array();

code/actions.php

+87-87
Original file line numberDiff line numberDiff line change
@@ -25,98 +25,98 @@
2525
// the action to take and the ID of the page where it will be displayed (allows for
2626
// multiple calls on same page to load content in unique areas)
2727
$request = array_merge($_GET, $_POST);
28-
$action = $request["action"];
28+
$action = $request["action"];
2929
$settings = Settings::get();
3030
$root_dir = Core::getRootDir();
3131

3232
switch ($action) {
3333

34-
// Stage 1 of the Table Verification test: returns a list of tables to test for a particular component
35-
case "get_component_tables":
36-
$component = $request["component"];
37-
38-
// N.B. from 2.1.5 onwards, the Core stores its own DB structure
39-
if ($component == "core") {
40-
require_once("$root_dir/global/misc/config_core.php");
41-
$tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE));
42-
} else {
43-
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
44-
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
45-
$tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"]));
46-
}
47-
echo json_encode(array("tables" => $tables));
48-
break;
49-
50-
// Stage 2 of the Table Verification test: verifies the table structure
51-
case "verify_table":
52-
$component = $request["component"];
53-
if ($component == "core") {
54-
require_once("$root_dir/global/misc/config_core.php");
55-
$info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]);
56-
$info["table_name"] = $request["table_name"];
57-
echo json_encode($info);
58-
} else {
59-
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
60-
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
61-
$info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]);
62-
$info["table_name"] = $request["table_name"];
63-
echo json_encode($info);
64-
}
65-
break;
66-
67-
// verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks
68-
// in a single step and returns the result
69-
case "verify_module_hooks":
70-
$module_id = $request["module_id"];
71-
$module_info = Modules::getModule($module_id);
72-
$module_folder = $module_info["module_folder"];
73-
$module_version = $module_info["version"];
74-
list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder);
75-
76-
echo json_encode(array(
77-
"module_id" => $module_id,
78-
"module_folder" => $module_folder,
79-
"module_name" => $module_info["module_name"],
80-
"result" => $result,
81-
"extra" => $extra_info
82-
));
83-
break;
84-
85-
case "verify_component_files":
86-
$component = $request["component"];
87-
88-
$return_info = array("result" => "pass");
89-
if ($component == "core") {
90-
$missing_files = Files::checkCoreFiles();
91-
$return_info["component_type"] = "core";
92-
$return_info["component_name"] = "Form Tools Core";
93-
}
94-
if (preg_match("/^module_/", $component)) {
95-
$module_id = preg_replace("/^module_/", "", $component);
96-
$module_info = Modules::getModule($module_id);
97-
$missing_files = Files::checkModuleFiles($module_info["module_folder"]);
98-
$return_info["component_type"] = "module";
99-
$return_info["component_name"] = $module_info["module_name"];
100-
}
101-
if (preg_match("/^theme_/", $component)) {
102-
$theme_id = preg_replace("/^theme_/", "", $component);
103-
$theme_info = Themes::getTheme($theme_id);
104-
$missing_files = Files::checkThemeFiles($theme_info["theme_folder"]);
105-
$return_info["component_type"] = "theme";
106-
$return_info["component_name"] = $theme_info["theme_name"];
107-
}
108-
if (!empty($missing_files)) {
109-
$return_info["result"] = "fail";
110-
$return_info["missing_files"] = $missing_files;
111-
}
112-
echo json_encode($return_info);
113-
break;
114-
115-
case "find_table_orphans":
116-
$remove_orphans = isset($request["remove_orphans"]) ? true : false;
117-
$results = Orphans::findTableOrphans($request["table_name"], $remove_orphans);
118-
echo json_encode($results);
119-
break;
34+
// Stage 1 of the Table Verification test: returns a list of tables to test for a particular component
35+
case "get_component_tables":
36+
$component = $request["component"];
37+
38+
// N.B. from 2.1.5 onwards, the Core stores its own DB structure
39+
if ($component == "core") {
40+
require_once("$root_dir/global/misc/config_core.php");
41+
$tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE));
42+
} else {
43+
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
44+
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
45+
$tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"]));
46+
}
47+
echo json_encode(array("tables" => $tables));
48+
break;
49+
50+
// Stage 2 of the Table Verification test: verifies the table structure
51+
case "verify_table":
52+
$component = $request["component"];
53+
if ($component == "core") {
54+
require_once("$root_dir/global/misc/config_core.php");
55+
$info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]);
56+
$info["table_name"] = $request["table_name"];
57+
echo json_encode($info);
58+
} else {
59+
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
60+
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
61+
$info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]);
62+
$info["table_name"] = $request["table_name"];
63+
echo json_encode($info);
64+
}
65+
break;
66+
67+
// verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks
68+
// in a single step and returns the result
69+
case "verify_module_hooks":
70+
$module_id = $request["module_id"];
71+
$module_info = Modules::getModule($module_id);
72+
$module_folder = $module_info["module_folder"];
73+
$module_version = $module_info["version"];
74+
list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder);
75+
76+
echo json_encode(array(
77+
"module_id" => $module_id,
78+
"module_folder" => $module_folder,
79+
"module_name" => $module_info["module_name"],
80+
"result" => $result,
81+
"extra" => $extra_info
82+
));
83+
break;
84+
85+
case "verify_component_files":
86+
$component = $request["component"];
87+
88+
$return_info = array("result" => "pass");
89+
if ($component == "core") {
90+
$missing_files = Files::checkCoreFiles();
91+
$return_info["component_type"] = "core";
92+
$return_info["component_name"] = "Form Tools Core";
93+
}
94+
if (preg_match("/^module_/", $component)) {
95+
$module_id = preg_replace("/^module_/", "", $component);
96+
$module_info = Modules::getModule($module_id);
97+
$missing_files = Files::checkModuleFiles($module_info["module_folder"]);
98+
$return_info["component_type"] = "module";
99+
$return_info["component_name"] = $module_info["module_name"];
100+
}
101+
if (preg_match("/^theme_/", $component)) {
102+
$theme_id = preg_replace("/^theme_/", "", $component);
103+
$theme_info = Themes::getTheme($theme_id);
104+
$missing_files = Files::checkThemeFiles($theme_info["theme_folder"]);
105+
$return_info["component_type"] = "theme";
106+
$return_info["component_name"] = $theme_info["theme_name"];
107+
}
108+
if (!empty($missing_files)) {
109+
$return_info["result"] = "fail";
110+
$return_info["missing_files"] = $missing_files;
111+
}
112+
echo json_encode($return_info);
113+
break;
114+
115+
case "find_table_orphans":
116+
$remove_orphans = isset($request["remove_orphans"]) ? true : false;
117+
$results = Orphans::findTableOrphans($request["table_name"], $remove_orphans);
118+
echo json_encode($results);
119+
break;
120120
}
121121

122122

lang/en_us.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
$L["text_help"] = "For more information on this module, please see the <a href=\"https://docs.formtools.org/modules/system_check/\" target=\"_blank\">help documentation</a> on the Form Tools site.";
5252
$L["text_file_check"] = "This examines all compatible components (Core, modules and themes) to confirm that the component's files exist.";
5353
$L["text_file_verification_intro"] = "This checks over your Core, modules and themes to confirm that all the necessary files have been uploaded properly. If any are missing, you will need to re-download the appropriate component and upload them to your server.";
54-
$L["text_orphan_record_check_intro"] = "This is a house-keeping test to examine the Core database tables for any unwanted orphaned records and references. Orphaned records are database entries that are no longer needed and should have been deleted along with their \"parents\". For example, when you delete a form, any references to that form ID should also be deleted. Orphaned records shouldn't cause problems, but add unnecessary clutter to your database. <b>If this test finds anything, we'd appreciate it if you <a href=\"http://forums.formtools.org/\">report them in the forums</a>!</b>";
54+
$L["text_orphan_record_check_intro"] = "This is a house-keeping test to examine the Core database tables for any unwanted orphaned records and references. Orphaned records are database entries that are no longer needed and should have been deleted along with their \"parents\". For example, when you delete a form, any references to that form ID should also be deleted. Orphaned records shouldn't cause problems, but add unnecessary clutter to your database. <b>If this test finds anything, we'd appreciate it if you <a href=\"https://github.com/formtools/core/issues\" target=\"_blank\">reported it on github</a>!</b>";
5555
$L["text_orphan_desc_short"] = "A housekeeping test to identify and remove old database records and references that are no longer needed and should have been deleted.";
5656
$L["text_environment_overview_summary"] = "This section below contains a report of key information about your Form Tools installation and environment, which can be helpful when reporting bugs.";
5757
$L["text_ft3_compatibility"] = "Form Tools 3 has slightly difference server requirements than Form Tools 2. This page runs a couple of simple tests to confirm you will be able to run the newer version.";

0 commit comments

Comments
 (0)