symphonists / search_index

Search Index provides an easy way to implement high performance fulltext searching on your Symphony site
32 stars 21 forks source link

explode() expects parameter 2 to be string, array given #11

Closed tonyarnold closed 13 years ago

tonyarnold commented 13 years ago

Hi Nick, I hit this error tonight updating an older site:

explode() expects parameter 2 to be string, array given
/Users/tonyarnold/Sites/tonyarnold.com/extensions/search_index/data-sources/data.search.php line 94

89          } else {
90              $param_sections = array();
91          }
92          
93          $sections = array();
94          foreach(array_map('trim', explode(',', $param_sections)) as $handle) {
95              $section = Symphony::Database()->fetchRow(0,
96                  sprintf(
97                      "SELECT `id`, `name` FROM `tbl_sections` WHERE handle = '%s' LIMIT 1",
98                      Symphony::Database()->cleanValue($handle)
nickdunn commented 13 years ago

updating an older site

That might be the problem, how old? Search Index changed quite a lot during its development so the config array and table structure may not always be backwards compatible. Could you paste what you've got in yer config.php please?

tonyarnold commented 13 years ago

Sure thing — it's never had search-index installed before today — it was an S2.1 install (which I've spent the evening upgrading to 2.2.1):


        ###### SEARCH_INDEX ######
        'search_index' => array(
            're-index-per-page' => '20',
            're-index-refresh-rate' => '0.5',
            'get-param-prefix' => null,
            'get-param-keywords' => 'keywords',
            'get-param-per-page' => 'per-page',
            'get-param-sort' => 'sort',
            'get-param-direction' => 'direction',
            'get-param-sections' => 'sections',
            'get-param-page' => 'page',
            'default-sections' => null,
            'default-per-page' => '20',
            'default-sort' => 'score',
            'default-direction' => 'desc',
            'excerpt-length' => '250',
            'min-word-length' => '3',
            'max-word-length' => '30',
            'stem-words' => 'yes',
            'build-entries' => 'no',
            'mode' => 'like',
            'log-keywords' => 'yes',
            'indexes' => 'a:2:{i:6;a:3:{s:6:\"fields\";a:5:{i:0;s:5:\"title\";i:1;s:7:\"summary\";i:2;s:4:\"body\";i:3;s:6:\"author\";i:4;s:4:\"tags\";}s:9:\"weighting\";s:1:\"1\";s:7:\"filters\";a:1:{i:30;s:3:\"yes\";}}i:40;a:3:{s:6:\"fields\";a:6:{i:0;s:4:\"page\";i:1;s:5:\"title\";i:2;s:4:\"body\";i:3;s:11:\"description\";i:4;s:8:\"keywords\";i:5;s:6:\"author\";}s:9:\"weighting\";s:1:\"2\";s:7:\"filters\";a:0:{}}}',
        ),
        ########
nickdunn commented 13 years ago

Hrm, am not aware of any Sympho changes that might be troublesome. So looks like $param_sections is probably null at this point. Are you passing ?sections=foobar on your URL?

tonyarnold commented 13 years ago

I was not, and that was indeed the problem. Close this issue as RTFM :)

-t

On 23/05/2011, at 10:58 PM, nickdunn wrote:

Hrm, am not aware of any Sympho changes that might be troublesome. So looks like $param_sections is probably null at this point. Are you passing ?sections=foobar on your URL?

Reply to this email directly or view it on GitHub: https://github.com/nickdunn/search_index/issues/11#comment_1221449


Tony Arnold http://thecocoabots.com/

nickdunn commented 13 years ago

Was my fault. When you're not passing sections I was defaulting the variable to an array, which explode chokes on. Now defaults to a string in 0.8.3. Cheers tarnold.