From 721e927f124e3cb96e0503d4267c517de03c885c Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 12 Apr 2021 22:23:49 +0200 Subject: [PATCH] Fix #16791 - Undefined index table_schema and "DESCRIBE FILES" broken links Reverts: ca0244f06bf989ce294d0181a38b50121709450a because the code was guessing what the parent had already found but the code did not fine the same results between the parent and the child. Now passing the result from the parent to the child will remove one guessing Signed-off-by: William Desportes --- libraries/classes/Display/Results.php | 52 +++++++++++++++-------------------- test/classes/Display/ResultsTest.php | 6 +--- 2 files changed, 23 insertions(+), 35 deletions(-) diff --git a/libraries/classes/Display/Results.php b/libraries/classes/Display/Results.php index 8c31ae8958..afbd118a45 100644 --- a/libraries/classes/Display/Results.php +++ b/libraries/classes/Display/Results.php @@ -2883,10 +2883,9 @@ class Results // Check for the predefined fields need to show as link in schemas if (! empty($specialSchemaLinks[$dbLower][$tblLower][$nameLower])) { $linking_url = $this->getSpecialLinkUrl( - $specialSchemaLinks, + $specialSchemaLinks[$dbLower][$tblLower][$nameLower], $row[$i], - $row_info, - mb_strtolower($meta->orgname) + $row_info ); $transformation_plugin = new Text_Plain_Link(); @@ -3028,51 +3027,44 @@ class Results /** * Get link for display special schema links * - * // phpcs:disable Generic.Files.LineLength.TooLong - * @param array>|string>>>> $specialSchemaLinks - * @param string $column_value column value - * @param array $row_info information about row - * @param string $field_name column name + * @param array>|string> $link_relations + * @param string $column_value column value + * @param array $row_info information about row + * * @return string generated link - * // phpcs:enable - * - * @phpstan-param array< - * string, array< - * string, array< - * string, - * array{ - * 'link_param': string, - * 'link_dependancy_params'?: array< + * + * @phpstan-param array{ + * 'link_param': string, + * 'link_dependancy_params'?: array< * int, * array{'param_info': string, 'column_name': string} * >, - * 'default_page': string - * }> - * > - * > $specialSchemaLinks + * 'default_page': string + * } $link_relations */ private function getSpecialLinkUrl( - array $specialSchemaLinks, + array $link_relations, $column_value, - array $row_info, - $field_name + array $row_info ) { $linking_url_params = []; - $db = mb_strtolower($this->properties['db']); - $table = mb_strtolower($this->properties['table']); - $link_relations = $specialSchemaLinks[$db][$table][$field_name]; $linking_url_params[$link_relations['link_param']] = $column_value; - $divider = strpos($link_relations['default_page'] ?? '', '?') ? '&' : '?'; + $divider = strpos($link_relations['default_page'], '?') ? '&' : '?'; if (empty($link_relations['link_dependancy_params'])) { return $link_relations['default_page'] . Url::getCommonRaw($linking_url_params, $divider); } foreach ($link_relations['link_dependancy_params'] as $new_param) { - $linking_url_params[$new_param['param_info']] - = $row_info[mb_strtolower($new_param['column_name'])]; + $columnName = mb_strtolower($new_param['column_name']); + + // If there is a value for this column name in the row_info provided + if (isset($row_info[$columnName])) { + $urlParameterName = $new_param['param_info']; + $linking_url_params[$urlParameterName] = $row_info[$columnName]; + } // Special case 1 - when executing routines, according // to the type of the routine, url param changes diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php index b0410f2243..58a656dabb 100644 --- a/test/classes/Display/ResultsTest.php +++ b/test/classes/Display/ResultsTest.php @@ -415,9 +415,6 @@ class ResultsTest extends AbstractTestCase ], ]; - $this->object->properties['db'] = $db; - $this->object->properties['table'] = $table; - $this->assertEquals( $output, $this->callFunction( @@ -425,10 +422,9 @@ class ResultsTest extends AbstractTestCase DisplayResults::class, 'getSpecialLinkUrl', [ - $specialSchemaLinks, + $specialSchemaLinks[$db][$table][$field_name], $column_value, $row_info, - $field_name, ] ) ); -- 2.11.4.GIT