tenden β created an issue.
More cleanup.
More coding standards cleanup.
Removed "use Drupal\Core\Database\Query\Condition;"
Cleaned up various coding standard issues
Trimmed trailing spaces.
Reworked this patch from scratch to make it easier to understand and to remove the null exceptions thrown in PHP 8.1.
The biggest change was the rewriting of the redirect_alter_where_clause. The old function passed the condition object into Sql.php as an operator of type 'formula'. This caused null pointer exceptions to be thrown on lines 255 and 401 of Condition.php.
To fix this, the where condition changes had to be put into one large string and then passed to Sql.php.
$query->where[$key_group_conditions]['conditions'][$next_key_cond] = [
'field' => $where_addition,
'value' => [],
'operator' => 'formula',
];
Patch to solve issue.
tenden β created an issue.
Hello @martbfly,
The reason why it does not work for the data_export display is that $view->exposed_widgets
is set to an empty array. Thus array_key_exists('redirect_redirect__uri', $view->exposed_widgets)
returns false.
That does make sense because the data_export display is only outputting to a file rather than exposing any widgets.
What do you think about changing the if condition to the following:
if ($view->storage->get('base_table') == "redirect" && (isset($view->exposed_widgets)) {
This would ensure that $view->exposed_widgets
is at least set even if it is empty.
As before, let me know your thoughts.
Hello @martybfly, the character encoding for lines 129 to 133 has issues. See below.
Patch 10 - lines 129 to 133
+ * "\t" (ASCII 9 (0x09)), tabulaciΓΖΓΒ³n.
+ * "\n" (ASCII 10 (0x0A)), salto de lΓΖΓΒnea.
+ * "\r" (ASCII 13 (0x0D)), retorno de carro.
+ * "\0" (ASCII 0 (0x00)), el byte NUL.
+ * "\x0B" (ASCII 11 (0x0B)), tabulaciΓΖΓΒ³n vertical.
Correct characters - lines 129 to 133
+ * "\t" (ASCII 9 (0x09)), tabulaciΓ³n.
+ * "\n" (ASCII 10 (0x0A)), salto de lΓnea.
+ * "\r" (ASCII 13 (0x0D)), retorno de carro.
+ * "\0" (ASCII 0 (0x00)), el byte NUL.
+ * "\x0B" (ASCII 11 (0x0B)), tabulaciΓ³n vertical.
Hello @martybfly
That change didn't work for me, but what about this:
if ($view->storage->get('base_table') == "redirect" && (str_starts_with($view->getDisplay()->display['id'], 'page_') || str_starts_with($view->getDisplay()->display['id'], 'data_export_'))) {
It restricts the display_plugin to just the 'page' and 'data_export' types.
Do you see any issues?
Thanks for the changes marytbfly.
Our project has added a CSV export Display to this Redirect View, but since the if condition only allows a disply with the name 'page_1', our CSV export page never calls the _redirect_recursively_alter_query_conditions function. This means that the CSV display will never add the join to the path_alias table.
I think having the number of displays restricted to just 1 whose name is 'page_1' is too restrictive.
Is it reasonable to change the if statement inside the redirect_views_query_alter function to the following:
if ($view->storage->get('base_table') == "redirect") {
Please let me know your thoughts.