debug_main_import.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. // Debug script to test main wordpress_import.php hanging issue
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5. ini_set('max_execution_time', 30);
  6. ini_set('memory_limit', '256M');
  7. echo "<h1>Debug Main WordPress Import</h1>";
  8. // Test 1: Basic PHP and includes
  9. echo "<p>Step 1: Testing includes...</p>";
  10. try {
  11. require_once '../includes/config.php';
  12. echo "<p>✓ Config included</p>";
  13. } catch (Exception $e) {
  14. echo "<p>✗ Config error: " . $e->getMessage() . "</p>";
  15. exit;
  16. }
  17. try {
  18. require_once '../includes/database.php';
  19. echo "<p>✓ Database included</p>";
  20. } catch (Exception $e) {
  21. echo "<p>✗ Database error: " . $e->getMessage() . "</p>";
  22. exit;
  23. }
  24. try {
  25. require_once '../includes/auth.php';
  26. echo "<p>✓ Auth included</p>";
  27. } catch (Exception $e) {
  28. echo "<p>✗ Auth error: " . $e->getMessage() . "</p>";
  29. exit;
  30. }
  31. try {
  32. require_once '../includes/translation.php';
  33. echo "<p>✓ Translation included</p>";
  34. } catch (Exception $e) {
  35. echo "<p>✗ Translation error: " . $e->getMessage() . "</p>";
  36. exit;
  37. }
  38. try {
  39. require_once '../includes/wordpress_import.php';
  40. echo "<p>✓ WordPressImport included</p>";
  41. } catch (Exception $e) {
  42. echo "<p>✗ WordPressImport error: " . $e->getMessage() . "</p>";
  43. exit;
  44. }
  45. // Test 2: Auth system
  46. echo "<p>Step 2: Testing auth system...</p>";
  47. try {
  48. $auth = new Auth();
  49. echo "<p>✓ Auth instance created</p>";
  50. if ($auth->isLoggedIn()) {
  51. echo "<p>✓ User is logged in</p>";
  52. $user = $auth->getUser();
  53. echo "<p>User: " . htmlspecialchars($user['username']) . " (Role: " . $user['role'] . ")</p>";
  54. } else {
  55. echo "<p>⚠ User not logged in</p>";
  56. }
  57. } catch (Exception $e) {
  58. echo "<p>✗ Auth error: " . $e->getMessage() . "</p>";
  59. exit;
  60. }
  61. // Test 3: Database connection
  62. echo "<p>Step 3: Testing database connection...</p>";
  63. try {
  64. $db = Database::getInstance();
  65. echo "<p>✓ Database instance created</p>";
  66. $result = $db->query("SELECT 1 as test");
  67. echo "<p>✓ Database query successful</p>";
  68. } catch (Exception $e) {
  69. echo "<p>✗ Database error: " . $e->getMessage() . "</p>";
  70. exit;
  71. }
  72. // Test 4: WordPressImport creation (same as main interface)
  73. echo "<p>Step 4: Testing WordPressImport creation...</p>";
  74. try {
  75. $wpConfig = [
  76. 'host' => '10.15.10.8',
  77. 'database' => 'valtsu_valtsu',
  78. 'username' => 'root',
  79. 'password' => 'jotainaivanmuuta'
  80. ];
  81. echo "<p>About to create WordPressImport...</p>";
  82. $importer = new WordPressImport($wpConfig);
  83. echo "<p>✓ WordPressImport created successfully</p>";
  84. } catch (Exception $e) {
  85. echo "<p>✗ WordPressImport creation error: " . $e->getMessage() . "</p>";
  86. echo "<p>File: " . $e->getFile() . "</p>";
  87. echo "<p>Line: " . $e->getLine() . "</p>";
  88. exit;
  89. }
  90. // Test 5: Test connection (same as main interface)
  91. echo "<p>Step 5: Testing WordPress connection...</p>";
  92. try {
  93. echo "<p>About to test connection...</p>";
  94. $connectionTest = $importer->testConnection();
  95. echo "<p>✓ Connection test completed</p>";
  96. echo "<pre>" . print_r($connectionTest, true) . "</pre>";
  97. } catch (Exception $e) {
  98. echo "<p>✗ Connection test error: " . $e->getMessage() . "</p>";
  99. echo "<p>File: " . $e->getFile() . "</p>";
  100. echo "<p>Line: " . $e->getLine() . "</p>";
  101. exit;
  102. }
  103. echo "<h2>All tests completed successfully!</h2>";
  104. ?>