Osticket: Fatal error Call to a member function sort() on array

Created on 24 May 2016  路  7Comments  路  Source: osTicket/osTicket

On develop, the page https://example.com/scp/kb.php gives
Fatal error: Call to a member function sort() on array in /root_path/include/staff/faq-categories.inc.php on line 148

I use a workaround like this:

- $categories->sort(function($a) { return $a->getLocalName(); });
+ sort($categories);

but I don't think it is the better way

Here is the config:

  • osticket develop
  • Debian Jessie
  • Nginx
bug

Most helpful comment

I created #3216 to address the issue

All 7 comments

+1

I also had this issue once i upgraded 1.9.12 -> 1.10 rc3.
I also tried a fresh install of 1.10 rc3, as well as a git install (as directed on github page)

@balojs i tried your suggestion, it had no effect.

@bastienho Your method works for me.

Hopefully this gets fixed on future versions.

thanks @zguithues check this path #3186 (84ebb88)

Could you also try this patch? I would like to use sorting in the ORM elsewhere and be consistent...

diff --git a/include/staff/faq-categories.inc.php b/include/staff/faq-categories.inc.php
index e90f06c..18ef634 100644
--- a/include/staff/faq-categories.inc.php
+++ b/include/staff/faq-categories.inc.php
@@ -141,7 +141,7 @@ if($_REQUEST['q'] || $_REQUEST['cid'] || $_REQUEST['topicId']) { //Search.
 } else { //Category Listing.
     $categories = Category::objects()
         ->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs')))
-        ->all();
+        ->getIterator();

     if (count($categories)) {
         $categories->sort(function($a) { return $a->getLocalName(); });

@greezybacon Confirmed that patch works.

I created #3216 to address the issue

Patch #3216 works for me @greezybacon
Thanks for the quick fix! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

markus4000 picture markus4000  路  4Comments

ghost picture ghost  路  6Comments

rachelsupport picture rachelsupport  路  5Comments

roman-1983 picture roman-1983  路  5Comments

simonnzg picture simonnzg  路  5Comments