Skip to content

Commit eeae136

Browse files
committed
2.1.3
1 parent 2f66b7c commit eeae136

File tree

5 files changed

+17
-30
lines changed

5 files changed

+17
-30
lines changed

code/General.class.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,6 @@ public static function getFieldTypeSettingIds()
234234
}
235235

236236

237-
public static function getValidationRuleIds()
238-
{
239-
$db = Core::$db;
240-
$db->query("SELECT rule_id FROM {PREFIX}field_type_validation_rules");
241-
$db->execute();
242-
return $db->fetchAll(PDO::FETCH_COLUMN);
243-
}
244-
245-
246237
public static function getFormFieldIds($form_id)
247238
{
248239
$db = Core::$db;

code/Hooks.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static function verifyModuleHooks($module_folder)
4444

4545
$actual_num_hooks = $db->numRows();
4646

47+
$extra_info = "";
4748
$result = "pass";
4849
if ($actual_num_hooks < $expected_num_hooks) {
4950
$result = "missing_hooks";
@@ -86,13 +87,14 @@ public static function verifyModuleHooks($module_folder)
8687

8788
if (!$found) {
8889
$result = "invalid_hooks";
90+
$extra_info = "[missing: $hook_type,$action_location,$function_name,$hook_function,$priority]";
8991
break;
9092
}
9193
}
9294
}
9395
}
9496

95-
return $result;
97+
return array($result, $extra_info);
9698
}
9799

98100

code/Module.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Module extends FormToolsModule
1313
protected $author = "Ben Keen";
1414
protected $authorEmail = "[email protected]";
1515
protected $authorLink = "http://formtools.org";
16-
protected $version = "2.1.2";
17-
protected $date = "2017-11-25";
16+
protected $version = "2.1.3";
17+
protected $date = "2017-12-20";
1818
protected $originLanguage = "en_us";
1919
protected $jsFiles = array("scripts/tests.js");
2020
protected $cssFiles = array("css/styles.css");

code/Orphans.class.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,13 @@ private static function testFieldTypeValidationRules($remove_orphans)
10261026
}
10271027

10281028

1029+
/**
1030+
* N.B. The field_validation table has a composite primary key of rule_id and field_id. rule_id is just an integer
1031+
* from 1-N, where N is the number of validation rules for the field type. So this test just looks for and clears out
1032+
* invalid field IDs - rule IDs are neither here nor there.
1033+
* @param $remove_orphans
1034+
* @return array
1035+
*/
10291036
private static function testFieldValidation($remove_orphans)
10301037
{
10311038
$db = Core::$db;
@@ -1036,37 +1043,23 @@ private static function testFieldValidation($remove_orphans)
10361043
);
10371044

10381045
$valid_field_ids = General::getFieldIds();
1039-
$valid_rule_ids = General::getValidationRuleIds();
10401046

10411047
$db->query("SELECT rule_id, field_id FROM {PREFIX}field_validation");
10421048
$db->execute();
10431049
$rows = $db->fetchAll();
10441050

10451051
$num_tests = 0;
10461052
foreach ($rows as $row) {
1047-
if (!in_array($row["rule_id"], $valid_rule_ids)) {
1048-
$response["problems"][] = "Invalid reference to rule_id: {$row["rule_id"]} for field_id: {$row["field_id"]}";
1049-
1050-
// clean-up code
1051-
if ($remove_orphans) {
1052-
$db->query("
1053-
DELETE FROM {PREFIX}field_validation
1054-
WHERE rule_id = :rule_id
1055-
");
1056-
$db->bind("rule_id", $row["rule_id"]);
1057-
$db->execute();
1058-
}
1059-
}
10601053
if (!in_array($row["field_id"], $valid_field_ids)) {
10611054
$response["problems"][] = "Invalid reference to field_id: {$row["field_id"]} for rule_id: {$row["rule_id"]}";
10621055

10631056
// clean-up code
10641057
if ($remove_orphans) {
10651058
$db->query("
10661059
DELETE FROM {PREFIX}field_validation
1067-
WHERE rule_id = :rule_id
1060+
WHERE field_id = :field_id
10681061
");
1069-
$db->bind("rule_id", $row["rule_id"]);
1062+
$db->bind("field_id", $row["field_id"]);
10701063
$db->execute();
10711064
}
10721065
}

code/actions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@
7171
$module_info = Modules::getModule($module_id);
7272
$module_folder = $module_info["module_folder"];
7373
$module_version = $module_info["version"];
74-
$result = Hooks::verifyModuleHooks($module_folder);
74+
list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder);
7575

7676
echo json_encode(array(
7777
"module_id" => $module_id,
7878
"module_folder" => $module_folder,
7979
"module_name" => $module_info["module_name"],
80-
"result" => $result
80+
"result" => $result,
81+
"extra" => $extra_info
8182
));
8283
break;
8384

0 commit comments

Comments
 (0)