{"record":{"id":"537221019cd80611","repo":"Dolibarr/dolibarr","slug":"errorlinknotfoundwithsharedlink","errorCode":null,"errorMessage":"ErrorLinkNotFoundWithSharedLink","messagePattern":"ErrorLinkNotFoundWithSharedLink","errorType":"http","errorClass":null,"httpStatus":403,"severity":"error","filePath":"htdocs/document.php","lineNumber":204,"sourceCode":"/*\n * View\n */\n\n// If we have a hash public (hashp), we guess the original_file.\n$ecmfile = '';\nif (!empty($hashp) && $hashp != 'shared') {\n\tif (GETPOST('type', 'alpha') == 'link') {\n\t\trequire_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';\n\t\t$link = new Link($db);\n\t\t$result = $link->fetch(0, $hashp);\n\t\tif ($result > 0 && !empty($link->url)) {\n\t\t\tif (preg_match('/^(http|dav)/', $link->url)) {\n\t\t\t\theader('Location: '.$link->url);\n\t\t\t\texit;\n\t\t\t}\n\t\t} else {\n\t\t\t$langs->load(\"errors\");\n\t\t\thttponly_accessforbidden($langs->trans(\"ErrorLinkNotFoundWithSharedLink\"), 403, 1);\n\t\t}\n\t} else {\n\t\tinclude_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php';\n\t\t$ecmfile = new EcmFiles($db);\n\t\t$result = $ecmfile->fetch(0, '', '', '', $hashp);\n\t\tif ($result > 0) {\n\t\t\t$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory\n\t\t\t// filepath can be 'users/X' or 'X/propale/PR11111'\n\t\t\tif (is_numeric($tmp[0])) { // If first tmp is numeric, it is subdir of company for multicompany, we take next part.\n\t\t\t\t$tmp = explode('/', $tmp[1], 2);\n\t\t\t}\n\t\t\t$moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path\n\n\t\t\tif ($modulepart) {    // Not required, so often not defined, for link using public hashp parameter.\n\t\t\t\tif ($moduleparttocheck == $modulepart) {\n\t\t\t\t\t// We remove first level of directory\n\t\t\t\t\t$original_file = (($tmp[1] ? $tmp[1] . '/' : '') . $ecmfile->filename); // this is relative to module dir\n\t\t\t\t\t//var_dump($original_file); exit;","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/document.php#L186-L222","documentation":"When a shared link (hashp) points to an ECM 'links' record (an external URL attached to an object) that no longer exists or is invalid, document.php cannot resolve it, loads the 'errors' language file, and calls httponly_accessforbidden() with the translated ErrorLinkNotFoundWithSharedLink (HTTP 403). The shared hash matched a link-type record but its URL could not be used or the record is gone.","triggerScenarios":"document.php?hashp=<hash> where fetch of the EcmFiles/link record by hashp returns no valid entry (or the entry is a link whose URL is empty/deleted) — the else branch fires the 403.","commonSituations":"Recipients clicking an old share link after the linked record/URL was deleted; truncated or mistyped hashp in the shared URL; share revoked but the link still circulating.","solutions":["Re-generate the share link from the document/ECM entry (share tab) and resend it","Verify the underlying link record still exists in llx_ecm_files / links table","Check the hashp parameter was not truncated by email clients or URL shorteners","If the share was intentionally revoked, inform users the link is no longer valid"],"exampleFix":"// before (stale link)\ndocument.php?hashp=abc123old\n// after (regenerated)\ndocument.php?hashp=<new share hash from ECM share tab>","handlingStrategy":"fallback","validationCode":"// check link record exists before sharing\n$ecm = new EcmFiles($db);\nif ($ecm->fetch(0,'','','',$hashp) <= 0) { warn('shared link target missing'); }","typeGuard":null,"tryCatchPattern":"try { $res = $ecmfile->fetch(0,'','','',$hashp); if ($res <= 0) { throw new Exception('shared link not found'); } } catch (Exception $e) { show_friendly_link_expired_page(); }","preventionTips":["Regenerate share links after deleting/moving linked records","Warn users when revoking shares that old links will 403","Avoid URL shorteners that may mangle hashp","Log hashp lookups that fail to detect stale link traffic"],"tags":["http-403","share-link","not-found"],"backgroundTag":"record-not-found","analyzedSha":"598aa4bdada683d17ca04b1842548821ff0eb6c6","analyzedAt":"2026-09-14T11:12:15.309Z","contentChangedAt":"2026-09-14T11:12:15.309Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}