This is a specific issue for multilingual websites. If you have just upgraded and do not have a multilingual site please see #1442080: "permission restrictions" in reports -> run re-analyze only task once after upgrade
In a multilingual site using i18n module the db_rewrite_sql() function causes language negotiation to be added to the query. This means a large percentage of broken links cannot be fixed (or are difficult to fix) because they are obscured by the "Permission restrictions deny you access to this broken link" text which makes it impossible to see where the link is, why permission is denied, or which language it is in. Since you do not need to speak the language to fix a URL I don't think this is desired functionality. linkchecker v2.4 showed all broken links in all languages so for me this is a feature regression.
I tracked this down to linkchecker.module -> _linkchecker_link_node_ids() -> two db_rewrite_sql() calls.
My temp fix is to trick i18n into thinking the sql already has language negotiation by adding "i18n" text to the sql that does not interfere with the query.
function _linkchecker_link_node_ids($link, $node_author_account = NULL) {
static $fields_with_node_links = array();
// If the user cannot access content, there is no need to check further.
if (!user_access('access content')) {
return array();
}
// Trick i18n module so that it does not add language negotiation sql
$dummy = '';
if (module_exists('i18n')) {
$dummy = 'n.nid <> "i18n" AND ';
}
// Get a list of nodes containing the link, using db_rewrite_sql() to allow
// node access modules to exclude nodes that the current user does not have
// access to view.
if (!empty($node_author_account)) {
$nodes = db_query(db_rewrite_sql('SELECT n.nid
FROM {node} n
INNER JOIN {linkchecker_nodes} ln ON ln.nid = n.nid
INNER JOIN {node_revisions} r ON r.vid = n.vid
WHERE ' . $dummy . 'ln.lid = %d AND (n.uid = %d OR r.uid = %d)'), $link->lid, $node_author_account->uid, $node_author_account->uid);
}
else {
$nodes = db_query(db_rewrite_sql('SELECT n.nid
FROM {node} n
INNER JOIN {linkchecker_nodes} ln ON ln.nid = n.nid
WHERE ' . $dummy . 'ln.lid = %d'), $link->lid);
}
// ...
Alternatively passing array('view' => NULL) as the $arg for db_rewrite_sql() will also stop i18n but I don't know the full ramification of using that.
$nodes = db_query(db_rewrite_sql('SELECT n.nid
FROM {node} n
INNER JOIN {linkchecker_nodes} ln ON ln.nid = n.nid
WHERE ' . $dummy . 'ln.lid = %d', 'n', 'nid', array('view' => NULL)), $link->lid);
If one of these is acceptable I would gladly roll a patch. In my case this is a critical issue since the site has 5 languages. The rest of the "Permission restrictions" problems seem to be caused by unpublished content which probably should not be link checked?
Comment | File | Size | Author |
---|---|---|---|
#23 | 1488572-23-linkchecker-i18n-d6.patch | 928 bytes | caktux |
#17 | 1488572_linkchecker_i18n_D6b.patch | 1.08 KB | hass |
#14 | 1488572_linkchecker_i18n_D6.patch | 1.14 KB | hass |
#10 | 1488572_linkchecker_i18n_D6.patch | 1.14 KB | hass |
Comments
Comment #1
hass CreditAttribution: hass commentedPlease make sure you run a Re-analyze after upgrading to 2.5. Does this solve the problem?
Comment #2
hass CreditAttribution: hass commentedIs there no better way from stopping i18n modue from extending the query?
Comment #3
tinker CreditAttribution: tinker commentedRe-analyze is not the solution. Did that multiple times on two sites to no avail. I debugged the problem and its the sql. i18n injects language = english criteria where as the nodes that have the links are in other languages. Language is not a valid criteria here. There are a number of checks in i18n_db_rewrite_sql to stop language injection but I think I chose the most suitable. The checks are:
My first method will not interfer with queries because NID will never equal "i18n" so I think it is the safest. The second method is cleaner PHP and SQL as there is no SQL addition but I could not find usage of $args array ('view' =>) in any modules outside of i18n so I don't know how it could interfere. Everything else involves larger changes to SQL.
I have only tested on MySQL.
Comment #4
hass CreditAttribution: hass commentedYou should never compare a string value with an integer. This adds serious database load as it tries to convert the i18n to integer what could theroretically end with 18... And match on node 18, but i'm not sure about sql... This will at least happen in php. The arg views solution sounds ok, if this is clean - or we add "i18n == i18n" to be clean with datatypes. Like views do it for debugging...
CNW as there is no clean patch.
Comment #5
hass CreditAttribution: hass commentedAsked in i18n for feedback #1489104: I18n db rewriting breaks linkchecker
Comment #6
hass CreditAttribution: hass commentedComment #7
hass CreditAttribution: hass commentedComment #8
susanmccormick CreditAttribution: susanmccormick commentedI am getting the same "permission restrictions deny" error and I don't have i18 installed. Using Linkchechecker 6.x-2.5.
Comment #9
hass CreditAttribution: hass commented@tahoewebnerd: See #1442080: "permission restrictions" in reports -> run re-analyze only task once after upgrade
Comment #10
hass CreditAttribution: hass commentedHere is a proper patch for D6. I'm myself not really sure if we need to set it to 'off' or one of the many other possible values. Please test this patch.
off = No language conditions inserted.
simple = Only current language and no language.
mixed = Only current and default languages.
strict = Only current language.
default = Only default language.
user = User defined, in the module's settings page.
params = Gets the stored params.
reset = Returns to previous.
custom = add custom where clause, like "%alias.language = 'en'".
What type of language detection are you using? Path based or domain based or any other? Aside, what about comments, blocks?
Comment #12
hass CreditAttribution: hass commented#10: 1488572_linkchecker_i18n_D6.patch queued for re-testing.
Comment #14
hass CreditAttribution: hass commentedPatch has no unix lf's. suxxx testbot.
Comment #15
hass CreditAttribution: hass commentedComment #17
hass CreditAttribution: hass commentedsuxxx, same patch again
Comment #18
hass CreditAttribution: hass commentedComment #19
hass CreditAttribution: hass commentedHelpful info for D7 port http://drupal.org/node/237696#comment-5861232
Comment #20
hass CreditAttribution: hass commented@tinker: have you been able to test this patch?
Comment #21
hass CreditAttribution: hass commentedCommitted http://drupalcode.org/project/linkchecker.git/commit/b2cb5ba
Comment #23
caktux CreditAttribution: caktux commentedtinker's solution was right and the patch in #17 didn't work for me but might also be necessary, didn't check without it since it's already committed. I went with the
array('view' => NULL)
trick since it felt cleaner, although I'm also unsure of what it's actually doing. We're only changing the query in our module so it shouldn't affect anything else.Comment #24
caktux CreditAttribution: caktux commentedJust realized I applied his solution to
_linkchecker_link_comment_ids
instead of_linkchecker_link_node_ids
, but that was actually the problem. Sweet.Comment #24.0
caktux CreditAttribution: caktux commentedAdd link to other issue that will help most people.
Comment #25
hass CreditAttribution: hass commentedPlease check out if #2119159: Incorrect filter configuration may cause "Permission restrictions deny you access" may also one of your issues.
Comment #26
nerdcore CreditAttribution: nerdcore commentedHaving similar issues using i18n + linkchecker-7.x-1.2.
Note that D7 has neither "db_rewrite_sql" nor "i18n_selection_mode" functions in its API.
Comment #27
hass CreditAttribution: hass commentedComment #28
rsvelko CreditAttribution: rsvelko commentedfor the same issue but in D7 / 7.x - > #2195429: Permission restrictions deny for links to deleted nodes
EDIT: the one above is delete-node related - the issue here in 6 and D7 is i18n-related.
I found that the language_switcher module is not playing nice and alters the sql query in a bad manner for our link checker reports. See fix there - #2450175: Permission restrictions errors in linkchecker module - bec. of the language_switcher module
Comment #29
VladimirAusClosing version 6 task. 🚪
Please reopen and update version if still applicable.
Comment #30
VladimirAus