stave.dev

Upgrading

What changed between an older core and this one, and what to use instead. Each table reads left to right: what your site has now, what replaces it, and where to look.

How to read this page

The source is core/docs/DEPRECATING_CHANGES.md, which travels with core and records every removal, newest first. This page keeps the entries that affect a site's own code and config, each one checked against the code in core/.

There are no aliases

A class that moved did not leave its old name behind. Code that names Zero\Core\HTTPError does not load; it has to be changed to the new name. Search your site for each entry in the left-hand column.

The layout of core

Classes that sat directly in core/ moved into folders, and each namespace follows its folder.

FolderHoldsNamespace
core/exception/HTTPError, StaleFileException, FileNotWritableExceptionZero\Core\Exception
core/access/User, Group, Permission, Holder, HoldsCapabilitiesZero\Core\Access
core/lib/Crypto, Net/, Http/, Mail/, CloudFlare/Zero\Lib
core/modules/The bundled modulesZero\Core\Module — see below
core/entity/The entity frameworkZero\Entity (unchanged)
core/sql/core.sql and migrations/—
core/docs/The framework's documentation, including ADMIN_ARCHITECTURE.md, ADMIN_ASSETS.md and PERMISSIONS.md, which sat in core/—
core/bin/Scripts: refresh-cloudflare-ips.php—
core/deprecated/Error.php, SQLAdapter.php, the Sitemap module. Nothing loads them.—

Classes that moved

WasUse insteadFile
Zero\Core\HTTPErrorZero\Core\Exception\HTTPErrorcore/exception/HTTPError.php
Zero\Core\CryptoZero\Lib\Cryptocore/lib/Crypto.php
Zero\Core\CidrZero\Lib\Net\Cidrcore/lib/Net/Cidr.php
Zero\Core\TrustedProxyZero\Lib\Net\TrustedProxycore/lib/Net/TrustedProxy.php
Zero\Core\ExternalRequestZero\Lib\Http\ExternalRequestcore/lib/Http/ExternalRequest.php
Zero\Core\User (the account)Zero\Core\Access\Usercore/access/User.php
Zero\Core\User (the session statics)Zero\Core\Session — see belowcore/Session.php
Zero\Core\GroupPermissionZero\Core\Access\Permission — see belowcore/access/Permission.php
Zero\Core\TokenBrokerZero\Core\Module\Auth\OAuth\Brokercore/modules/Auth/OAuth/Broker.php
Zero\Entity\OAuthToken, Zero\Entity\OAuthProviderZero\Core\Module\Auth\OAuth\Token, Providercore/modules/Auth/OAuth/
Global Auth adapters (\GitHubAdapter, loaded with require_once)Zero\Core\Module\Auth\Adapters\GitHubAdapter, autoloadedcore/modules/Auth/adapters/
Zero\Lib\Push\PushHelperZero\Core\Module\Push\Lib\PushHelpercore/modules/Push/lib/PushHelper.php
// gone
use Zero\Core\HTTPError;

// use
use Zero\Core\Exception\HTTPError;

User became User and Session

User was the account and the session in one class. The account is Zero\Core\Access\User; everything about the current request is on Zero\Core\Session.

WasUse instead
User::currentId(), User::getId()Session::userId()
User::current()Session::user()
User::isLoggedIn()Session::isLoggedIn()
User::hasPermission($key)Session::can($key)
User::establish($user)Session::establish($user)
User::logout()Session::end()

GroupPermission became Permission

GroupPermission was built with a module's own table and column names. Permission is built with a module name and an entity name, and every module's grants are rows in one core table, permission. See permissions.

WasUse instead
new GroupPermission($db, 'notes', 'note_id', 'note_permissions', 'note')new Permission('notes', 'note')
hasPermission($id, $userId, $action), which checked the owner tooCheck the owner yourself, then can($id, $userId, $action)
getByEntity($id)groups($id)
getAvailableGroups($id, $userId)availableGroups($id, $userId)
getSharedUsers($id)users($id)
update($id, $groupId, $flags)grant() again with the new flags
ON DELETE CASCADE on a module's permission tableCall forget($id) when you delete the item; permission has no foreign keys

grant() and revoke() now take a Holder — a User or a Group object — rather than a group id.

Bundled modules live in core

The modules every site gets — Index, Auth, User, Admin, Push, Entity, Module, HelloWorld, Test — ship in core/modules/. Your site's modules/ folder holds your own modules, and any override of core's. See bundled modules.

WasNowWhere
Copies of the bundled modules in your modules/Delete them; core's are used. A copy you leave behind is now an override: it answers in place of core's.core/modules/
modules/Auth/config/, modules/Auth/adapters/config/*.jsonThe same paths under core/modules/Auth/—
php modules/Auth/bin/purge-auth-tokens.php in cronphp core/modules/Auth/bin/purge-auth-tokens.php—
skeleton/modules/Index/ copied into each siteIndex is a core module; your own modules/Index/ overrides itcore/modules/Index/
Core building module paths from MODULE_PATHZero\Core\Modules finds every module in both rootscore/Modules.php
A module folder with a lowercase name (modules/foo/Foo.php)Rename the folder to the module's name (modules/Foo/)core/Modules.php

Core's modules have their own namespace

Every class of a module in core/modules/ is in Zero\Core\Module\. Zero\Module\ holds a site's modules only. The URLs are unchanged, apart from AccessRequest's.

WasUse instead
Zero\Module\{Auth, User, Admin, Index, Push, Entity, Module, HelloWorld, Test} and every class below themZero\Core\Module\...
\Zero\Module\Push\Lib\PushHelper\Zero\Core\Module\Push\Lib\PushHelper
\Zero\Module\Auth\OAuth\Broker, Provider, Token\Zero\Core\Module\Auth\OAuth\.... A site's own frame partials that list sign-in providers (_oauth-buttons.php, _google-signin.php) name Provider and need the change.
extends \Zero\Module\Admin in a testextends \Zero\Core\Module\Admin
Building a module class name from the string 'Zero\\Module\\'Modules::controllerClass($name)
Cutting that prefix off a class nameModules::classRest($class)

A site overrides any module of core

WasNow
A site module named like a bundled one failing every request with a 500; Index the one exception (Modules::OVERRIDABLE)A site module with the exact name of a module of core overrides it, and may extend core's class. Modules::overridden(), corePath(), sitePath() and isCore() tell the two apart.
A “Module name clash” 500 for any name in both rootsOnly for two spellings of one name (Links and links, compared ignoring case and hyphens) or one name in two folders of the site
Modules::configure($roots, $iniFile)Takes the core root as an optional third argument
This site's EntityFramework module

This site's documentation module was renamed from Entity to EntityFramework when the shared name was a clash. It keeps that name so that it does not override core/modules/Entity/: it is documentation, not a replacement for the module.

Tiers: required and optional became core

WasNow
Tiers required (always on) and optionalOne tier, core: Index, Auth, User, Admin, Push, Entity, on by default. Modules::tier() answers core, example or site.
An app/modules.ini entry for Index, Auth, User or Admin ignoredObeyed. No module is always on, so check your file for a stray = off line.
ModulesIni::setEnabled() refusing a required module; no switch on the Admin modules screenEvery module has a switch. Turning Admin off removes the screen; delete the Admin = off line to bring it back.
The string ADMIN_MODULES_ALWAYS_ON, the row field canSwitchGone

AccessRequest is a submodule of Auth

WasNow
core/modules/AccessRequest/, class Zero\Module\AccessRequestcore/modules/Auth/submodule/AccessRequest/, class Zero\Core\Module\Auth\AccessRequest. It is on when Auth is on.
/access-request/permission, /submit, /approve/auth/access-request/permission, /submit, /approve. #[RequirePermission] redirects to the first.
Approval links in mail sent before the moveAnswer 404, like every old URL
An AccessRequest line in app/modules.iniMatches no module and is ignored. Remove it.

app/modules.ini

Modules can be switched off, and one file says which. app/modules.ini lists only departures from the defaults: core and site modules default on, example modules (Module, HelloWorld, Test) default off. A module that is off answers 404 exactly as one that does not exist.

[enabled]
Push = off
HelloWorld = on

[order]
Links = 10
WasUse instead
'enabled' in a module's admin-config.php[enabled] in app/modules.ini
'order' in a module's admin-config.php[order] in app/modules.ini

The entity framework

The entity framework is a git submodule of core at core/entity/. Your site's entity/ folder holds only your own entity classes. See Entity Framework.

WasNow
entity/Entity.php, GenericEntity.php, Event.php at the site rootcore/entity/, same names. Delete the site's copies.
require_once ZERO_ROOT . '/entity/GenericEntity.php'Nothing. The autoloader maps Zero\Entity\ to core/entity/, then to your entity/.
Generated classes written next to GenericEntity.phpWritten to GenericEntity::siteDir(): ENTITY_SITE_DIR if defined, else ZERO_ROOT . 'entity/'
A site entity class named like a framework classNot loaded; the framework's is found first
Entity::where() printing Unknown search key into the pageA Console warning, and null returned

One class-loading rule

Application::classFile() is an explicit map from namespace to folder, and it is the only rule: requests, tests and command-line scripts all use it. The class name is no longer rewritten by string replacement. See autoloading.

NamespaceFolder
Zero\Core\Attribute\core/attribute/
Zero\Core\core/ (so Zero\Core\Access\ is core/access/)
Zero\Lib\core/lib/
Zero\Entity\core/entity/, then the site's entity/
Zero\Aux\aux/
Zero\App\Lib\app/lib/
Zero\Core\Module\{Name}\...Core's module of that name, core/modules/{Name}/ (Modules::corePath()), each further segment a folder
Zero\Module\{Name}\...The site's module of that name, modules/{Name}/ (Modules::sitePath())
WasUse instead
Zero\... entries under autoload in the site's composer.jsonRemove them. Composer loads third-party packages only.
require 'vendor/autoload.php' in a script or test bootstrap, to reach framework classesrequire 'core/autoload.php', which registers classFile() and includes vendor/autoload.php when the site has one
require_once of a module class in its testsA use line
A site-root lib/ folder for Zero\Lib\core/lib/. A library only one module uses goes in that module's lib/, under Zero\Module\{Name}\Lib.
The site folder had to be called zeroindex.php defines ZERO_ROOT as the folder three levels above www/; any name works

Config and wording

WasUse insteadWhere
FROM_EMAILMAIL_FROM. Blank or absent means noreply@ + PRIMARY_DOMAIN. Delete FROM_EMAIL; core does not read it.core/lib/Mail/Mail.php
SITE_NAME in app/config/config.iniSITE_NAME in app/strings/site.ini. Remove it from config.ini.core/skeleton/strings/site.ini
Wording hard-coded in a moduleThe module's strings/*.ini; repeat a key in app/strings/ to override itcore/Strings.php
Every file in app/config/ parsed as constantsOnly .ini files are parsedApplication::configFiles()
A config key such as a.b or a-bSkipped with a Console warning. Keys must be plain identifiers.Application::defineOnce()
A key defined twice raising PHP's “already defined” warningThe first value stays, and a Console warning names the key and fileApplication::defineOnce()
SESSION_HINT_COOKIEDelete it; nothing reads it—
database.ini with no DB_DRIVER meaning mysqlDB_DRIVER is required and has no default. Add DB_DRIVER=mysql, or nothing connects. Database::connect() and Database::init() with an array still mean mysql when it has no driver key.Database::isConfigured()
Blank NAME or USER still attempting a connection, and logging Database connection failed at critical each timeDatabase::getConnection() throws Database is not configured without connecting or logging. Code that matched on the old message for a site with no database must match the new one.core/Database.php
DEVMODE defined when the client address contains DEV_SUBNETShelved: the block is commented out, DEVMODE is never defined and nothing reads DEV_SUBNET. Test it with defined('DEVMODE') && DEVMODE; such code takes its production branch. Uncomment the block to bring it back.Application::defineConstants()
The session-age check in Application::__construct(), which ran before any .ini was read and so never firedRuns at the end of defineConstants(), so sessions now do get a new id by age. SESSION_REGENERATE_INTERVAL left out or blank means 1800 seconds; 0 means never. The replaced session answers for 60 more seconds and is then refused. See security.Application::regenerateAgedSession()
skeleton/_config_templates/core/skeleton/config-templates/—

The full list of keys is on the configuration page.

Helpers a URL could reach

A public method of a module is an endpoint. Five framework helpers were public, so /{module}/get-auxiliary/{file} and /{module}/link-assets/... were URLs on every module. They are protected in core/Response.php and core/Module.php.

MethodCalls from a frame, view or moduleCalls from outside the object
getAuxiliary(), framePiecePath()Unchanged: $this->getAuxiliary('nav')No longer possible
framePieceFile(), findModuleView(), linkAssets() (static)UnchangedResponse::framePieceFile(...) and Module::linkAssets(...) are a fatal error

Apply the same rule to your own modules: a helper that is not meant to be a URL should not be public. renderError() stays public because Application::run() calls it.

Errors

WasUse instead
new \Zero\Core\Error(404, 'Map not found'); return;throw new \Zero\Core\Exception\HTTPError(404, 'Map not found');
A JSON error body carrying data and no reasonHTTPError::toArray(): status, message, detail, code. Clients read detail first, then message.
HTML in an HTTPError detailThe detail is escaped. Write "\n", not <br>.
error_log() in framework-facing codeConsole::error(), Console::warn()

core/Error.php is now core/deprecated/Error.php and the autoloader does not find it. More on the errors page.

Users, capabilities and the database

core/sql/core.sql creates every table and view that core and the bundled modules use, and can be loaded onto a database that already has some of them. The one-off scripts that came before it are in core/sql/migrations/, to be run by hand on a site that needs them; core/sql/README.md gives the order.

WasNowMigration
Deleting a user from AdminAn account is disabled, never deleted: $user->disable(), $user->enable(). A disabled account cannot sign in and its open session ends at the next request.users_disabled.sql
A capability as an allow.* row in user_settingsA row in permission, so a group can hold one too. Grant with $user->grant($key), revoke with $user->revoke($key). setSetting('allow.x', '1') grants nothing.capability_migration.sql
Capability keys without the prefixEvery key starts with allow.; grant() refuses one that does not—
Tables group, group_memberuser_group, user_group_membergroup_rename.sql
A permission table per moduleRows in permissionpermission_migration.sql
$_SESSION['user_settings']['allow.admin']Session::can('allow.admin'). Read through to the database, so a revocation applies on the next request.—
$_SESSION['auth_level']Session::user()?->authLevel()—

Admin

Admin's own screens are submodules, and every other screen belongs to the module it administers. The admin screens page describes the result; these are the things that break.

WasUse instead
/admin/manage/users, /admin/manage/user/{id}/admin/users, /admin/users/edit/{id}
POST /admin/update-permissionPOST /admin/users/set-capability, set-setting, remove-setting
/admin/manage/groups, /admin/manage/group/{id}/admin/groups, /admin/groups/members/{id}
/admin/manage/{entity}, /admin/create-entity/admin/entity/manage/{label}, /admin/entity/create
/admin/manage/event/admin/audit
A non-admin redirected to /user/loginA 404, for every /admin URL
Any modules/*/Admin/ folder listed on the dashboardOnly a module with the class {X}\Admin\{X}Admin in its own namespace (Zero\Module\ for a site's module)
Any existing method of an admin controller reachable by URLOnly methods AdminResponse::isRoutableMethod() accepts: public, non-static, declared outside Zero\Core\
A failed admin action calling $this->error() and redirectingthrow new HTTPError(409, '...'); a success ends with $this->done($message, $url)
Breadcrumbs or a “Back to Admin” link printed in a viewRemove them; AdminResponse prints the breadcrumbs above every view
An admin screen reading its module's constants from app/config/Admin loads the module's own config.ini, config/ and strings/ for the screen it routes to

The ban check

WasNowWhere
Application::banmotherfuckers()Application::banNefariousRequest(). Same check, still the first line of run().core/Application.php
No way to exempt a clientapp/config/allowed-ips.lst: one IP or CIDR range per line, # for comments. A listed client is never banned. The file is optional.core/skeleton/config-templates/allowed-ips.lst

The check itself is described under security.

Removed, with no replacement

GoneWhat to do
KeycloakAdapter, /auth/keycloak-testA new OIDC provider is a new adapter extending OAuth2Adapter
The Sitemap module; /sitemap answers 404Remove Sitemap lines from app/modules.ini and any /sitemap link from your footer. The code is kept in core/deprecated/modules/Sitemap/.
The “returning user” hint cookie and Session::hintCookieName()Nothing. It held the user id in plain text and nothing read it.
Zero\Core\ErrorHTTPError, thrown
core/bin/log_monitor.sh and the LOG_FILE key of the config.ini templateRemove the cron entry and the key. The script mailed one log file per level; Console writes every level to one file (Console::$defaultLogFile), so watch that with the host's log tooling.
core/SQLAdapter.phpArchived to core/deprecated/; nothing referenced it
zero-init.sh cloning zero.core and shadowjs, making the www symlinkThe script clones nothing and builds the site in the folder that contains core/. See install.

If your core is older still

These changed earlier. Check them if your site predates them.

WasUse instead
$_SESSION['framePath']$this->adoptFrameFrom($_SERVER['HTTP_REFERER'] ?? null) in the module constructor, before parent::__construct(). A module that does not call it renders in the site's default frame.
A standalone URL rendering Index/view/foo.php directlyA public Index::foo() method answers first; the view file alone is the fallback. See routing.
A method-level #[RequirePermission] replacing the class-level oneIt adds to it: both keys are required
#[AuditLog('event', false, true)] (the requireAuth argument)#[RequireLogin] above #[AuditLog('event')]
Application::checkForAttributes()Application::checkAttributes($class, $endpoint), public and static
public function view($args)Named parameters matching the URL segments: public function view($id = null)
A JSON body decoded into $_POST whatever its typeOnly when the request declares Content-Type: application/json

Upgrade checklist

  1. Replace core/ with the new one, including its entity submodule.
  2. Delete your site's copies of the bundled modules and of the entity framework files. Keep your own modules/Index/ if you have one.
  3. Check every site module whose name matches a bundled one. It now overrides core's; rename it if that is not what you want.
  4. Change Zero\Module\ to Zero\Core\Module\ wherever your code names a class of a bundled module (PushHelper, the OAuth Provider in frame partials).
  5. Change links to /access-request/... into /auth/access-request/....
  6. Search your modules for the old class names in the tables above and change each use line. Start with Zero\Core\HTTPError and Zero\Core\User.
  7. Replace User:: session statics with Session::, and new Error(...) with throw new HTTPError(...).
  8. Remove require_once lines for framework, entity and module classes.
  9. Create app/modules.ini if you want anything off or on by exception, and move enabled and order out of every admin-config.php. An entry for Index, Auth, User or Admin is now obeyed.
  10. Move SITE_NAME to app/strings/site.ini; rename FROM_EMAIL to MAIL_FROM; delete SESSION_HINT_COOKIE and LOG_FILE. Remove any cron entry for log_monitor.sh.
  11. Add DB_DRIVER=mysql to app/config/database.ini if the file has no driver line. Without it nothing connects.
  12. Search your modules and plugins for DEVMODE and make every read defined('DEVMODE') && DEVMODE. The constant is not defined at present, so anything behind it is off.
  13. Make every non-endpoint helper in your modules protected or private.
  14. Run the migrations your database needs from core/sql/migrations/, in the order core/sql/README.md gives, or load core/sql/core.sql to add the tables that are missing.
  15. Point cron jobs and scripts at core/modules/... and core/autoload.php.
  16. Update bookmarks and links to the old /admin/manage/... URLs.
  17. Load a page. A bare 500 on every URL means a module name clash — two spellings of one name, or one name in two folders of your site; read the log for the two folders.