Garani
Active member
I know that this is a bit strange, but let's see if someone gets what I am missing.
I need to call XenForo_Model_InlineMod_Thread::applyThreadPrefix so that I can change the prefix of one or more threads.
Yes, the user is authorized, and so is the forum for that particular prefix.
I am calling the function from an extention of XenForo_ControllerPublic_InlineMod_Thread, so I am creating that class:
Within the function I call it like this:
On the first run, it does NOT work. Function is called, parameters are there and correct, but simply is does not write to DB, nor I get a moderator log as expected. So, something is off. Still I get no error ($errorKey) nor any unchanged thread ($unchangedThreadIds). Then out of the blue, once in a while, it works. Behavior is not coherent.
I tried to mimic the function by creating a new datawriter, and that doesn't work either: it simply does not write to DB. The only solution I found was to raw write to the DB with this:
(at the moment it is running within a loop, so it isn't efficient as it should).
Any idea on what I may be missing?
I need to call XenForo_Model_InlineMod_Thread::applyThreadPrefix so that I can change the prefix of one or more threads.
Yes, the user is authorized, and so is the forum for that particular prefix.
I am calling the function from an extention of XenForo_ControllerPublic_InlineMod_Thread, so I am creating that class:
PHP:
$threadInlineModel = XenForo_Model::create('DaVinciDigital_GuildManager_Extend_Model_InlineMod_Thread');
Within the function I call it like this:
PHP:
$unchangedThreadsIds = array();
$errorKey = '';
$options = array ();
$prefixId = (string)$guilds[$thread['node_id']]['deguilded_prefix_id'];
$threadInlineModel->applyThreadPrefix($threadDeguilded, $prefixId, $unchangedThreadIds, $options, $errorKey);
On the first run, it does NOT work. Function is called, parameters are there and correct, but simply is does not write to DB, nor I get a moderator log as expected. So, something is off. Still I get no error ($errorKey) nor any unchanged thread ($unchangedThreadIds). Then out of the blue, once in a while, it works. Behavior is not coherent.
I tried to mimic the function by creating a new datawriter, and that doesn't work either: it simply does not write to DB. The only solution I found was to raw write to the DB with this:
PHP:
$db = XenForo_Application::get('db');
$db->query("
UPDATE xf_thread SET
prefix_id = ".$guilds[$thread['node_id']]['deguilded_prefix_id'] . "
WHERE thread_id = ".$thread['thread_id']);
XenForo_Db::commit();
(at the moment it is running within a loop, so it isn't efficient as it should).
Any idea on what I may be missing?