Download the PHP package lolli/dbdoctor without Composer

On this page you can find all versions of the php package lolli/dbdoctor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dbdoctor

tests core v13 tests core v14

TYPO3 DB doctor

Mission

The mission of this extension is to find database inconsistencies that may have been introduced in a living TYPO3 instance over time, and to fix them.

As an example, when a page tree is deleted by an editor, it sometimes happens that most pages are properly set to deleted, but some pages are missed, or a content element on one page is not deleted. This leads to orphan pages or content elements in the database.

There can be many reasons to end up with invalid database state like the above: TYPO3 in general has no referential integrity constraints on database tables, inconsistencies can be triggered by a dying PHP process, a lost DB connection, a core bug, a buggy extension, a broken deployment, and more. Long-lived active instances that were upgraded through multiple major core versions tend to end up with something that isn't quite right anymore.

Such inconsistencies can lead to further issues. For instance, if a page is copied that has an orphaned localized record, the system tends to mess up localizations of the copied page, too. Editors then stumble and TYPO3 agencies have to do time-consuming debugging sessions to find out what went wrong.

This extension provides a CLI command that tries to find various such inconsistencies and gives admins options to fix them.

I'm not aware of other open extensions that try to achieve the same in a similar systematic way. The core lowlevel extension comes with a few commands that try to find and clean up some fishy DB state cases, but dbdoctor solves far more things. This extension is not a substitute for lowlevel commands. It will grow over time.

Installation via composer

The extension currently supports TYPO3 v13 and TYPO3 v14. It can be installed as non-dev dependency (not adding --dev to composer require): It has no impact on a live instance (except dependency injection definitions) as long as it is not actively executed via CLI. There are no TER releases after 2.2.0.

Usage

Preparation

The nature of the CLI command is to perform destructive database operations on your instance. As such, a few things should be kept in mind:

Agentic doctor

Judging findings on a large instance is the laborious part of using dbdoctor. A coding agent can do much of it: Documentation/AgentGuide.md tells agents how to run dbdoctor read-only with the JSON report, how to go through the report in a few steps, and how to judge findings, for instance whether fixing them changes the frontend. The agent ends with a verdict per check: harmless, needs a look, or the check seems wrong.

One prompt to an agent with shell access does it all, in the project root of the instance:

With dbdoctor installed already, the prompt starts with "Read …".

To make this permanent for a project, add a line to its AGENTS.md or CLAUDE.md:

Notes:

Human interface

Note dbdoctor is "runtime static" with TCA and database schema: Both are not expected to change meanwhile. When you are looking at single changes and decide to change TCA, then clear all caches and abort dbdoctor (press "a" in interactive mode) to start again. Failing to do so may lead to dbdoctor writing harmful changes to the database, depending on what you did with TCA.

The interface looks like this:

A run with TYPO3 v14: Healthy checks are a single "OK" line, a check that finds something shows its records and asks what to do.

The main command is a chain of single checks. They are done one by one. Affected record details can be shown on a per-page and a per-record basis to give a quick overview. The interface allows deleting or updating affected records, depending on the type of the check.

Interactive mode

When dbdoctor finds something to fix in (default) interactive mode, execution stops and waits for user input:

s, p, d and e work on the records found when the check ran: e executes exactly the changes s shows. Before executing, e runs the check again: When records changed meanwhile, it shows the new findings instead of executing. r runs the check again at any time.

Exit values

Exit values are bit masks: Integer 3 means: "Changes needed or done" AND "User abort"

Options

The CLI command can be executed with a couple of options. The default mode is "interactive", prompting for user input after each failed check.

Postprocessing

Strategy

The strategy of this command is to check for single things one-at-a-time and to fix them before going to the next check. Updates and deletes of not-ok records are done with low-level database queries directly, not using the DataHandler.

Single checks are carefully crafted and functionally tested and the order in which they are executed is important.

A single run does not guarantee a clean database: Fixing something in a later check can create new findings for an earlier check, for instance when a deleted record leaves sys_file_reference rows pointing to nothing. Run dbdoctor again until a run finds nothing, -m check returns 0 (zero) then.

Single checks rather try to avoid memory consumption and assumed state at the cost of more queries being executed. Queries are often performed as prepared statements to re-use them often in a single check. Statements are properly closed when a single check has finished, effectively using the PHP garbage collection. All-in-all, this command should perform relatively well even with big-sized instances, but it will hammer the database a lot.

Impact on Frontend rendering

When a health check finds something fishy, dbdoctor allows only one hard coded solution to deal with it. The user is not asked for a solution, they either accept the proposed UPDATE or DELETE database changes, or need to abort and take care manually (and then restart).

Implementing a per-record question/answer feature in dbdoctor is not feasible since this would add an orthogonal vector of complexity to the system which would quickly render it unmaintainable: Single checks are designed to work on top of each other, dbdoctor needs to establish a "chain of correctness" to do its job.

There are usually three options for a specific "fix":

In rare cases, a record that belongs to another one is missing, and dbdoctor inserts it, for instance the default language sys_file_metadata record of a sys_file record.

The general strategy is to create as little damage as possible from a TYPO3 Frontend rendering point of view.

For example, when there are two localizations for a default language record in a specific language, dbdoctor detects this as invalid and suggests setting one of them to deleted=1. Of the two records, it tries to set the one to deleted that is typically not rendered in Frontend.

This general strategy isn't always as simple as with the above example, though: Since the TYPO3 Frontend rendering is so flexible, the actual rendered record sometimes depends on specific Frontend rendering details dbdoctor can't know. In those cases, dbdoctor tries to guess the least amount of damage. This may not always fit real life cases. The only solution to deal with this is to look at single record change suggestions individually. The interactive options p, d and s hopefully help to classify single suggested changes.

Limits

Even though this low level tool tries to be very careful and checks lots of details before suggesting a change, there are still some limits and assumptions: For example, the "delete" column of soft-delete aware TCA tables is assumed to be an integer column, and not a text or varchar or similar. The correct schema of this column is usually created by the core as long as there is no explicit definition of it in a ext_tables.sql file. However, if an extension gets this wrong and defines such a field in some broken way, dbdoctor may cause damage by suggesting deletes or updates of all rows.

There are further assumptions: For instance, dbdoctor assumes some TCA settings the core provides for standard tables (especially pages, tt_content and sys_file_reference) are not changed by extensions. For example, those tables are assumed to be both soft-delete aware and workspace aware, the corresponding fields are queried by dbdoctor on such tables, and dbdoctor will fail if an extension tampered with the corresponding TCA ctrl settings.

There are further scenarios dbdoctor cannot deal with: For example, let's say some extension declares a table soft-delete-aware by having a TCA entry ['ctrl']['delete'] = 'deleted', and you have some rows that are deleted=1. Later, that TCA table is set to be no longer soft-delete-aware by removing the ['ctrl']['delete'] declaration. The core database analyzer will then suggest first renaming the deleted column to zzz_deleted_deleted, and will then allow removing the column. Doing this will effectively push all previously deleted records "live", if you failed to remove all affected deleted=1 records beforehand. There are similar scenarios when TCA tables are changed to be no longer workspace-aware, but you still have workspace related records in the table, or when TCA tables are no longer "starttime" / "endtime" aware while there are still timed records in the table.

dbdoctor always works on the current TCA state. It never knows if some TCA table has been defined "soft-delete-aware" before, and if this has been changed later. When you push records live by removing the "deleted" column, by removing the "workspaces" extension, workspaces related columns, or timing related fields, this can end up in a broken state dbdoctor is not able to fix. Instead, it will tend to find additional database relations that are broken, and will suggest changes that make the situation worse than before. Also, dbdoctor never looks at potentially existing zzz_deleted columns - those do not exist from dbdoctor's point of view since they depend on some "before" TCA state that cannot be reconstructed. State created by scenarios like the above is not repairable and needs manual reconstruction. Good luck.

All in all, TCA and ext_tables.sql of extensions should be in good shape before working with dbdoctor, and changes suggested by health checks should always be checked manually before committing them to the database. Also, never forget to back up the database to prepare for a disaster recovery that may become necessary. Do not accept dbdoctor suggestions blindly!

Versions

dbdoctor supports the PHP versions and database systems of the TYPO3 core versions it supports.

Further hints

I highly encourage admins to back up databases when working with dbdoctor. Some basic rules regarding SQL dumps must not be forgotten when doing this:

FAQ

Will the functionality be made available in a backend GUI?

No. CLI is the only sane way for this kind of thing.

Can I manipulate health checks?

Not via the CLI: It has no options to skip or configure checks, every check always fixes things the same way. Options would multiply the possible system states and render maintenance of this already complex project impossible. Programmatically, ModifyHealthClassListEvent can remove or reorder checks, for instance to skip checks tagged as risky, and disables replaces a check, see below. Both work, but you are on your own: Read the event class comment first.

Can I add my own health checks?

Technically yes, but you are on your own. Health checks are collected via dependency injection: Every autoconfigured service implementing HealthCheckInterface is tagged lolli.dbdoctor.health automatically and becomes part of the chain, also when it lives in a different extension. Its position is determined by the before and after tag attributes in Services.yaml, referencing identifiers of other checks. Neither the identifiers, nor the order, nor HealthCheckInterface are API: dbdoctor adds, renames, reorders or removes checks at any time. A check without before and after ends up at some position nobody chose. If before and after contradict each other, for instance after dbdoctor reordered checks, building the dependency injection container fails with an exception naming the cycle. Do not additionally add such a check using ModifyHealthClassListEvent, it would run twice.

Can I replace a health check of dbdoctor?

Same as above: Yes, but you are on your own. Tag your check with disables, the identifier of the check it replaces:

The replaced check is not executed, and your check runs at its position in the chain, no before or after needed. A tag replaces exactly one check. To replace multiple checks, add one tag with its own identifier per replaced check. Identifiers in disables that do not exist are ignored silently: When dbdoctor renames or removes a check you replaced, the dbdoctor check may run again, and yours ends up at some position nobody chose. Verify your replacements after each dbdoctor update.

Does dbdoctor fix the number of relations stored in inline and MM fields?

No. The field of a record with inline children (TCA foreign_field) or MM relations (TCA MM) stores the number of relations, for instance tt_content.image or sys_category.items. The relations themselves live in the child or MM table, and the core reads them from there, not from this count. The count is not reliable: For instance, sys_category.items is not updated when categories are assigned from the other side of the relation, like the categories field of a content element, and discarding workspace changes removes MM rows without touching counts. dbdoctor ignores these count fields: It does not check them, and checks that remove child records or MM rows do not update them.

Why does dbdoctor not use the TcaSchema API of the core?

On purpose. TcaHelper and a few checks mimic parts of TcaSchema, which exists since TYPO3 v13. But dbdoctor changes and deletes records, and which tables and fields a check touches must follow rules dbdoctor defines and tests itself. TcaSchema is an interpretation layer of the core on top of the TCA array, and it may change its semantics in any core release, including bugfix releases, without dbdoctor noticing. The TCA array is the more stable contract: Extensions write it, the core migrates outdated syntax before dbdoctor reads it. Also, the relation related checks depend on details like foreign_table_field, MM_opposite_field or MM_match_fields that TcaSchema does not model, so dbdoctor would read the TCA array anyway.

This project is heavily driven by agentic coding. Can I trust it?

No. But probably more than before. That "No" holds for any tool that changes your data, and it is why this README elaborates on backups, replay and recovery so much: If dbdoctor destroyed something and you have neither a backup nor an audit trail of the executed queries, there is no mercy. See "Preparation" above. And yes, large parts of the code are written with the help of agents nowadays. When I picked up this project again in 2026, there were many loose ends, missing features and various architectural flaws. I was able to fix a lot of them within a few days, and I am confident the result is far better than what I could have achieved without agents. This works because of the harness around it: Every check has a functional test with fixtures of the broken and the fixed state, CI runs all of them on all supported PHP versions with mysql, mariadb, postgres and sqlite, and changes are tested against several real-life instances. I look at the details and discuss options at length. And most importantly: I know the problem domain. I worked on the database details of the TYPO3 core for years and refactored major parts of it. Simply put: You can trust dbdoctor more than anyone who starts an agent with "Rewrite DataHandler" in 2026.

Tagging and releasing

packagist.org is enabled via the usual GitHub hook. Each tag gets a GitHub release, too: Create it in the GitHub web interface from the tag, using "Generate release notes".

Example:


All versions of dbdoctor with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
typo3/cms-core Version ^13.4 || ^14.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lolli/dbdoctor contains the following files

Loading the files please wait ...