dolibarr.filearchive/debug_hooks.php
data cbf04e6cc9 FileArchiv: Tile/Gallery view with toggle buttons
- Added formObjectOptions hook for document pages
- CSS/JS injected via DOMContentLoaded for proper timing
- Toggle between list and tile view (localStorage persisted)
- Lightbox for image gallery with keyboard navigation
- Fixed hook contexts (productdocuments, invoicedocuments, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-19 16:59:19 +01:00

124 lines
3.9 KiB
PHP

<?php
/**
* Debug script to check hook loading
*/
// Bypass login requirements
if (!defined('NOLOGIN')) {
define('NOLOGIN', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
// Load Dolibarr environment
$res = 0;
if (file_exists("../../main.inc.php")) {
$res = @include "../../main.inc.php";
}
if (!$res && file_exists("../../../main.inc.php")) {
$res = @include "../../../main.inc.php";
}
if (!$res) {
die("Include of main fails");
}
header('Content-Type: text/plain; charset=UTF-8');
echo "=== FileArchiv Hook Debug ===\n\n";
// Check if module is enabled
echo "1. Module enabled: " . (isModEnabled('filearchiv') ? "YES" : "NO") . "\n\n";
// Check modules_parts hooks
echo "2. Modules parts hooks for filearchiv:\n";
if (isset($conf->modules_parts['hooks'])) {
foreach ($conf->modules_parts['hooks'] as $module => $hooks) {
if (strpos($module, 'filearchiv') !== false) {
echo " Module: $module\n";
echo " Hooks: " . json_encode($hooks) . "\n";
}
}
if (!isset($conf->modules_parts['hooks']['filearchiv'])) {
echo " WARNING: filearchiv not found in modules_parts hooks!\n";
echo " Available modules: " . implode(', ', array_keys($conf->modules_parts['hooks'])) . "\n";
}
} else {
echo " No hooks defined at all!\n";
}
// Check if class file exists
echo "\n3. Class file check:\n";
$path = '/filearchiv/class/actions_filearchiv.class.php';
$fullpath = dol_buildpath($path);
echo " dol_buildpath('$path') = $fullpath\n";
echo " File exists: " . (file_exists($fullpath) ? "YES" : "NO") . "\n";
// Try custom path
$customPath = DOL_DOCUMENT_ROOT . '/custom/filearchiv/class/actions_filearchiv.class.php';
echo " Custom path: $customPath\n";
echo " Custom exists: " . (file_exists($customPath) ? "YES" : "NO") . "\n";
// Check DOL_DOCUMENT_ROOT
echo "\n4. DOL_DOCUMENT_ROOT: " . DOL_DOCUMENT_ROOT . "\n";
// Test initHooks
echo "\n5. Testing initHooks('formfile'):\n";
global $hookmanager;
$hookmanager->initHooks(array('formfile'));
echo " Context array: " . implode(', ', $hookmanager->contextarray) . "\n";
echo " Hooks for formfile: " . (isset($hookmanager->hooks['formfile']) ? count($hookmanager->hooks['formfile']) : 0) . "\n";
if (isset($hookmanager->hooks['formfile'])) {
foreach ($hookmanager->hooks['formfile'] as $module => $instance) {
echo " - $module: " . get_class($instance) . "\n";
}
}
// Check if our class can be loaded manually
echo "\n6. Manual class loading test:\n";
if (file_exists($customPath)) {
include_once $customPath;
if (class_exists('ActionsFilearchiv')) {
echo " Class ActionsFilearchiv: EXISTS\n";
$test = new ActionsFilearchiv($db);
echo " Instance created: " . get_class($test) . "\n";
} else {
echo " Class ActionsFilearchiv: NOT FOUND after include\n";
}
} else {
echo " Cannot test - file not found\n";
}
// Test writing to /tmp
echo "\n7. Testing file write to /tmp:\n";
$testFile = '/tmp/filearchiv_test_' . time() . '.log';
$result = @file_put_contents($testFile, "Test write at " . date('Y-m-d H:i:s') . "\n");
echo " Write result: " . ($result !== false ? "SUCCESS ($result bytes)" : "FAILED") . "\n";
if (file_exists($testFile)) {
echo " File exists: YES\n";
echo " Contents: " . file_get_contents($testFile) . "\n";
unlink($testFile);
}
// Check debug log
echo "\n8. Checking debug log:\n";
$debugLog = '/tmp/filearchiv_debug.log';
if (file_exists($debugLog)) {
echo " Debug log exists: YES\n";
echo " Size: " . filesize($debugLog) . " bytes\n";
echo " Last 5 lines:\n";
$lines = file($debugLog);
foreach (array_slice($lines, -5) as $line) {
echo " " . $line;
}
} else {
echo " Debug log exists: NO\n";
}
echo "\n=== Done ===\n";