Fixed Username change limit can be set to a value that is too high

Ivancas

Well-known member
Affected version
2.2.15
The following error is displayed when a user is edited:
1715052139194.webp
Master style on XF doesn't have any modifications.
This can be reproduced on PHP 8.2 or PHP 81 (I haven't tried others).
Addons were disabled through config.php

This happens when I try to edit any user. The strack trace is the following:
Code:
#0 src/XF/Mvc/Entity/Entity.php(167): XF\Entity\User->getNextAllowedUsernameChange()
#1 src/XF/Mvc/Entity/Entity.php(125): XF\Mvc\Entity\Entity->get('next_allowed_us...')
#2 internal_data/code_cache/templates/l1/s0/admin/user_edit.php(270): XF\Mvc\Entity\Entity->offsetGet('next_allowed_us...')
#3 src/XF/Template/Templater.php(1655): XF\Template\Templater->{closure}(Object(XF\Template\Templater), Array, NULL)
#4 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('user_edit', Array)
#5 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#6 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XF:User\\Edit', 'admin:user_edit', Array)
#7 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#8 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#9 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#10 src/XF/App.php(2487): XF\Mvc\Dispatcher->run()
#11 src/XF.php(524): XF\App->run()
#12 admin.php(13): XF::runApp('XF\\Admin\\App')
#13 {main}

Request state:
Code:
array(4) {
  ["url"] => string(38) "/admin.php?users/formertexan.1826/edit"
  ["referrer"] => bool(false)
  ["_GET"] => array(1) {
    ["users/formertexan_1826/edit"] => string(0) ""
  }
  ["_POST"] => array(0) {
  }
}
 
Okay, you got me. I'm confused.

This basically shouldn't be able to happen in the code, as I am reading it.

Can you run the following query against your database, and let us know the output?

SQL:
SELECT option_value 
FROM xf_option 
WHERE option_id = 'usernameChangeTimeLimit';
 
Okay, you got me. I'm confused.

This basically shouldn't be able to happen in the code, as I am reading it.

Can you run the following query against your database, and let us know the output?

SQL:
SELECT option_value
FROM xf_option
WHERE option_id = 'usernameChangeTimeLimit';
yes:
1715101427967.webp

Exporting the entry returns a bin file which contains 9223372036854775807
 
Okay. Now find that option in your admin control panel. What is it set to? Did you set it to that number?
 
Okay. Now find that option in your admin control panel. What is it set to? Did you set it to that number?
I don't remember but it seems basically it will end at the end of the universe:
1715101686882.webp

I've changed the value and the error has gone. Thanks!
 
I think it might be sensible for us to impose a slightly less generous upper limit here so we'll leave the bug open ;)

The main issue here is we then multiply that number by 86400 to get the number of seconds 😬

Which is 7.9689934398×10²³ in case you're wondering 😆
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.0 Beta 7).

Change log:
Set a few sensible max limits for username change options
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom