Website Without PHP
English (United States)US
  • English (United States)
  • Dutch (Netherlands)
Menu

Last updated:

Which PHP version does your site report?

We read only what your site already sends in public: the headers and the top of the homepage. No scan, no login.

Fix Cannot modify readonly property in PHP

Get help with your website

Error

What the message means

Cannot modify readonly property means code tried to change a readonly property after initialization. PHP rejects that write. Record the named class and property.

For example, investigate why an order object receives a different value after creation. The message does not establish a database connection failure or identify a particular WordPress plugin.

Before you change anything

Save the complete error line and its timestamp in a private note. Record the failed action, the active PHP version and any components updated at the same time. Do not post passwords, customer details or full server paths in a public support forum.

Back up both files and the database before making changes. Check that the backup can actually be restored. Use a protected test copy with the same PHP version and relevant settings, with real payments and outgoing customer emails disabled.

Expose the second assignment

A small developer example is: class Label { public function __construct(public readonly string $code) {} } $label = new Label('A'); $label->code = 'B';. The final assignment produces the error. Assigning 'A' again is not a permitted way to initialize that object a second time either.

If a new label needs code 'B', a separate object can be created: $new = new Label('B');. The first label remains 'A'. This illustrates intentional replacement, rather than recommending readonly for every property.

The developer still needs to establish which instance the rest of your application should use and where that replacement is allowed.

Trace the failing operation

Start at the failing assignment and locate the earlier assignment to the same object. Ask the developer to compare the two call paths. Establish whether the object represents a fixed record, such as the address on a placed order, or an editable form.

That decision defines the behavior the repair must preserve.

Avoid removing readonly from a supplier class simply to hide the error. Discuss whether the caller should construct a new object or stop initializing an existing one twice. For an import, inspect whether the same input row is submitted again.

Keep a small example using invented records so the maintainer can follow the writes without customer data.

Five steps to repair

  1. Record the class, property and failed action. On the test copy, identify both assignments to the same object instance.
  2. Decide whether this value may change after creation. Write down the expected website behavior before choosing a code change.
  3. Have the code owner repair the repeated assignment. Preserve the protections on unrelated properties while making this targeted change.
  4. Test creation, reopening and the permitted edit separately. Include a repeated import using the same invented input record.
  5. Compare the stored value with the expected result. Inspect fresh errors and record which existing objects must remain unchanged.

A concrete acceptance test

Use a test order with a delivery address. Agree whether an address edit applies only to future orders or also to that order. Perform both operations and compare the original address, replacement address and confirmation shown on screen.

A page loading successfully is insufficient if it saves the wrong address. Keep this acceptance example with the repair so the next update can repeat it.

Updating WordPress or WooCommerce components

If the error points to a plugin or theme, first check whether its author documents a relevant update. Record the installed version before trying that update on the test copy. Include any custom extensions that depend on the component in your checks.

Avoid editing supplier files without an agreed maintenance plan. A later update can overwrite a manual repair. For custom code, ask for a change that is kept with the source code and can be tested again during the next PHP update.

When to ask for help

Use the existing PHP update service if you cannot trace the error or if it affects orders, payments or saved records. Describe the failed action and the expected result in the help form below. An error message alone does not identify which component needs to change.

Check your PHP version

Use the Exposure Check link below this article to check your PHP version where it is publicly visible. If that information is unavailable, ask your host to confirm the active version. This check cannot read private logs and does not prove that the programming error is fixed.

Visit the PHP security status page for the separate assessment of your PHP version. Save the versions, code change and test outcome in your maintenance notes. Let the responsible maintainer decide when the tested repair should be applied to the live website.

Frequently asked questions

Should readonly be removed from the class?

Only after reviewing the data model. First establish why the property is written again and which changes the website is supposed to permit.

Can the mini-check prove this cause?

No. A public check does not replace investigation of private logs and server settings. Use the error message and failing action as the starting point.

When is the repair complete?

When the original action produces the correct result and fresh logs show no recurrence. Keep the versions and test result in your maintenance notes.

Sources

Accessed on November 17, 2026.

  1. Domain
  2. Check
  3. Result
  4. Report

Which PHP version does your site run?

Enter your domain. We read only what your site already sends in public: the headers and the top of the homepage. No scan, no login.

We keep the domain and the result, never your IP address.