Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Any search returns Fatal Error

edited May 2014 in Vanilla 2.0 - 2.8

I followed the install instructions on my 2.1 (recently upgraded from 2.0.x) installation. Any time I run a search, or if I access /forum/search I get an error:

Fatal Error in UserModel.JoinUsers();

Invalid argument supplied for foreach()
The error occurred on or near: /Applications/MAMP/htdocs/techinet.it/forum/applications/dashboard/models/class.usermodel.php
704:     */
705:    public function JoinUsers(&$Data, $Columns, $Options = array()) {
706:       // Grab all of the user fields that need to be joined.
707:       $UserIDs = array();
708:       foreach ($Data as $Row) {
709:          foreach ($Columns as $ColumnName) {
710:             $ID = GetValue($ColumnName, $Row);
711:             if (is_numeric($ID))
712:                $UserIDs[$ID] = 1;
Backtrace:
[/Applications/MAMP/htdocs/techinet.it/forum/applications/dashboard/models/class.usermodel.php:708] PHP::Gdn_ErrorHandler();
[/Applications/MAMP/htdocs/techinet.it/forum/applications/dashboard/controllers/class.searchcontroller.php:99] UserModel->JoinUsers();
[/Applications/MAMP/htdocs/techinet.it/forum/applications/dashboard/controllers/class.searchcontroller.php:99] SearchController->Index();
[/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.dispatcher.php:350] PHP::call_user_func_array();
[/Applications/MAMP/htdocs/techinet.it/forum/index.php:46] Gdn_Dispatcher->Dispatch();
Queries:
select *
from GDN_User `User`
where UserID = '2'; 0.000000s
select *
from GDN_Permission `Permission`
limit 1; 0.000000s
select MAX(p.`PermissionID`) as `PermissionID`, MAX(p.`Garden.Settings.Manage`) as `Garden.Settings.Manage`, MAX(p.`Garden.Settings.View`) as `Garden.Settings.View`, MAX(p.`Garden.Messages.Manage`) as `Garden.Messages.Manage`, MAX(p.`Garden.SignIn.Allow`) as `Garden.SignIn.Allow`, MAX(p.`Garden.Applicants.Manage`) as `Garden.Applicants.Manage`, MAX(p.`Garden.Users.Add`) as `Garden.Users.Add`, MAX(p.`Garden.Users.Edit`) as `Garden.Users.Edit`, MAX(p.`Garden.Users.Delete`) as `Garden.Users.Delete`, MAX(p.`Garden.Users.Approve`) as `Garden.Users.Approve`, MAX(p.`Garden.Activity.Delete`) as `Garden.Activity.Delete`, MAX(p.`Garden.Activity.View`) as `Garden.Activity.View`, MAX(p.`Garden.Profiles.View`) as `Garden.Profiles.View`, MAX(p.`Garden.Profiles.Edit`) as `Garden.Profiles.Edit`, MAX(p.`Garden.Moderation.Manage`) as `Garden.Moderation.Manage`, MAX(p.`Garden.Curation.Manage`) as `Garden.Curation.Manage`, MAX(p.`Garden.PersonalInfo.View`) as `Garden.PersonalInfo.View`, MAX(p.`Garden.AdvancedNotifications.Allow`) as `Garden.AdvancedNotifications.Allow`, MAX(p.`Conversations.Moderation.Manage`) as `Conversations.Moderation.Manage`, MAX(p.`Vanilla.Discussions.View`) as `Vanilla.Discussions.View`, MAX(p.`Vanilla.Discussions.Add`) as `Vanilla.Discussions.Add`, MAX(p.`Vanilla.Discussions.Edit`) as `Vanilla.Discussions.Edit`, MAX(p.`Vanilla.Discussions.Announce`) as `Vanilla.Discussions.Announce`, MAX(p.`Vanilla.Discussions.Sink`) as `Vanilla.Discussions.Sink`, MAX(p.`Vanilla.Discussions.Close`) as `Vanilla.Discussions.Close`, MAX(p.`Vanilla.Discussions.Delete`) as `Vanilla.Discussions.Delete`, MAX(p.`Vanilla.Comments.Add`) as `Vanilla.Comments.Add`, MAX(p.`Vanilla.Comments.Edit`) as `Vanilla.Comments.Edit`, MAX(p.`Vanilla.Comments.Delete`) as `Vanilla.Comments.Delete`, MAX(p.`Plugins.Debugger.View`) as `Plugins.Debugger.View`, MAX(p.`Plugins.Debugger.Manage`) as `Plugins.Debugger.Manage`, MAX(p.`Garden.Email.View`) as `Garden.Email.View`, MAX(p.`Vanilla.Approval.Require`) as `Vanilla.Approval.Require`, MAX(p.`Vanilla.Comments.Me`) as `Vanilla.Comments.Me`, MAX(p.`Plugins.ProfileExtender.Add`) as `Plugins.ProfileExtender.Add`, MAX(p.`Plugins.OnlineNow.ViewHidden`) as `Plugins.OnlineNow.ViewHidden`, MAX(p.`Plugins.OnlineNow.Manage`) as `Plugins.OnlineNow.Manage`, p.JunctionTable as `JunctionTable`, p.JunctionColumn as `JunctionColumn`, p.JunctionID as `JunctionID`
from GDN_Permission p
join GDN_UserRole ur on p.RoleID = ur.RoleID
where ur.UserID = '2'
group by p.JunctionTable, p.JunctionColumn, p.JunctionID; 0.000000s
select *
from GDN_User `User`
where UserID = '2'; 0.000000s
Variables in local scope:
[Data] false
[Columns] array (
  0 => 'UserID',
)
[Options] array (
)
[UserIDs] array (
)

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Make sure you followed all the steps in the readme.

    I honestly cannot debug this, sorry. Paging @mcu_hq

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • mcu_hqmcu_hq yippie ki-yay ✭✭✭

    Do you receive this error if you disable the plugin? I don't see any reference to the sphinx plugin in that trace. The plugin does however override the default class.searchmodel.php, which is where I would think the problem would be if the SQL was changed between v2.0 and v2.1. I didn't see any problems with my install of 2.1, but that was a few months ago and things may have changed since then.

  • mcu_hqmcu_hq yippie ki-yay ✭✭✭

    IT seems that @peregrine has reproduced this error in the past, so somethin must be wrong in the plugin somewhere for v2.1...I'll take a look.

  • mcu_hqmcu_hq yippie ki-yay ✭✭✭
    edited June 2014

    Ok, try this:

    Open up class.searchdmodel.php and change line 74 to: return array(); instead of return FALSE;

    https://github.com/mcuhq/SphinxSearchPlugin/blob/master/class.searchmodel.php#L74

    Let me know if that fixes the problem.

  • IT seems that @peregrine has reproduced this error in the past, so

    it happened with a beta version for me.

    for me, I installed vanilla 2.1, and the latest sphinxsearch, and didn't get the problem again, without necessitating change you suggested. not sure what factors made it go away.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I did uninstall the Sphinx plugin and made a custom search plugin with searching by category and some other adjustments from standard search engine. I will mirror my installation on a developement machine and retry Sphinx with the fix you suggested in the next few days.
    Thanks!

  • peregrineperegrine MVP
    edited June 2014

    I believe I figured out the problem.

    Fatal Error in UserModel.JoinUsers();

    I'm pretty sure this is the issue. @francosolerio @mcu_hq

    • I suspect you have $Configuration['Debug'] = TRUE; in your config.php
    • try removing $Configuration['Debug'] = TRUE; from your config.php if you have the error.

    I can cause error by adding $Configuration['Debug'] = TRUE; to config.php
    and if I remove debug statement sphinx works fine.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight ∞ · New Moderator

    I also see this on my production site. Enabling debug via conf will throw errors on many pages in 2.1. Goes away when removing debug mode.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • another side issue if you have eventi plugin enabled, you won't be able to enable plugins via dashbpard either.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited June 2014

    @mcu_hq said:

    Ok, try this:

    Open up class.searchdmodel.php and change line 74 to: return array(); instead of return FALSE;

    https://github.com/mcuhq/SphinxSearchPlugin/blob/master/class.searchmodel.php#L74

    Let me know if that fixes the problem.

    @mcu_hq with your change

     /**
             * Override the default search from running right here! 
             */
             if(true) // Force this to be true while the sphinxsearch plugin is enabled!
                  return array(); //sphinx is running...don't use default search
            else {
    

    works perfectly with NO ERRORS

    $Configuration['Debug'] = TRUE; in your config.php

    or

    $Configuration['Debug'] = FALSE; in your config.php

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I can confirm that $Configuration['Debug'] = FALSE; solves the issue here.

    Returning array() instead of FALSE in class.searchdmodel.php line 74 gives a different error on my installation (see below). This error like the previous one disappears with Configuration['Debug'] = FALSE;

    Notice: Undefined property: stdClass::$BuildExcerptsLimit in /Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/widgets/class.widgets.php on line 239
    
    Notice: Undefined property: stdClass::$BuildExcerptsAround in /Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/widgets/class.widgets.php on line 240
    
    Fatal Error in PHP.WriteClassic();
    
    Creating default object from empty value
    The error occurred on or near: /Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/widgets/views/helper_functions.php
    33:     <div class="SphinxSearch">
    34:         <ul class="DataList">
    35:             <?php foreach ($Results as $Row): ?>
    36:                 <?php
    37:                 $Author->Photo = $Row->UserPhoto;
    38:                 $Author->Name = $Row->UserName;
    39:                 $Author->UserID = $Row->UserID;
    40:                 $TitleURL = $Row->IsComment ? 'discussion/comment/' . $Row->CommentID . '/#Comment_' . $Row->CommentID : DiscussionLink($Row, FALSE); //if the comment is from the orignal discussion poster, simply link to the front page of that
    41:                 ?>
    Backtrace:
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/widgets/views/helper_functions.php:37] PHP::Gdn_ErrorHandler();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/widgets/views/helper_functions.php:22] PHP::WriteClassic();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/views/search/results.php:82] PHP::WriteResults();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/views/search/index.php:182] PHP::include();
    [/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.controller.php:767] PHP::include();
    [/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.controller.php:1233] Gdn_Controller->FetchView();
    [/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.pluggable.php:212] Gdn_Controller->xRender();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/class.sphinxsearch.plugin.php:437] Gdn_Pluggable->__call();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SphinxSearch/class.sphinxsearch.plugin.php:437] SearchController->Render();
    [/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.pluginmanager.php:705] SphinxSearchPlugin->SearchController_Render_Before();
    [/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.pluginmanager.php:638] Gdn_PluginManager->CallEventHandler();
    [/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.pluggable.php:196] Gdn_PluginManager->CallEventHandlers();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SearchCategory/class.searchcategory.plugin.php:98] Gdn_Pluggable->__call();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SearchCategory/class.searchcategory.plugin.php:98] SearchController->Render();
    [/Applications/MAMP/htdocs/techinet.it/forum/plugins/SearchCategory/class.searchcategory.plugin.php:98] SearchCategoryPlugin->SearchController_Index_Create();
    [/Applications/MAMP/htdocs/techinet.it/forum/library/core/class.dispatcher.php:337] PHP::call_user_func_array();
    [/Applications/MAMP/htdocs/techinet.it/forum/index.php:46] Gdn_Dispatcher->Dispatch();
    Variables in local scope:
    [Results] array (
      0 => 
      array (
        'DiscussionID' => '2532',
        'InsertUserID' => '140',
        'Body' => 'Conoscete una marca (facilmente reperibile) di <span class="SphinxExcerpts">pane</span> <span class="SphinxExcerpts">azimo</span>? Per un periodo devo evitare lieviti...<br />
    Grazie',
        'DateInserted' => '2010-02-08 11:11:19',
        'LastCommentUserID' => '140',
        'CommentID' => '2532',
        'IsComment' => '0',
        'CountComments' => '1',
        'CountViews' => '68',
        'Title' => '<span class="SphinxExcerpts">pane</span> <span class="SphinxExcerpts">azimo</span> per latte',
        'DiscussionBody' => 'Conoscete una marca (facilmente reperibile) di pane azimo? Per un periodo devo evitare lieviti...
    Grazie',
        'UserName' => 'marzadori',
        'UserPhoto' => NULL,
        'UserID' => '140',
        'CatName' => 'Latte',
        'CatUrlCode' => 'latte',
      ),
      1 => 
      array (
        'DiscussionID' => '132',
        'InsertUserID' => '29',
        'Body' => ' ...  e farti le cose(es:<span class="SphinxExcerpts">pane</span>,pasta,ecc).Così sei sicura ... .Io faccio delle"piadine"tipo <span class="SphinxExcerpts">pane</span> <span class="SphinxExcerpts">azimo</span> con la farina del Mulino ... ',
        'DateInserted' => '2007-02-02 20:52:40',
        'CommentID' => '495',
        'IsComment' => '1',
        'CountComments' => '8',
        'CountViews' => '277',
        'Title' => 'prodotti per celiaci',
        'DiscussionBody' => 'ciao a tutti
    lola,che ringrazio,ha scritto che è sicuro il prosciuto cotto Lenti x celiaci e allora mi(anzi vi) chiedo: tutti i prodotti per celiaci sono sicuri x chi è frumento?e sempre Lola scrive che tra gli ingredienti non ci deve essere il vino,ma io non l\'ho trovato tra le categorie a rischio....siate buoni e aiutatemi a capire! vorrei riuscire a stare meglio ma ho paura di continuare a sbagliare. Grazie a tutti',
        'UserName' => 'lola',
        'UserPhoto' => NULL,
        'UserID' => '29',
        'CatName' => 'Frumento',
        'CatUrlCode' => 'frumento',
      ),
      2 => 
      array (
        'DiscussionID' => '132',
        'InsertUserID' => '98',
        'Body' => ' ...  e farti le cose(es:<span class="SphinxExcerpts">pane</span>,pasta,ecc).Così sei sicura ... .Io faccio delle"piadine"tipo <span class="SphinxExcerpts">pane</span> <span class="SphinxExcerpts">azimo</span> con la farina del Mulino ... ',
        'DateInserted' => '2007-02-05 16:05:05',
        'CommentID' => '539',
        'IsComment' => '1',
        'CountComments' => '8',
        'CountViews' => '277',
        'Title' => 'prodotti per celiaci',
        'DiscussionBody' => 'ciao a tutti
    lola,che ringrazio,ha scritto che è sicuro il prosciuto cotto Lenti x celiaci e allora mi(anzi vi) chiedo: tutti i prodotti per celiaci sono sicuri x chi è frumento?e sempre Lola scrive che tra gli ingredienti non ci deve essere il vino,ma io non l\'ho trovato tra le categorie a rischio....siate buoni e aiutatemi a capire! vorrei riuscire a stare meglio ma ho paura di continuare a sbagliare. Grazie a tutti',
        'UserName' => 'galvanone',
        'UserPhoto' => NULL,
        'UserID' => '98',
        'CatName' => 'Frumento',
        'CatUrlCode' => 'frumento',
      ),
    )
    [WriteText] true
    [CssClass] 'DataList'
    [Row] array (
      'DiscussionID' => '2532',
      'InsertUserID' => '140',
      'Body' => 'Conoscete una marca (facilmente reperibile) di <span class="SphinxExcerpts">pane</span> <span class="SphinxExcerpts">azimo</span>? Per un periodo devo evitare lieviti...<br />
    Grazie',
      'DateInserted' => '2010-02-08 11:11:19',
      'LastCommentUserID' => '140',
      'CommentID' => '2532',
      'IsComment' => '0',
      'CountComments' => '1',
      'CountViews' => '68',
      'Title' => '<span class="SphinxExcerpts">pane</span> <span class="SphinxExcerpts">azimo</span> per latte',
      'DiscussionBody' => 'Conoscete una marca (facilmente reperibile) di pane azimo? Per un periodo devo evitare lieviti...
    Grazie',
      'UserName' => 'marzadori',
      'UserPhoto' => NULL,
      'UserID' => '140',
      'CatName' => 'Latte',
      'CatUrlCode' => 'latte',
    )
    [Author] array (
      'Photo' => NULL,
    )
    
Sign In or Register to comment.