Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions debug_contactpersoon_data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Debug script to check what's in the database for the contactpersoon
*/

echo "=== DEBUG CONTACTPERSOON DATABASE DATA ===\n";

// The contactpersoon ID from the API response
$contactpersoonId = 'e8ba22ba-35ab-4b59-a097-91df6fa2cd3d';

echo "Contactpersoon ID: $contactpersoonId\n\n";

echo "1. Checking what's in the database for this contactpersoon...\n";
echo " - Query: SELECT * FROM oc_openregister_objects WHERE id = '$contactpersoonId'\n";
echo " - Expected fields: id, name, object (JSON), created, updated, etc.\n\n";

echo "2. The 'object' field should contain JSON with:\n";
echo " - username: the Nextcloud username\n";
echo " - email: the email address\n";
echo " - other contactpersoon data\n\n";

echo "3. If username is empty or null, the service returns:\n";
echo " - hasUser: false\n";
echo " - username: ''\n";
echo " - disabled: false (default for non-users)\n\n";

echo "4. POSSIBLE ISSUES:\n";
echo " a) Username field is empty in database but user exists in Nextcloud\n";
echo " b) Username field has different format than expected\n";
echo " c) User was disabled but username was removed from contactpersoon data\n";
echo " d) There's a mismatch between what we think the username is vs what's stored\n\n";

echo "5. TO FIX THIS:\n";
echo " a) Check the actual database record\n";
echo " b) Verify what username should be associated with this contactpersoon\n";
echo " c) Update the contactpersoon data with the correct username\n";
echo " d) Or fix the logic to handle this edge case\n\n";

echo "=== END DEBUG ===\n";
?>
44 changes: 44 additions & 0 deletions debug_contactpersoon_database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Debug script to check what's actually in the database for the contactpersoon
*/

echo "=== DEBUG CONTACTPERSOON DATABASE ===\n";

// The contactpersoon ID from the API response
$contactpersoonId = 'e8ba22ba-35ab-4b59-a097-91df6fa2cd3d';

echo "Contactpersoon ID: $contactpersoonId\n\n";

echo "1. We need to check what's actually in the database:\n";
echo " - Table: oc_openregister_objects\n";
echo " - Field: object (JSON)\n";
echo " - Should contain: username, email, etc.\n\n";

echo "2. Current API response shows:\n";
echo " - hasUser: false\n";
echo " - username: ''\n";
echo " - disabled: false\n\n";

echo "3. But user says this contactpersoon HAS a user!\n\n";

echo "4. POSSIBLE CAUSES:\n";
echo " a) Username field is empty/null in database but user exists in Nextcloud\n";
echo " b) Username field has different name (not 'username')\n";
echo " c) Data structure is different than expected\n";
echo " d) Contactpersoon data was corrupted or not properly saved\n\n";

echo "5. TO DEBUG:\n";
echo " a) Check the actual database record\n";
echo " b) Check if username is stored under a different field name\n";
echo " c) Check if the user exists in Nextcloud but isn't linked properly\n";
echo " d) Check if there's a mismatch between what we expect vs reality\n\n";

echo "6. NEXT STEPS:\n";
echo " - Run a direct database query to see the raw data\n";
echo " - Check if username is stored differently\n";
echo " - Verify the user actually exists in Nextcloud\n";
echo " - Fix the data or the logic\n\n";

echo "=== END DEBUG ===\n";
?>
71 changes: 71 additions & 0 deletions debug_database_direct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/**
* Debug script to check database directly
* This script runs inside the Nextcloud container and checks the database directly
*/

require_once __DIR__ . '/../lib/base.php';

echo "=== Direct Database Debug ===\n\n";

// The contactpersoon ID from the user's example
$contactpersoonId = 'e8ba22ba-35ab-4b59-a097-91df6fa2cd3d';

echo "Looking for contactpersoon ID: " . $contactpersoonId . "\n\n";

try {
// Get database connection
$connection = \OC::$server->getDatabaseConnection();

// Query the openregister_objects table
$query = "SELECT * FROM oc_openregister_objects WHERE id = ?";
$stmt = $connection->prepare($query);
$result = $stmt->execute([$contactpersoonId]);
$row = $stmt->fetch();

if ($row) {
echo "Found contactpersoon in database:\n";
echo "ID: " . $row['id'] . "\n";
echo "Name: " . $row['name'] . "\n";
echo "Object JSON: " . $row['object'] . "\n";
echo "Created: " . $row['created'] . "\n";
echo "Updated: " . $row['updated'] . "\n\n";

// Decode the JSON object
$objectData = json_decode($row['object'], true);
if ($objectData) {
echo "Decoded object data:\n";
echo json_encode($objectData, JSON_PRETTY_PRINT) . "\n\n";

// Check for username
if (isset($objectData['username'])) {
echo "Username found: " . $objectData['username'] . "\n";

// Check if user exists in Nextcloud
$userManager = \OC::$server->getUserManager();
$user = $userManager->get($objectData['username']);

if ($user) {
echo "User exists in Nextcloud: " . $user->getUID() . "\n";
echo "User enabled: " . ($user->isEnabled() ? 'Yes' : 'No') . "\n";
echo "User disabled: " . ($user->isEnabled() ? 'No' : 'Yes') . "\n";
} else {
echo "User NOT found in Nextcloud\n";
}
} else {
echo "No username field in object data\n";
}
} else {
echo "Failed to decode object JSON\n";
}
} else {
echo "Contactpersoon NOT found in database\n";
}

} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
echo "Trace: " . $e->getTraceAsString() . "\n";
}

echo "\n=== Debug Complete ===\n";
46 changes: 46 additions & 0 deletions debug_user_status.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Debug script to check user status in Nextcloud
*/

// Get the contactpersoon ID from the API response
$contactpersoonId = 'e8ba22ba-35ab-4b59-a097-91df6fa2cd3d';

echo "=== DEBUG USER STATUS ===\n";
echo "Contactpersoon ID: $contactpersoonId\n\n";

// Simulate the ContactpersoonService logic
try {
// This would be in the Docker container context
echo "1. Checking if contactpersoon exists in database...\n";

// Simulate database query
echo " - Would query openregister_objects table\n";
echo " - Looking for contactpersoon with ID: $contactpersoonId\n\n";

echo "2. Checking if contactpersoon has username...\n";
echo " - Would check if data.username exists\n";
echo " - Current API shows: hasUser: false, username: ''\n\n";

echo "3. If no username, userInfo should be:\n";
echo " - hasUser: false\n";
echo " - username: ''\n";
echo " - groups: []\n";
echo " - disabled: false (default for non-users)\n\n";

echo "4. ISSUE IDENTIFIED:\n";
echo " - API returns disabled: false because hasUser: false\n";
echo " - But user might actually be disabled in Nextcloud\n";
echo " - We need to check if username exists but user is disabled\n\n";

echo "5. POSSIBLE SOLUTIONS:\n";
echo " a) Check if contactpersoon.data.username exists but user is disabled\n";
echo " b) Verify the user was actually disabled via our disable endpoint\n";
echo " c) Check if there's a mismatch between data.username and actual Nextcloud user\n\n";

} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}

echo "=== END DEBUG ===\n";
?>
83 changes: 0 additions & 83 deletions find_test_object.php

This file was deleted.

Loading