FIX: $Layout should not be executed if inside cached block

If you have $Layout inside of some <% cached %> tag, Layout should not be
executed if the cached content is available.  Prior to this commit Layout was
executed in advance of rendering the template and passed to the underlay as
a variable.  It is now passed as a closure so it is only executed as needed.

See https://groups.google.com/d/msg/silverstripe-dev/itYU50HoH50/aR6grcPIBSYJ
FIX: locales like zh_hans were requiring zh as their YML array key
FEATURE: Cache has_one relationships

Enables caching of has_one relationships using the caching built into
DataObject::get_by_id()
FIX: only insert script includes before other javascript file references

If you had a script tag somewhere in your body that was for a JS template or JSON data
(for example <script type='application/json' id='something'>{ ... }</script>), then
the requirements backend was inserting javascript files before that script tag when it really
should have been putting them at the end of the body.
HHVM COMPATIBILITY: Disable circular reference collection

Removing gc_enable since HHVM 2.2 does not support this feature.
HHVM COMPATIBILITY: Use ReflectionProperty->getValue

HHVM returns an array of ReflectionProperty objects from
lookup_static_properties, instead of just an array of values. This watches for
this conditions and calls getValue
HHVM COMPATIBILITY: Make ClassInfo::ancestry() work correctly on HHVM

HHVM 2.2 has a bug which causes get_parent_class() to not work
correctly if the class hasn't been included yet. i.e. get_parent_class()
doesn't trigger the autoloader. Work around this issue by adding a call
to class_exists() first so that the class gets autoloaded.
HHVM COMPATIBILITY: HHVM doesn't allow constants to be defined as non-scalar values

PHP doesn't allow this either, STDOUT is a weird exception to this rule. Fixes
the issue by not trying to define a constant with a file pointer as the value.
This seems like weird/bad global state anyway.
FIX: Do not allow 200 response with databaseConfig error in main.php

Previously, upon a fatal error in main.php, PHP would die and display an error
message to the user, but the HTTP response was still 200 OK. That has the
dangerous potential of poisoning caches with bad data. This change fixes the
behavior so that the page dies with a 500 Server Error code.