Fixed IPS permissions import bug

Affected version
2.0

Slavik

XenForo moderator
Staff member
Code:
XF\Db\Exception: MySQL query error [1265]: Data truncated for column 'permission_value' at row 17 src/XF/Db/AbstractStatement.php:217

Stack trace
INSERT  INTO `xf_permission_entry` (`user_group_id`, `user_id`, `permission_group_id`, `permission_id`, `permission_value`, `permission_value_int`) VALUES (20,0,'general','view','allow',0),
(20,0,'general','viewNode','allow',0),
(20,0,'general','viewProfile','allow',0),
(20,0,'general','viewMemberList','allow',0),
(20,0,'general','bypassFloodCheck','allow',0),
(20,0,'general','search','allow',0),
(20,0,'forum','viewAttachment','allow',0),
(20,0,'forum','viewContent','allow',0),
(20,0,'forum','viewOthers','allow',0),
(20,0,'forum','editOwnPost','allow',0),
(20,0,'forum','votePoll','allow',0),
(20,0,'profilePost','view','allow',0),
(20,0,'profilePost','post','allow',0),
(20,0,'profilePost','comment','allow',0),
(20,0,'conversation','start','allow',0),
(20,0,'conversation','receive','allow',0),
(20,0,'conversation','maxRecipients',0,0),
(20,0,'avatar','allowed','allow',0) ON DUPLICATE KEY UPDATE permission_value = VALUES(permission_value), permission_value_int = VALUES(permission_value_int)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1265, '01000')
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1265, '01000')
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(274): XF\Db\AbstractAdapter->query('INSERT  INTO `x...')
#4 src/XF/Import/DataHelper/Permission.php(152): XF\Db\AbstractAdapter->insertBulk('xf_permission_e...', Array, false, 'permission_valu...')
#5 src/XF/Import/DataHelper/Permission.php(12): XF\Import\DataHelper\Permission->insertPermissionsInternal('group', 20, Array, false)
#6 src/XF/Import/Data/UserGroup.php(30): XF\Import\DataHelper\Permission->insertUserGroupPermissions(20, Array)
#7 src/XF/Import/Data/AbstractData.php(135): XF\Import\Data\UserGroup->postSave(14, 20)
#8 src/addons/XFI/Import/Importer/IpsForums.php(407): XF\Import\Data\AbstractData->save(14)
#9 src/XF/Import/Runner.php(231): XFI\Import\Importer\IpsForums->stepUserGroups(Object(XF\Import\StepState), Array, 8)
#10 src/XF/Import/Runner.php(59): XF\Import\Runner->runStep('userGroups', Object(XF\Import\StepState), 8)
#11 src/XF/Admin/Controller/Import.php(234): XF\Import\Runner->run()
#12 src/XF/Mvc/Dispatcher.php(321): XF\Admin\Controller\Import->actionRun(Object(XF\Mvc\ParameterBag))
#13 src/XF/Mvc/Dispatcher.php(248): XF\Mvc\Dispatcher->dispatchClass('XF:Import', 'Run', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Import), NULL)
#14 src/XF/Mvc/Dispatcher.php(100): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Import), NULL)
#15 src/XF/Mvc/Dispatcher.php(50): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#16 src/XF/App.php(2177): XF\Mvc\Dispatcher->run()
#17 src/XF.php(390): XF\App->run()
#18 admin.php(13): XF::runApp('XF\\Admin\\App')
#19 {main}
From what I can see, IPS allows for you to enable PMs for people, but you can set max pms they can send is 0, which the importer doesnt deal with when the returned max users is 0.

Simply ensuring this is >0 allows it to continue, eg

Code:
$p['conversation']['maxRecipients'] = '1'; // should be max 500
Though should obviously pull the correct value for non 0 entries.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.5).

Change log:
Ensure the import permission helper doesn't fall over when faced with a permission value of 0.
Any changes made as a result of this issue being resolved may not be rolled out here until later.
 

Chris D

XenForo developer
Staff member
There are two places in src/addons/XFI/Importer/Importer/IpsForums.php that need changing.

Find (line 257):
PHP:
$p['conversation']['maxRecipients'] = $group['g_max_mass_pm']; // should be max 500
Replace with:
PHP:
$p['conversation']['maxRecipients'] = 1; // should be max 500
Find (line 308):
PHP:
$p['conversation']['maxRecipients'] = $group['g_max_mass_pm']; // should be max 500
Replace with:
PHP:
$p['conversation']['maxRecipients'] = 1; // should be max 500
You can replace 1 with whatever value you like, as long as it isn't 0. You can set it to -1 to mean "Unlimited".

The first one is for normal users. The second one is for moderators.
 
Top