Tickets XF\PrintableException: XF\Job\ApprovalQueueProcess: Please select a valid forum.

Affected add-on version
2.12.4
Affected XenForo version
2.3.13
This one is quite annoying, as it blocks approval of new tickets:
  • XF\PrintableException: XF\Job\ApprovalQueueProcess: Please select a valid forum.
  • src/XF/Mvc/Entity/Entity.php:1276
  • Generated by: Unknown account
  • Oct 27, 2026 at 2:23 PM

Stack trace​

#0 src/addons/NF/Tickets/Entity/Ticket.php(1776): XF\Mvc\Entity\Entity->save()
#1 src/addons/NF/Tickets/Entity/Ticket.php(1427): NF\Tickets\Entity\Ticket->updateCategoryRecord()
#2 src/XF/Mvc/Entity/Entity.php(1330): NF\Tickets\Entity\Ticket->_postSave()
#3 src/addons/NF/Tickets/Service/Ticket/Approver.php(44): XF\Mvc\Entity\Entity->save()
#4 src/addons/NF/Tickets/ApprovalQueue/Ticket.php(42): NF\Tickets\Service\Ticket\Approver->approve()
#5 src/XF/ApprovalQueue/AbstractHandler.php(202): NF\Tickets\ApprovalQueue\Ticket->actionApprove(Object(SV\ElasticSearchEssentials\NF\Tickets\Entity\Ticket))
#6 src/XF/Job/ApprovalQueueProcess.php(71): XF\ApprovalQueue\AbstractHandler->performAction('approve', Object(SV\ElasticSearchEssentials\NF\Tickets\Entity\Ticket))
#7 src/XF.php(950): XF\Job\ApprovalQueueProcess->{closure:XF\Job\ApprovalQueueProcess::run():57}()
#8 src/XF/Job/ApprovalQueueProcess.php(57): XF::asVisitor(Object(SV\ElasticSearchEssentials\XF\Entity\User), Object(Closure))
#9 src/XF/Job/Manager.php(275): XF\Job\ApprovalQueueProcess->run(45)
#10 src/XF/Job/Manager.php(205): XF\Job\Manager->runJobInternal(Array, 45)
#11 src/XF/Job/Manager.php(121): XF\Job\Manager->runJobEntry(Array, 45)
#12 job.php(25): XF\Job\Manager->runByIds(Array, 45)
#13 {main}

Request state​


array(4) {
["url"] => string(8) "/job.php"
["referrer"] => string(94) "https://forum.com/approval-queue/?applied_filters=1&include_reported=1&without_tickets=1"
["_GET"] => array(0) {
}
["_POST"] => array(0) {
}
}
 
Cause found: Category::_preSave() runs the on-demand forum check on every counter save, so any ticket in such a category can no longer be approved (or updated)

Versions

Tickets 2.12.4, XenForo 2.3.13. Still happening today (Nov 1, 2026, server error log), so this is not a leftover from the upgrade.

Current trace (2.12.4)
Code:
XF\PrintableException: XF\Job\ApprovalQueueProcess: Please select a valid forum.
src/XF/Mvc/Entity/Entity.php:1276
#0 src/addons/NF/Tickets/Entity/Ticket.php(1783): XF\Mvc\Entity\Entity->save()
#1 src/addons/NF/Tickets/Entity/Ticket.php(1434): NF\Tickets\Entity\Ticket->updateCategoryRecord()
#2 src/XF/Mvc/Entity/Entity.php(1330): NF\Tickets\Entity\Ticket->_postSave()
#3 src/addons/NF/Tickets/Service/Ticket/Approver.php(44): XF\Mvc\Entity\Entity->save()
#4 src/addons/NF/Tickets/ApprovalQueue/Ticket.php(42): NF\Tickets\Service\Ticket\Approver->approve()
#5 src/XF/ApprovalQueue/AbstractHandler.php(202): ...->actionApprove(...)
#6 src/XF/Job/ApprovalQueueProcess.php(71): ...->performAction('approve', ...)

Expected
Approving a moderated ticket makes it visible and updates the category counters.

Actual
The approval fails with "Please select a valid forum." The ticket save is rolled back, so the ticket stays in the approval queue. Every new attempt fails the same way.

Code path
1. Approver::approve() sets discussion_state = 'visible' and saves the ticket.
2. Ticket::_postSave() → updateCategoryRecord(). The state change is 'enter', so it runs (Ticket.php 1780-1783):
Code:
if ($visibilityChange === 'enter' && $category)
{
    $category->ticketAdded($this);
    $category->save();
}
3. Category::save() → preSave() → Category::_preSave() (Category.php 76-82):
Code:
protected function _preSave()
{
    if ($this->on_demand_thread && (!$this->thread_node_id || !$this->ThreadForum))
    {
        $this->error(\XF::phrase('please_select_valid_forum'), 'thread_node_id');
    }
}
4. The category has on_demand_thread = 1 and no valid ThreadForum, so the error is set, Entity::save() throws PrintableException (Entity.php:1276), and the outer ticket save transaction is rolled back.

The only places that use the please_select_valid_forum phrase are this _preSave() and XF\Entity\Feed, so the error can only come from this check.

Data on our site
The ticket in the queue is in category "Commercial Inquiries" (ticket_category_id 8). On the ticket page the "Discussion" tab is shown with data-xf-click="overlay". Per nf_tickets_ticket_wrapper_macros that only happens when the ticket has no viewable thread and $ticket.Category.on_demand_thread is true. So category 8 has on-demand thread creation enabled, and the error shows it has no valid thread forum (on our dev copy of this category thread_node_id is 0).

That setting was saved under an earlier version: in 2.11.0 Category has the on_demand_thread column but no _preSave() check, so the admin form accepted "on demand" without a forum. 2.12.1 and 2.12.4 have the check. After the upgrade the old data became unsaveable.

Why this is wider than approvals
The check runs on every save of the category entity, not only when the admin saves the category form. So every place that saves the category for counters hits it:
  • Ticket.php:1756 / 1766: ticket moved into or out of the category
  • Ticket.php:1783: ticket becomes visible (approval, undelete, new visible ticket)
  • Ticket.php:1788: ticket becomes hidden (soft delete, unapprove)
  • Ticket.php:1793: any update of a visible ticket (ticketDataChanged(), e.g. a new reply that changes last_message_date, a status change)
  • Ticket.php:1813: ticket hard delete
  • Job/Category.php:31: the category counter rebuild job
From the code, every one of these fails for a category in this state. We only reproduced the approval case on our site; the others follow from the same save() call and were not tested by hand.

The same will happen on any site where the thread forum of an on-demand category is deleted later, because ThreadForum is then null.

Suggested fix
1. Only validate when an admin changes the related fields, so internal counter saves are not blocked:
Code:
protected function _preSave()
{
    if ($this->on_demand_thread
        && $this->isChanged(['on_demand_thread', 'thread_node_id'])
        && (!$this->thread_node_id || !$this->ThreadForum)
    )
    {
        $this->error(\XF::phrase('please_select_valid_forum'), 'thread_node_id');
    }
}
(Moving the check into Admin\Controller\Category::categorySaveProcess() works as well.)

2. Data repair in an upgrade step, for categories saved before the check existed:
Code:
UPDATE xf_nf_tickets_category AS c
LEFT JOIN xf_forum AS f ON (f.node_id = c.thread_node_id)
SET c.on_demand_thread = 0
WHERE c.on_demand_thread = 1
  AND f.node_id IS NULL;

3. At runtime, actionDiscussion() and the "Discussion" tab should not offer on-demand thread creation when the category has no valid ThreadForum, so a later forum deletion shows a clear message instead of a failed thread creation.
 
Back
Top