fix(user): match profile validation hook argument type

Accept the stdClass user data passed by WordPress and derive the user ID only from the hook object. Cover callback registration, nonce and permission guards, and mismatched posted IDs; refresh the identity review dialog contract.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Fable 5 committed 2026-10-30 20:38:00 +08:00
1 parent bc26d62602
commit f9b7997ec2
4 files changed
+74 -11

No files matched your search

@@ -14,6 +14,17 @@ test('phone persistence, uniqueness, and native profile saves pass the PHP harne
assert.match(output, /User profile phone harness passed/);
});
test('profile validation follows the WordPress stdClass hook contract without a POST user-ID fallback', () => {
const admin = read('src/User/ProfileAdmin.php');
const validation = admin.slice(admin.indexOf('public static function validate('), admin.indexOf('public static function save('));
assert.match(admin, /add_filter\('user_profile_update_errors', \[self::class, 'validate'\], 10, 3\)/);
assert.match(validation, /validate\(\\WP_Error \$errors, bool \$update, \\stdClass \$user\): void/);
assert.match(validation, /\$user_id = \(int\) \(\$user->ID \?\? 0\)/);
assert.doesNotMatch(validation, /instanceof \\WP_User|\$_POST\['user_id'\]/);
assert.match(admin, /render\(\\WP_User \$user\): void/);
});
test('phone binding, registration, and sign-in share phone_number as the only phone value key', () => {
const service = read('src/Auth/Service.php');
const registrationAndBinding = read('src/Auth/ServicePart1b.php');