Non-static method cannot be called statically: fix
Non-static method cannot be called statically means code invokes a method in a way that does not match its definition.
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.
More about this
This may become visible after moving to PHPPHP is a programming language that builds your web pages on the computer that hosts your site, just before they reach the visitor. WordPress runs on it. 8.
Save the complete message, including the class and method names.
The developer can then compare the call with the code that actually provides the method in the running application.
Before you start
Save the complete error line and its timestamp in a private note. Record the action that failed, the current PHP versionA PHP version is a numbered edition of PHP, like 8.3. Each edition is looked after for a limited time, then gets security fixes only, then nothing. and any components updated at the same time. Share only information needed for the investigation.
Public support forums are not suitable places for customer details, access credentials or complete server paths.
Back up both files and the database before making changes. Check that the backupA backup is a separate copy of your website's files and database, so you can bring the site back after a mistake, a hack or a failed update. is usable. Work on a restricted test copy with the same PHP version and relevant settings.
Disable real payments and outgoing customer emails there. Agree who will make the change and who will check the result. These steps are an investigation guide, not a diagnosis of your particular website.
What changed? A method is a function belonging to a class. A non-static method is used in the context of an object.
The PHP manual says that calling non-static methods statically raises an Error. Before PHP 8.0, this was reported as deprecatedA deprecation is an early warning that a feature still works today but will be removed in a future PHP version, so code using it must be changed in time. behaviour. The problem therefore concerns how the method is called, not just whether its file exists on the server.
Choosing the correct repair
Do not blindly add static to the definition. The manual explains that the object reference $this is unavailable inside a static method. Ask the developer to establish whether the method requires data from an object.
If it does, its call needs the appropriate object context. The application's design determines the correct repair; the error text alone cannot make that decision.
Five steps to a repair
- Save the class, method, file and line number from the log. Record the action you performed. A failed administration task may use a different calling route from a publicly accessible page.
- Compare the definition with the call. Check that both files come from the expected release. Ask whether a pluginA WordPress plugin is an add-on you install in WordPress to give your site extra features, such as contact forms, SEO tools or a webshop. and its companion extension were intended to be updated together as a compatible pair.
- Describe the information the method needs. Does it belong to a specific order, user or setting? Have the developer determine how to obtain the correct object without skipping any required initialization.
- Test the chosen change with two different test objects. For example, use two invented orders with different totals. This helps reveal whether the method uses the correct information for each individual result.
- Repeat the original route and inspect the visible result. Include a relevant background task if it uses the same method. Record separately which routes worked and which have not yet been checked.
A practical check
Imagine a method generating an order summary. Write down the expected lines and totals for two invented orders. Generate both summaries and compare them individually.
Merely checking that a file appears is insufficient: its contents must also belong to the correct order. This is a suggested acceptance scenario, not a description of your software. It helps the developer assess the repair against actual behaviour instead of only looking for a quiet error logAn error log is a file where your website's software writes down what went wrong, with the time and place. It is the first thing to check when a site breaks..
Getting help and checking the repair
Use the help form below if you cannot access the logs or do not know who maintains the affected code. Describe one failed action and the expected result. Ask for a proposal that separates the cause, the change and the acceptance check.
Do not include passwords with your request.
After the repair, repeat the original action on the test copy. Also check a normal visitor journey, an empty result and invalid input where relevant. Review fresh log entries at the new test time.
Keep versions and outcomes in your maintenance notes. Let the responsible administrator decide when the tested change can be applied to the live website.
Choosing the next step
Use the links below this article to choose the next step. The PHP update page helps you discuss maintenance with the administrator. The Exposure Check is a separate public check; do not treat its result as evidence that this programming error is repaired.
Use the status page for current security information. Keep the repair of the visitor action and the assessment of the server as separate checks in your notes. When requesting help, include the error text, the failed action and the expected result, but no passwords.
Ask for one responsible person to oversee both the change and its acceptance.