πŸ‡¨πŸ‡¦Canada @tenden

Account created on 3 June 2009, about 15 years ago
#

Recent comments

πŸ‡¨πŸ‡¦Canada tenden

Removed "use Drupal\Core\Database\Query\Condition;"
Cleaned up various coding standard issues

πŸ‡¨πŸ‡¦Canada tenden

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',
];
πŸ‡¨πŸ‡¦Canada tenden

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.

πŸ‡¨πŸ‡¦Canada tenden

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.

πŸ‡¨πŸ‡¦Canada tenden

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?

πŸ‡¨πŸ‡¦Canada tenden

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.

Production build 0.69.0 2024