XF 2.2 Saving User Errors

brian22

Member
Whenever I try to save a user's profile info, even my own, I get this error message. Note: It only happens for a few users, not all. Any idea what the issue is? Thanks


ErrorException: [E_WARNING] Undefined array key "regex" in src/XF/CustomField/Definition.php at line 428
  1. XF::handlePhpError() in src/XF/CustomField/Definition.php at line 428
  2. XF\CustomField\Definition->_validateMatchTypeRegex() in src/XF/CustomField/Definition.php at line 267
  3. XF\CustomField\Definition->_validateFieldTypeTextarea() in src/XF/CustomField/Definition.php at line 243
  4. XF\CustomField\Definition->_validateFieldTypeTextbox() in src/XF/CustomField/Definition.php at line 230
  5. XF\CustomField\Definition->isValid() in src/XF/CustomField/Set.php at line 203
  6. XF\CustomField\Set->set() in src/XF/CustomField/Set.php at line 108
  7. XF\CustomField\Set->bulkSet() in src/XF/Admin/Controller/User.php at line 378
  8. XF\Admin\Controller\User->XF\Admin\Controller\{closure}() in src/XF/Mvc/FormAction.php at line 166
  9. XF\Mvc\FormAction->run() in src/XF/Admin/Controller/User.php at line 563
  10. XF\Admin\Controller\User->actionSave() in src/XF/Mvc/Dispatcher.php at line 352
  11. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 258
  12. XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 115
  13. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 57
  14. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2487
  15. XF\App->run() in src/XF.php at line 524
  16. XF::runApp() in admin.php at line 13
 
Gemini suggests..

The error message you're encountering, "Undefined array key "regex"", indicates that the code is trying to access a key named "regex" from an array, but that key doesn't exist. This is happening specifically in the CustomFieldDefinition class at line 428 of the src/XF/CustomField/Definition.php file.
Here's a breakdown of what's happening:
  1. The CustomFieldDefinition class likely represents a definition for a custom field in a user profile.
  2. The code expects a validations array to be present within the definition, and for the "regex" key to be set within that array if the field type is "textarea".
  3. However, in some cases, the validations array might not have the "regex" key set, causing the error.
This error only occurs for a few users because the validation logic is likely only triggered under specific conditions, possibly when a specific custom field type is being saved.
Here are some possible solutions you can try:
  1. Fix the code: If you have access to the codebase, you can fix the issue by ensuring that the validations array always has the "regex" key set, even if it's an empty string. This would prevent the error from occurring.
  2. Update the plugin or software: If this is a known issue with a plugin or software you're using, there might already be an update available that fixes the problem. Check for updates and install them if available.
  3. Inspect the data: Investigate why the "regex" key might be missing for some users. There could be a data integrity issue or a bug in the way the data is being processed.
 
Gemini suggests..

Well after some investigating with another person, this seems to be well beyond the scope of a regular “end user” I think…..

What we have been able to determine thus far……with everything up to date.

  1. I do not believe we have a database issue. I looked for crashed tables and such, and there does not appear to be any. If its database related then it’s an entry within some table or something.
  2. I also verified that the server itself doesn’t seem to be an issue – plenty of disk space is available (199G on the /home partition).
  3. So I went and looked at the code that was referenced. It appears to me to be something that is pretty “hard coded” as opposed to something that you might have defined. Basically someone created a special function called “validateMatchTypeRegex” which they are then calling from within a plugin or something. Problem is that there are no comments or other breadcrumbs to indicate what might have put this in.
  4. This custom field is a regular, built-in “official” part of Xenforo and not a plugin.
  5. I looked at the change timestamp and noted it was updated at 2/5/24 @ 12:20. So I did a search for all files changed on 2/5/24. The bottom part (after the blank lines) were all changed at 12:20 so I cannot narrow it down except to say it was not in the “addons”.
  6. I then did a search of the database for the word “regex” in any of the fields. I found it in several of the databases.
  7. So we browsed the xf_user_field and found the column “match_type” where some stuff has regex and some doesn’t (attached as xf_user_field.png – note screenshot taken after adding the TestMe field mentioned below)
  8. We then did some testing to determine what does/doesn’t work.
    1. We noted that user ID 4 was unable to edit and save any field – we tested with some that had the regex in the match_type column and some that doesn’t.
    2. We then added a new custom field named TestMe (match_type = none) and attempted to edit that with the user. It also didn’t work.
    3. We then chose another user (ID 632) and edited fields on her account. All fields were successfully editable, including the new TestMe field.
    4. We also tested on another user with higher privileges (thinking it might be that user ID 4 has advanced privileges) and were not able to reproduce this issue with any other users.
    5. We did have another user who previously had an issue and it was “fixed” by merging the account with an older account they also had.
  9. During the test saving, I was watching the mysqld.log for any messages, but none appeared.

So the concern is we cannot figure out why ID 632 would not be a problem whereas ID 4 would be, and where we might look for an answer. Additionally, because of this, we have no way of knowing how many other users might be impacted, or how to find them.


Neither of us are programmers (much less Xenforo developers) and even if we attempted to try to follow support’s recommendation of changing the codebase, honestly I wouldn’t have the foggiest idea how to do that.
 
Top Bottom