Closed (duplicate)
Project:
Drupal core
Version:
9.5.x-dev
Component:
views.module
Priority:
Minor
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
27 Sep 2018 at 19:55 UTC
Updated:
17 Jul 2022 at 00:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
longwaveNot sure how to write a test for this, or if we actually need one.
Comment #3
joachim commentedPatch looks good.
I agree, I don't think this needs to be tested.
Comment #5
dhirendra.mishra commentedComment #6
dhirendra.mishra commentedAdding condition of !empty.Please check.
Comment #7
joachim commentedThere's no need for an !empty check, as the code further up initializes the variable to an empty string.
Comment #8
dhirendra.mishra commented@joachim, But not using !empty condition will allow to create $data element array with empty key.
Instead can we add !empty condition for variable $revision_table everywhere in code. For example please see below line of code. can you please confirm?
if ($revision_table) {
$data[$revision_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]);
$data[$revision_table]['table']['provider'] = $this->entityType->getProvider();
$views_revision_base_table = $revision_table;
if ($revision_data_table) {
$views_revision_base_table = $revision_data_table;
}
$data[$views_revision_base_table]['table']['entity revision'] = TRUE;
$data[$views_revision_base_table]['table']['base'] = [
'field' => $revision_field,
'title' => $this->t('@entity_type revisions', ['@entity_type' => $this->entityType->getLabel()]),
];
// Join the revision table to the base table.
$data[$views_revision_base_table]['table']['join'][$views_base_table] = [
'left_field' => $revision_field,
'field' => $revision_field,
'type' => 'INNER',
];
if ($revision_data_table) {
$data[$revision_data_table]['table']['group'] = $this->t('@entity_type revision', ['@entity_type' => $this->entityType->getLabel()]);
$data[$revision_data_table]['table']['entity revision'] = TRUE;
$data[$revision_table]['table']['join'][$revision_data_table] = [
'left_field' => $revision_field,
'field' => $revision_field,
'type' => 'INNER',
];
}
// Add a filter for showing only the latest revisions of an entity.
$data[$revision_table]['latest_revision'] = [
'title' => $this->t('Is Latest Revision'),
'help' => $this->t('Restrict the view to only revisions that are the latest revision of their entity.'),
'filter' => ['id' => 'latest_revision'],
];
}
Comment #9
joachim commentedI don't understand what you mean at all, sorry.
The variable is initialised to an empty string:
so
if ($revision_table) {}is enough to check whether it is either an empty string (and so evaluates to FALSE) or a non-empty string (and so evaluates to TRUE).Comment #10
bn_code commentedComment #11
bn_code commentedAgree with #9
Comment #13
mitrpaka commentedRe-rolled latest patch (which seems to be same as original by @longwave)
Comment #15
longwaveComment #16
alexpottIn order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:
Comment #17
joachim commented@alexpott we discussed writing tests earlier in the issue, but couldn't figure out how to test this. Any ideas?
Comment #19
vacho commentedHi. Some ideas about how to test this.
The logic
This issue is to solve this logic:
If the entity is revisionable => they can have revision table operations.
Currently,
If the entity is not revisionable => they have a revision table anyway.
Test logic
- Step 1: Set A view that show an entity that is not revisionable such as User.
- Step 2: Add to view operations column.
- Step 3: Valid if generate operations anyway or not.
Tecnical options
- Unit: Is for an environment
- Kernel: Is for test full Drupal environment.
- Browser: Is for test full-environment and internal simulate a web browser result. (It is the test that we can implement)
- Javascript: Javascript execution.
Comment #22
vsujeetkumar commented@alexpott I think this one is duplicate with #2973137: and already fixed, Please review.
Comment #23
vsujeetkumar commentedComment #28
smustgrave commentedClosing as a duplicate of https://www.drupal.org/project/drupal/issues/2973137. after confirming the fix for this ticket was included in that ticket.