0

I'm migrating a Drupal 8 project I developed locally up to the server as a subdirectory in my hosting service that my site domain points to. I've cleared the caches (with drush cr and truncating the cache tables in PHPMyAdmin), moved all the files over, exported the local database and replaced all URL's in the SQL dump to match new site domain, recreated database on host server, updated settings.php to connect to database, set $base_url to match my domain, uncommented the RewriteBase in the .htaccess file, and have retried all the above in different combinations trying to figure out this issue. The site works perfectly fine on local but shows as a 500 Internal Server Error on production, this is what displays on site:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

And this is what I'm seeing in the host provider's PHP error logs.

20170929T235109: www.mysite.com/index.php PHP Fatal error: Unsupported operand types in /hermes/walnaweb02a/b194/moo.jerrydgarciacom/smashjuku/core/modules/views/src/Element/View.php on line 49

I never fiddled with any core or module files, so I'm guessing this issue is being caused by something else. I have no idea whatsoever how to troubleshoot this though, so any advice, ideas or recommendations are welcome.

  • What version of PHP is on the server? – Kevin Sep 30 '17 at 18:27
  • The default PHP version is 5.6. – user1930581 Sep 30 '17 at 20:14
  • Have you enabled mod_rewrite module for Apache? – kenorb Oct 3 '17 at 9:22
0

This is the failing code which fails in View::preRenderViewElement (View.php file):

  /**
   * View element pre render callback.
   */
  public static function preRenderViewElement($element) {
    // Allow specific Views displays to explicitly perform pre-rendering, for
    // those displays that need to be able to know the fully built render array.
    if (!empty($element['#pre_rendered'])) {
      return $element;
    }

    if (!isset($element['#view'])) {
      $view = Views::getView($element['#name']);
    }
    else {
      $view = $element['#view'];
    }

    $element += $view->element; // PHP Fatal error: Unsupported operand types.
    $view->element = &$element;

The above shows that the problem is related to pre rendering your view element which failed to load the view from your element (either from $element['#name'] or $element['#view']). This may suggest that one of your views could be broken.

First of all, try clearing your Drupal caches and memory caches (Memcached/Redis).

Then since you're migrating your code, please double check that:

  • you've properly migrated all your custom code (hooks) related to views,
  • you've re-exported your views into new Drupal 8 format,
  • try re-saving the failing element (node or view),
  • your PHP matches the environment where it works,
  • you've executed /update.php (or drush updb) to update any pending database changes.

Debugging

If above won't help, ideally you should reproduce the same problem on your local (pulling the code and db, making sure the PHP is the same). Then you can install PHP XDebug extension, configure and enable it temporary, then you can generate the trace for specific page, or use xdebug_start_trace() and xdebug_stop_trace() functions to debug specific parts of your code. Or use a standard var_dump(debug_backtrace()); exit; code (on $view->element being empty) before the failing line in preRenderViewElement(), to track down which element or view it relates to and start from there.

0

Most probably, you just need to rebuild the caches.
Home >> Administration >> Configuration >> Development >> Performance -> Clear all caches (../admin/config/development/performance)
or cd /hermes/walnaweb02a/b194/moo.jerrydgarciacom/smashjuku/my_root_folder && ../vendor/bin/drush cr

  • Did that already, used drush cr before I moved the files and database. Even went into phpmyadmin after installing the db on server and truncated all the cache tables, still no luck. – user1930581 Sep 30 '17 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.