Build 420 - Foundation framework upgrade (Laravel 5.5 LTS)

Release Note 9

Due to overwhelming support from the community, October CMS is updating its foundation framework to the latest Long Term Support (LTS) release. As a result, there are some new requirements to run October and some code changes required.

From the proposed date of 1st July 2017* (Build 420) your webserver will require PHP 7.0 or above to use October CMS. After this date, websites using PHP 5.5.9 will still function normally but will no longer be able to receive updates or install the latest version.

There are mandatory code changes required, including code found in plugins and themes, both private and public. Instructions marked with a can be performed immediately to ensure forward compatibility. In other words the change is compatible with all versions of October, now and after the release. It is recommended to make these changes as soon as possible.

* Actual date and build may change.

Required code changes

Database queries now return Collections instead of arrays

The query builder now returns October\Rain\Support\Collection instances instead of plain arrays.

// This now returns a Collection object
Db::table('users')->get();

// Add all() method to keep returning an array
Db::table('users')->get()->all();

Cast to an array after calling get() to remain compatible.

// Forwards compatible version
(array) Db::table('users')->get();

Since Collection objects implement ArrayAccess, they behave like arrays so looping over them should be fine. However here are some notable differences.

// An empty array will return false
if (!$array) { /* pass */ }

// Collections cannot be converted to booleans
if (!$collection) { /* fail */ }

// Use the isEmpty() method to check if empty
if (!$collection->isEmpty()) { /* pass */ }

Importantly, native PHP array manipulation functions will no longer behave correctly.

// Array functions will not work
$array = array_reverse($collection);

// Either cast to an array
$array = array_reverse((array) $collection);

// Or use the equivalent Collection method
$collection = $collection->reverse();

Database query pluck method has changed

The pluck() method called on a database query has changed radically and now returns a collection. It should be replaced with value() to retain the previous functionality of returning a string value.

// This will return a collection containing one item
Db::table('users')->where('id', 1)->pluck('username');

Replace pluck() with value() to remain compatible.

// Returns the username value as a string
Db::table('users')->where('id', 1)->value('username');

Twig has been updated to v2.0

Twig v2 is mostly compatible with Twig v1, there are some minor differences in the internals that may need updating. This is unlikely to impact the majority of websites.

Check Twig features in use are not deprecated.

Updated minimum requirements

As noted PHP 7.0 is now required at a minimum to install and update the platform. If you are unable to upgrade your server to PHP 7.0 and still wish to use October, you can still install the older build (419) that supports PHP 5.5.9, however bear in mind that no support path will be provided.

Installing old version

October Build 419 was the last build to support PHP 5.5.9, it can be installed using composer. Run the following command:

# Instructions still to be completed
composer ...
comments powered by Disqus