You can use a hook to alter the view. Or you can add a custom filter plugin?
I think this would be an important functionality to figure out. As it is right now, the Broken Links report is so inconvenient compared to before, that as an admin I consider it nearly worthless.
Using the "failed links" filter shows huge amounts of valid links, such as 307 redirects from URL redirects on nodes. The report also shows links even if "test link" is set to false.
- 🇳🇿New Zealand Gold 20 minutes in the future
Is there any reason to just not record the results if the response code is in the list?
It's a "Broken Links" report. It doesn't make sense to show all links. I don't know how to fix it, though.
- 🇳🇿New Zealand Gold 20 minutes in the future
I've never written a Views filter but am currently giving it a go.
The intention is to just add the filter to the View and have it add
and code not in ("this list")
to the query. The filter config form will just have a link to the module config form. Then add this filter and export the view again. - 🇳🇿New Zealand Gold 20 minutes in the future
I've got a branch that's not ready for an MR yet.
https://git.drupalcode.org/issue/linkchecker-3065056/-/commit/237e7dd35a...
This is on 2.0.x and looks to be working, right up until it doesn't.
The query() method is being called. I can see my WHERE clause being added to the query object. If I use the exposed filters to add a filter on only one Status Code I can see that being added as well and it is going into the same place in the object my stuff is going. The only difference is that my filter is not being used.
I've tried a couple of approaches.
I used
$this->query->addWhere($this->options['group'], "{$this->tableAlias}.{$this->realField}", $ignored_response_codes, 'NOT IN')
and even walked over$ignored_response_codes
adding each as a "!=". I also triedaddWhereExpression($this->options['group'], "{$this->tableAlias}.{$this->realField} NOT IN (" + implode(',', $ignored_response_codes)
.While all are going into the query object, none of these worked.
All we appear to need to do is get this query() to work and we've got it.
If people want to patch their local version you can add .patch to the commit link above. Once patched you can edit your local Broken Links Report to add the filter.
Input requested. I'm hoping that there's something about Views Filters that I'm just missing, but the things that I've been referencing all suggest this should be working.
- Merge request !60Issue #3271896 by eiriksm, acbramley, VladimirAus, Johnny Santos,... → (Open) created by Gold
- Open on Drupal.org →Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7last update
11 months ago Not currently mergeable. 13:17 9:23 Running12:19 8:42 Running- Status changed to Needs review
11 months ago 2:01am 19 January 2024 - 🇳🇿New Zealand Gold 20 minutes in the future
I've got a working MR. At least it's working locally for me.
- last update
11 months ago Build Successful - Status changed to Needs work
11 months ago 6:02pm 19 January 2024 It does filter. However, the filter in the dropdown for "Failed" is no longer needed. And the filter for "Success (2xx)" should be removed, as it will never return results.
I also get an error. Edit the linkchecker view with the patch applied.
Warning: Undefined array key "ignored_response_codes" in Drupal\linkchecker\Plugin\views\filter\IgnoredResponseCodes->adminSummary() (line 44 of modules/contrib/linkchecker/src/Plugin/views/filter/IgnoredResponseCodes.php).
$this->options['ignored_response_codes']
doesn't exist and is never set. Also, the return value isn't supposed to be an array. Look at examples from Core or the Views module. The solution is this:public function adminSummary() { $ignored_response_codes = $this->getIgnoredResponseCodes(); if (!empty($ignored_response_codes)) { return $this->t('Ignored response codes: @codes', ['@codes' => implode(', ', $ignored_response_codes)]); } return ''; }
- last update
11 months ago 85 pass, 2 fail - last update
11 months ago Composer require failure - last update
11 months ago 85 pass, 2 fail - Status changed to Needs review
11 months ago 4:21pm 22 January 2024 Question, should the report also exclude links that have status checking disabled?
- 🇳🇿New Zealand Gold 20 minutes in the future
#15 It does filter. However, the filter in the dropdown for "Failed" is no longer needed. And the filter for "Success (2xx)" should be removed, as it will never return results.
I don't think this is the case. If the ignored response codes was intentionally set to be empty all response codes would be returned and the existing selectors would be useful. I would revert commit bfc4fdad. If we forced the contents of this to include "success" values this would be a reasonable edit.
#16 re:
adminSummary()
Good catch. Cheers. :)
#19 Question, should the report also exclude links that have status checking disabled?
I'm not sure where/what this is. Either way though, that's out of scope for this issue and should be added as a new issue so we can get this one over the line.
- last update
11 months ago 86 pass Okay, reverted. Though it still doesn't make 100% sense, since the report is called "Broken Links".
- 🇳🇿New Zealand Gold 20 minutes in the future
Okay, reverted. Though it still doesn't make 100% sense, since the report is called "Broken Links".
Absolutely agree with this. It's not a task that this ticket is for though. :) And you're right, with it being a standard view the end user can modify it to their specific needs.
I'm feeling like this is RTBC but as one of the people that did the code part of this I don't think it's my place to do that.