Some of the users of our templates and modules have experienced an error in both Joomla 2.5 and Joomla 3 installations that occurs when PHP on their server is set to strict error reporting (E_STRICT) where they receive error messages stating that “Strict Standards: Non-static method … on line XX”, or similar.
If you’ve got the error-reporting mode of PHP set to strict also, you may find yourself running into similar messages frequently, especially after installing a quickstart package (that is, a full install of Joomla including a template, modules and database content to match a demo layout) or when browsing the front end of a Joomla site that has modules installed. Naturally, if you’re seeing this error mainly when there are modules installed on the page you’re visiting it’s reasonable to assume that the modules are the problem, but in fact the root cause of this issue is with PHP and how it works, so it will affect not only modules, but pretty much any Joomla extension or template that uses PHP.
Why do I see this message?
If you’re seeing this message often, then it’s very likely that in your server’s php.ini file the current settings include the line “error_reporting = E_ALL | E_STRICT”; what this means is that the system is reporting errors as plain notices. This is an issue, since often what’s considered an ‘error’ by PHP may in fact just be a warning, or reminder to the average user. For example, if you use a modern email client you might get a message if you write the word “attach” or “attached” in an email without actually attaching something to it; it’s a helpful little message to remind you that perhaps you’ve missed something. Strict Error Reporting would turn that simple reminder into a full-blown error, making it seem like something has gone wrong when it hasn’t, really. In fact, the E_STRICT flag is usually put to use by developers to help troubleshoot their products; they need to be aware of every small detail when creating something efficient and stable, but it’s overkill for regular users who are more interested in things working smoothly, and actually considered bad practice for “live sites”.
To Summarize: Essentially, Strict Standards warnings are not errors; they’re messages designed for developers to help troubleshoot their software and such messages don’t need to (and it’s recommended that they shouldn’t) be enabled on a production site.
How to remove the Strict Standards message?
Now, when we say “remove”, what we’re actually saying is “hide”; the cause of the message will still exist, but it’s almost always irrelevant since it’s just the equivalent of a reminder message rather than a true error that needs fixing. There are a few methods for taking care of this:
Method #1: Using Joomla’s settings
Joomla itself has some built-in functionality for controlling server settings, which are virtually the same in both Joomla 2.5 and Joomla 3; if you’re using Joomla 2.5:
- Login to your Joomla backend as super administrator.
- In the main menu select Site -> Global Configuration, then click on the “Server” tab and look for the Error Reporting parameters (these options should appear in the “Server Settings” group).
- Set the Error Reporting setting to “None” and click on “Save” to store the changes.
If you are running Joomla 3 the method’s the same, but there’s a slight difference in the menu layout:
- Login to your Joomla site’s admin panel as an administrator account, then click on System -> Global Configuration in the main menu.
- On the configuration screen, click on the “Server” tab and look in the Server Settings option group for the Error Reporting parameter.
- Change Error Reporting to “None”, and save changes.
With the changes saved head on back to the frontend of your site and see if you’re still getting the messages; hopefully they should have all disappeared. If not, it means you’ll have to go a bit deeper and directly modify the server’s php.ini file manually. This isn’t a particularly difficult task, but it’s still advisable that someone with web development experience handles this change as any mistake made when editing the file could have rather severe consequences for your site, since PHP is at the core of Joomla and its extensions and templates. So play it safe and get help if you’re not comfortable making this change yourself!
Method #2: Changing php error reporting on the server side (php.ini)
If you’ve tried disabling Strict Standards via Joomla without success, or you’re looking to cut the issue off directly at the source, then you can also disable Strict Standards on your server via the php settings, which are stored in the php.ini file. This file is usually found in the root folder of your server, so you’ll need to connect to your site via FTP. Once there, find and open your php.ini file with the editor of your choice. There’s usually quite a few options listed here, but the specific one you’re looking for is the error_reporting attribute. Once you’ve found this line you’ll have to replace this attribute with the following code:
error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED
…and then saving the changes and uploading the modified file back to its original location.
Warning: If after making this change you find that you’re getting another error such as a 500 Internal Server Error (aka HTTP 500 error), then you should contact with your host’s support team who will be able to provide you with details on how and where to override the php.ini file, since some hosts are quite protective of this file due to how necessary it is for smooth server operation. Once they advise you of their preferred modification method you can check it and try making the change once again.
Method #3: Modifying the template file
There’s another, last-ditch method for taking care of this issue if for some reason you are unable to use the above methods, or if you’re not permitted to change the php.ini file and can’t contact your host’s support network. In this case you will be modifying some of the core files of the template you’re using for your site. Once again you’ll need to use FTP for this change since you’re modifying the core template files rather than the standard settings. Once connected to your server, assuming you are using one of our own Joomla templates you should navigate to the layout folder of the template folder, which is usually found in the templates folder of your Joomla installation. As an example, the path to the folder will usually be something like templates/gk_TemplateName/layout/. In this folder you’ll find a default.php file; open this with your chosen editor and add this line at the top of this file right after the “<?php” line:
To be doubly-sure of success, you can also try adding this code to the file also:
ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED); ini_set('display_errors','Off');
Once done, save the changes and reupload the file back to its original location. You should now be error-free and can get back to more important things like building your website content! If you find that you are still encountering issues even after these fixes, then it may be that there’s something more going wrong under the server’s hood, and you should get back in touch with your host’s customer service team who will surely be able to help you locate the source.