Strange issue after fresh install

So I installed SS 4.5.1 using the prefered method (composer) on a local DDEV environment. Everything went fine, no errors, ran dev/build, etc and website is working.

However, logging into the admin it throws the following error everywhere in the pages module. All other modules seem fine and operate without errors.

# [Warning] array_keys() expects parameter 1 to be array, string given

### GET /admin/pages/

Line  **926**  in  **/var/www/html/public_html/vendor/silverstripe/cms/code/Controllers/CMSMain.php**
$context->setSearchParams($params);

$placeholder = _t('SilverStripe\\CMS\\Search\\SearchForm.FILTERLABELTEXT', 'Search') . ' "' .
    SiteTree::singleton()->i18n_plural_name() . '"';

$searchParams = $context->getSearchParams();

$searchParams = array_combine(array_map(function ($key) {
    return 'Search__' . $key;
}, array_keys($searchParams)), $searchParams);

$schema = [
    'formSchemaUrl' => $schemaUrl,
    'name' => 'Term',
    'placeholder' => $placeholder,
    'filters' => $searchParams ?: new \stdClass // stdClass maps to empty json object '{}'

Hey @Eliseth

Since this is the library file and I am hoping you didn’t made any changes in that, you can try to flush the settings cache with this URL:
http://your-domain/dev/build?flush=1

I tried that, but unfortunately to no avail. Also no files were modified, as stated; it’s a fresh install.

Ok, so I noticed that when adding the following the error disappears: “?q[Term]=”.

http://my-domain/admin/pages/
…will throw the error, but…
http://my-domain/admin/pages/?q[Term]=
…will not.

Also, this goes for editing the page as well:
http://my-domain/admin/pages/edit/show/1
…will throw the error, but…
http://my-domain/admin/pages/edit/show/1?q[Term]=
…will not

It seems as if the URL variable q[Term] needs to be passed or it throws an error.

Edit: Just passing ?q is enough to make the error disappear. Is this normally forced somewhere? Is this a server configuration problem? Or should it work without the ?q URL variable?

this should work with ?q URL, if you have terminal access, can you please try to run below command in root directory?

vendor/bin/sake dev/build

Did that:

$ vendor/bin/sake dev/build

Building database db using SilverStripe\ORM\Connect\MySQL 5.5.5-10.2.30-MariaDB-1:10.2.30+maria~bionic-log

CREATING DATABASE TABLES

  • File (0 records)
  • SiteConfig (1 records)
  • ChangeSet (0 records)
  • ChangeSetItem (0 records)
  • FileLink (0 records)
  • SiteTree (5 records)
  • SiteTreeLink (0 records)
  • Group (2 records)
  • LoginAttempt (7 records)
  • Member (2 records)
  • MemberPassword (2 records)
  • Permission (5 records)
  • PermissionRole (0 records)
  • PermissionRoleCode (0 records)
  • RememberLoginHash (0 records)
  • Folder
  • Image
  • Page
  • ErrorPage (2 records)
  • RedirectorPage (0 records)
  • VirtualPage (0 records)

CREATING DATABASE RECORDS

  • SilverStripe\Assets\File
  • SilverStripe\SiteConfig\SiteConfig
  • SilverStripe\Versioned\ChangeSet
  • SilverStripe\Versioned\ChangeSetItem
  • SilverStripe\Assets\Shortcodes\FileLink
  • SilverStripe\CMS\Model\SiteTree
  • SilverStripe\CMS\Model\SiteTreeLink
  • SilverStripe\Security\Group
  • SilverStripe\Security\LoginAttempt
  • SilverStripe\Security\Member
  • SilverStripe\Security\MemberPassword
  • SilverStripe\Security\Permission
  • SilverStripe\Security\PermissionRole
  • SilverStripe\Security\PermissionRoleCode
  • SilverStripe\Security\RememberLoginHash
  • SilverStripe\Assets\Folder
  • SilverStripe\Assets\Image
  • Page
  • SilverStripe\ErrorPage\ErrorPage
  • 404 error page refreshed
  • 500 error page refreshed
  • SilverStripe\CMS\Model\RedirectorPage
  • SilverStripe\CMS\Model\VirtualPage

Database build completed!

Same result…

add this in .env file

SS_ERROR_LOG="silverstripe.log"

this will generate the error log file in the root folder, which can help you to track the root cause.

Seems to want that parameter no matter what…

[2020-02-25 12:23:31] error-log.WARNING: E_WARNING: array_keys() expects parameter 1 to be array, string given {"code":2,"message":"array_keys() expects parameter 1 to be array, string given","file":"/var/www/html/vendor/silverstripe/cms/code/Controllers/CMSMain.php","line":926} []
[2020-02-25 12:23:31] error-log.WARNING: E_WARNING: array_map(): Expected parameter 2 to be an array, null given {"code":2,"message":"array_map(): Expected parameter 2 to be an array, null given","file":"/var/www/html/vendor/silverstripe/cms/code/Controllers/CMSMain.php","line":926} []
[2020-02-25 12:23:31] error-log.WARNING: E_WARNING: array_combine() expects parameter 1 to be array, null given {"code":2,"message":"array_combine() expects parameter 1 to be array, null given","file":"/var/www/html/vendor/silverstripe/cms/code/Controllers/CMSMain.php","line":924} []
[2020-02-25 12:23:31] error-log.WARNING: E_WARNING: Illegal string offset 'FilterClass' {"code":2,"message":"Illegal string offset 'FilterClass'","file":"/var/www/html/vendor/silverstripe/cms/code/Controllers/CMSMain.php","line":1633} []
[2020-02-25 12:23:31] error-log.WARNING: E_USER_WARNING: Couldn't set response type to 500 because of output on line 419 of /var/www/html/vendor/silverstripe/framework/src/Control/HTTPResponse.php {"code":512,"message":"Couldn't set response type to 500 because of output on line 419 of /var/www/html/vendor/silverstripe/framework/src/Control/HTTPResponse.php","file":"/var/www/html/vendor/silverstripe/framework/src/Control/HTTPResponse.php","line":397} []

Some more digging shows that the RequestHandler::getRequest() returns the following array:

the ‘q’ getVar contains the URL segment?

SilverStripe\Control\HTTPRequest::__set_state(array(
   'url' => 'admin/pages',
   'dirParts' => 
  array (
  ),
   'extension' => NULL,
   'httpMethod' => 'GET',
   'scheme' => 'https',
   'ip' => '172.18.0.6',
   'getVars' => 
  array (
    'q' => '/admin/pages/',
  ),
   'postVars' => 
  array (
  ), ...etc...

I had the same error.
This is related to the rewrite rule of nginx vhost definition.
I cannot take a look, because my project has been deleted.
But i can remember it had to do with these settings (try_files and rewrite argument)

Please take a look at the official nginx vhost documentation for silverstripe and compare to your default ddev vhost settings. I had to create a custom vhost file.

I think the default line

try_files $uri $uri/ /index.php?q=$uri&$args;

must be replaced by

try_files $uri /index.php?$query_string;

But this is only from memory

1 Like

That was it… I completely missed the additional steps required to host on nginx… Thanks!

1 Like