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/.
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.
| Folder | Holds | Namespace |
|---|---|---|
core/exception/ | HTTPError, StaleFileException, FileNotWritableException | Zero\Core\Exception |
core/access/ | User, Group, Permission, Holder, HoldsCapabilities | Zero\Core\Access |
core/lib/ | Crypto, Net/, Http/, Mail/, CloudFlare/ | Zero\Lib |
core/modules/ | The bundled modules | Zero\Core\Module — see below |
core/entity/ | The entity framework | Zero\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
| Was | Use instead | File |
|---|---|---|
Zero\Core\HTTPError | Zero\Core\Exception\HTTPError | core/exception/HTTPError.php |
Zero\Core\Crypto | Zero\Lib\Crypto | core/lib/Crypto.php |
Zero\Core\Cidr | Zero\Lib\Net\Cidr | core/lib/Net/Cidr.php |
Zero\Core\TrustedProxy | Zero\Lib\Net\TrustedProxy | core/lib/Net/TrustedProxy.php |
Zero\Core\ExternalRequest | Zero\Lib\Http\ExternalRequest | core/lib/Http/ExternalRequest.php |
Zero\Core\User (the account) | Zero\Core\Access\User | core/access/User.php |
Zero\Core\User (the session statics) | Zero\Core\Session — see below | core/Session.php |
Zero\Core\GroupPermission | Zero\Core\Access\Permission — see below | core/access/Permission.php |
Zero\Core\TokenBroker | Zero\Core\Module\Auth\OAuth\Broker | core/modules/Auth/OAuth/Broker.php |
Zero\Entity\OAuthToken, Zero\Entity\OAuthProvider | Zero\Core\Module\Auth\OAuth\Token, Provider | core/modules/Auth/OAuth/ |
Global Auth adapters (\GitHubAdapter, loaded with require_once) | Zero\Core\Module\Auth\Adapters\GitHubAdapter, autoloaded | core/modules/Auth/adapters/ |
Zero\Lib\Push\PushHelper | Zero\Core\Module\Push\Lib\PushHelper | core/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.
| Was | Use 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.
| Was | Use instead |
|---|---|
new GroupPermission($db, 'notes', 'note_id', 'note_permissions', 'note') | new Permission('notes', 'note') |
hasPermission($id, $userId, $action), which checked the owner too | Check 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 table | Call 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.
| Was | Now | Where |
|---|---|---|
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/*.json | The same paths under core/modules/Auth/ | — |
php modules/Auth/bin/purge-auth-tokens.php in cron | php core/modules/Auth/bin/purge-auth-tokens.php | — |
skeleton/modules/Index/ copied into each site | Index is a core module; your own modules/Index/ overrides it | core/modules/Index/ |
Core building module paths from MODULE_PATH | Zero\Core\Modules finds every module in both roots | core/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.
| Was | Use instead |
|---|---|
Zero\Module\{Auth, User, Admin, Index, Push, Entity, Module, HelloWorld, Test} and every class below them | Zero\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 test | extends \Zero\Core\Module\Admin |
Building a module class name from the string 'Zero\\Module\\' | Modules::controllerClass($name) |
| Cutting that prefix off a class name | Modules::classRest($class) |
A site overrides any module of core
| Was | Now |
|---|---|
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 roots | Only 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 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
| Was | Now |
|---|---|
Tiers required (always on) and optional | One 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 ignored | Obeyed. 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 screen | Every 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 canSwitch | Gone |
AccessRequest is a submodule of Auth
| Was | Now |
|---|---|
core/modules/AccessRequest/, class Zero\Module\AccessRequest | core/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 move | Answer 404, like every old URL |
An AccessRequest line in app/modules.ini | Matches 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
| Was | Use 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.
| Was | Now |
|---|---|
entity/Entity.php, GenericEntity.php, Event.php at the site root | core/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.php | Written to GenericEntity::siteDir(): ENTITY_SITE_DIR if defined, else ZERO_ROOT . 'entity/' |
| A site entity class named like a framework class | Not loaded; the framework's is found first |
Entity::where() printing Unknown search key into the page | A 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.
| Namespace | Folder |
|---|---|
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()) |
| Was | Use instead |
|---|---|
Zero\... entries under autoload in the site's composer.json | Remove them. Composer loads third-party packages only. |
require 'vendor/autoload.php' in a script or test bootstrap, to reach framework classes | require 'core/autoload.php', which registers classFile() and includes vendor/autoload.php when the site has one |
require_once of a module class in its tests | A 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 zero | index.php defines ZERO_ROOT as the folder three levels above www/; any name works |
Config and wording
| Was | Use instead | Where |
|---|---|---|
FROM_EMAIL | MAIL_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.ini | SITE_NAME in app/strings/site.ini. Remove it from config.ini. | core/skeleton/strings/site.ini |
| Wording hard-coded in a module | The module's strings/*.ini; repeat a key in app/strings/ to override it | core/Strings.php |
Every file in app/config/ parsed as constants | Only .ini files are parsed | Application::configFiles() |
A config key such as a.b or a-b | Skipped with a Console warning. Keys must be plain identifiers. | Application::defineOnce() |
| A key defined twice raising PHP's “already defined” warning | The first value stays, and a Console warning names the key and file | Application::defineOnce() |
SESSION_HINT_COOKIE | Delete it; nothing reads it | — |
database.ini with no DB_DRIVER meaning mysql | DB_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 time | Database::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_SUBNET | Shelved: 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 fired | Runs 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.
| Method | Calls from a frame, view or module | Calls from outside the object |
|---|---|---|
getAuxiliary(), framePiecePath() | Unchanged: $this->getAuxiliary('nav') | No longer possible |
framePieceFile(), findModuleView(), linkAssets() (static) | Unchanged | Response::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
| Was | Use 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 reason | HTTPError::toArray(): status, message, detail, code. Clients read detail first, then message. |
HTML in an HTTPError detail | The detail is escaped. Write "\n", not <br>. |
error_log() in framework-facing code | Console::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.
| Was | Now | Migration |
|---|---|---|
| Deleting a user from Admin | An 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_settings | A 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 prefix | Every key starts with allow.; grant() refuses one that does not | — |
Tables group, group_member | user_group, user_group_member | group_rename.sql |
| A permission table per module | Rows in permission | permission_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.
| Was | Use instead |
|---|---|
/admin/manage/users, /admin/manage/user/{id} | /admin/users, /admin/users/edit/{id} |
POST /admin/update-permission | POST /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/login | A 404, for every /admin URL |
Any modules/*/Admin/ folder listed on the dashboard | Only 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 URL | Only methods AdminResponse::isRoutableMethod() accepts: public, non-static, declared outside Zero\Core\ |
A failed admin action calling $this->error() and redirecting | throw new HTTPError(409, '...'); a success ends with $this->done($message, $url) |
| Breadcrumbs or a “Back to Admin” link printed in a view | Remove 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
| Was | Now | Where |
|---|---|---|
Application::banmotherfuckers() | Application::banNefariousRequest(). Same check, still the first line of run(). | core/Application.php |
| No way to exempt a client | app/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
| Gone | What to do |
|---|---|
KeycloakAdapter, /auth/keycloak-test | A new OIDC provider is a new adapter extending OAuth2Adapter |
The Sitemap module; /sitemap answers 404 | Remove 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\Error | HTTPError, thrown |
core/bin/log_monitor.sh and the LOG_FILE key of the config.ini template | Remove 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.php | Archived to core/deprecated/; nothing referenced it |
zero-init.sh cloning zero.core and shadowjs, making the www symlink | The 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.
| Was | Use 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 directly | A public Index::foo() method answers first; the view file alone is the fallback. See routing. |
A method-level #[RequirePermission] replacing the class-level one | It 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 type | Only when the request declares Content-Type: application/json |
Upgrade checklist
- Replace
core/with the new one, including itsentitysubmodule. - Delete your site's copies of the bundled modules and of the entity framework files. Keep your own
modules/Index/if you have one. - Check every site module whose name matches a bundled one. It now overrides core's; rename it if that is not what you want.
- Change
Zero\Module\toZero\Core\Module\wherever your code names a class of a bundled module (PushHelper, the OAuthProviderin frame partials). - Change links to
/access-request/...into/auth/access-request/.... - Search your modules for the old class names in the tables above and change each
useline. Start withZero\Core\HTTPErrorandZero\Core\User. - Replace
User::session statics withSession::, andnew Error(...)withthrow new HTTPError(...). - Remove
require_oncelines for framework, entity and module classes. - Create
app/modules.iniif you want anything off or on by exception, and moveenabledandorderout of everyadmin-config.php. An entry forIndex,Auth,UserorAdminis now obeyed. - Move
SITE_NAMEtoapp/strings/site.ini; renameFROM_EMAILtoMAIL_FROM; deleteSESSION_HINT_COOKIEandLOG_FILE. Remove any cron entry forlog_monitor.sh. - Add
DB_DRIVER=mysqltoapp/config/database.iniif the file has no driver line. Without it nothing connects. - Search your modules and plugins for
DEVMODEand make every readdefined('DEVMODE') && DEVMODE. The constant is not defined at present, so anything behind it is off. - Make every non-endpoint helper in your modules
protectedorprivate. - Run the migrations your database needs from
core/sql/migrations/, in the ordercore/sql/README.mdgives, or loadcore/sql/core.sqlto add the tables that are missing. - Point cron jobs and scripts at
core/modules/...andcore/autoload.php. - Update bookmarks and links to the old
/admin/manage/...URLs. - 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.