- Issue created by @Steven Snedker
- 🇮🇳India annmarysruthy
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies → .
- 🇮🇳India annmarysruthy
Replicated the issue. The below changes in core/modules/comment/src/Plugin/views/sort/StatisticsLastUpdated.php could fix the issue:
<?php namespace Drupal\comment\Plugin\views\sort; use Drupal\views\Attribute\ViewsSort; use Drupal\views\Plugin\views\sort\Date; /** * Sort handler for the newer of last comment / entity updated. * * @ingroup views_sort_handlers */ #[ViewsSort("comment_ces_last_updated")] class StatisticsLastUpdated extends Date { /** * The node table. */ // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing protected ?string $node_table; /** * The field alias. */ // phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName, Drupal.Commenting.VariableComment.Missing protected ?string $field_alias; /** * {@inheritdoc} */ public function query() { $this->ensureMyTable(); $this->node_table = $this->query->ensureTable('node_field_data', $this->relationship); $this->query->addField($this->node_table, 'changed'); $this->field_alias = $this->query->addOrderBy(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->tableAlias . ".last_comment_timestamp)", $this->options['order'], $this->tableAlias . '_' . $this->field); } }
In the above solution, issue is fixed with fewer changes than the proposed solution in the issue: making $field_alias nullable and using the proper table (node_field_data instead of node).
- Merge request !11897Issue #3519952: fix Comment Statistics: Updated/commented date TypeError → (Open) created by annmarysruthy
- 🇺🇸United States smustgrave
Thanks for working on this, can we add some test coverage please
- 🇺🇸United States smustgrave
Left some comments, is there not an existing test that could be expanded by chance?
If you are another contributor eager to jump in, please allow the previous poster(s) at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
- 🇮🇳India annmarysruthy
@smustgrave added commits for review comments. Kindly review.
Checked the existing tests and could not find one related to sorting. Therefore I created a new test.