Why you need to upgrade phpBB to version 3.2

A lot of forum owners are procrastinators. The current version of phpBB (as of this writing) is phpBB 3.2.3. If you are not on the phpBB 3.2 you should upgrade. Why?

Because in two months the group that manages the PHP programming language (which phpBB is written in) will stop supporting versions of PHP 5 with security fixes. This means after January 2019 you may be vulnerable to new exploits found in PHP 5, used by phpBB 3.1 and earlier versions.

It’s understandable why you might not want to upgrade your forum from your current version, generally phpBB 3.0 or 3.1. As most of my work is upgrading forums I see all the time why forum owners drag their feet. Reasons include:

  • Their forum has lots of mods and custom changes made over the years. With modifications not supported in phpBB 3.1 and higher, they have to figure out how to move forward. Many modifications do not have the equivalent available as extensions. So they either have to give up the functionality of the mod (which often makes forum users unhappy) or just procrastinate as long as possible. Procrastination is the easier approach.
  • Their forum has a style with lots of changes. Perhaps a logo has been integrated that is nonstandard, or they’ve made major changes to the templates and the stylesheets. Lots of styles haven’t been migrated to phpBB 3.2 either, so this is another issue they will have to deal with if they upgrade.
  • They know just enough PHP to be dangerous, so they’ve tweaked the code here and there to do special things. That would go away with an upgrade, or at least the cost of making changes to the base code gets more expensive. It’s heavily discouraged and makes upgrading or updating phpBB a pain, because you often have to reapply these changes. Custom changes can be done by writing a custom extension, but it’s a complicated thing to do. You need to be a very experienced PHP programmer to write an extension, and heavily study phpBB’s architecture and coding requirements.
  • Having someone like me upgrade your forum costs money.

Now that push has come to shove though, unless you are willing to bear the security risks, it’s time to finally make the upgrade. phpBB 3.1 users are not off the hook either, because this version of phpBB does not support PHP 7, the latest major version of PHP. I helped a client migrate their forum just yesterday to PHP 7. PHP 7 was installed on their new server. Certain things stopped working or created PHP notices.

Note that versions of PHP before 5.6 are already not patched for security issues. So if you are using an earlier version of PHP like PHP 5.2 (popular for phpBB 3.0 and 2.0) or PHP 5.3, 5.4 or 5.5 you are already at risk. You really can’t upgrade to PHP 7.0 as you will experience errors. Some phpBB 2.0 and 3.0 users have issues running PHP 5.6.

So now may be the time to take the plunge. Of course I can help you in this process. You may want to read my upgrade page. In addition to running the latest version of phpBB, I think you will find that once you are there it is worth the hassle. The extensions architecture of PHP 3.1 and higher is very nice, almost as nice as using WordPress plugins. The themes are responsive, so they look great on mobile devices. In addition, PHP 7 is about 50% faster than PHP 5, which is another great incentive to upgrade, particularly if you have performance issues with your forum.

You can send me a query if you want to discuss upgrading your forum.

End phpBB update styling rework with a custom style

Updated February 15, 2018 to add a few things.

Has this happened to you? You update phpBB to the latest version and find out that your custom logo or various style changes that you tediously made to phpBB are gone, or partially gone. It’s a common problem and one reason many forum owners defer updating phpBB.

You can end this hassle by creating and installing your own custom style. Using this approach your custom style inherits most of its styling from a primary phpBB style. You then selectively override the primary style’s CSS, HTML or Javascript with your own changes. This way when the primary style you use is changed, you don’t lose your custom changes. This also ensures that your styles and templates use the most current and approved code, which often includes security patches.

In this tutorial I will show how you can do this. I will keep my example simple by using my custom style to swap out the default phpBB logo with my own logo, sized to the new logo’s dimensions. In principle though you can go way beyond this simple use. For example, your custom style can overwrite the inherited style’s colors, padding and margins, or container widths and heights. You can also overwrite HTML and Javascript files.

Overview of steps required

The basic approach is:

  1. Make a note of all the changes you made to your style
  2. Reload your preferred style
  3. Create a custom style that inherits from your preferred style
  4. Override the preferred style’s stylesheet directives. This is best done by creating a stylesheet.css file for your custom style and placing your style customizations there.
  5. If you changed some templates, place the custom version of these templates in your custom style’s template directory. Frequently, forum owners will make changes to overall_header.html and overall_footer.html.
  6. Install the custom style
  7. Make the custom style the primary style
  8. Test and refine

Let’s delve into each step to see how this is done.

Make a note of all the changes you made to your style

You probably know what these changes are, but if you have any questions you can use a file comparison tool like WinMerge (for Windows) or kdiff3 (for pretty much any operating system) to compare your files with a reference version.

  1. Download your current style folder where you made all your custom changes, such as /styles/prosilver
  2. Download a reference version of your style for your current release of phpBB. phpBB keeps a list of its releases here. If your styles are based on prosilver then you would use the reference /styles/prosilver folder for your current release of phpBB. If using a different style, find the style version you used. You may have to download it from phpbb.com or from the style author’s website.
  3. Run the file comparison tool and note the changes you made so they can be reapplied in the custom style.

Reload your preferred style

  1. Make certain you have documented all the changes you made to your style. Once they are overwritten, you may not be able to recover them.
  2. Since you made changes to your preferred style, it’s a good time to undo them. The simplest way is to upload the reference version of your style, replacing anything that’s there. Purge the cache. If you don’t see the style changes afterward, clear your browser’s cache and reload the page.

Create a custom style that inherits from your preferred style

  1. First review phpBB’s Creating & Modifying Styles page.
  2. Create a folder in the styles folder for the name of your style. In this example I keep it simple and call the folder “custom”, i.e. /styles/custom.
  3. Create a style.cfg file in this folder. Copy the style.cfg contents from your parent style’s style.cfg file. Below is the code in /styles/prosilver/style.cfg for phpBB 3.2, which I used because my “custom” style inherits from prosilver.
#
# phpBB Style Configuration File
#
# This file is part of the phpBB Forum Software package.
#
# @copyright (c) phpBB Limited <https://www.phpbb.com>
# @license GNU General Public License, version 2 (GPL-2.0)
#
# For full copyright and license information, please see
# the docs/CREDITS.txt file.
#
# At the left is the name, please do not change this
# At the right the value is entered
#
# Values get trimmed, if you want to add a space in front or at the end of
# the value, then enclose the value with single or double quotes.
# Single and double quotes do not need to be escaped.
#
#

# General Information about this style
name = prosilver
copyright = © phpBB Limited, 2007
style_version = 3.2.0
phpbb_version = 3.2.0

# Defining a different template bitfield
# template_bitfield = lNg=

# Parent style
# Set value to empty or to this style's name
# if this style does not have a parent style
parent = prosilver
  1. In my example I changed “name = prosilver” to “name = custom”. Since I want to inherit from prosilver I left the “parent = prosilver” line unchanged. If you are changing a style other than prosilver as the primary style, you need to change the parent style to the correct style name. It must match the parent folder name in the styles folder. You might also want to edit the copyright, style_version and phpbb_version lines. If it’s only for your own use, this is not necessary. Here are my changes:
# General Information about this style
name = custom
copyright = © Mark D. Hamill
style_version = 1.0.0
phpbb_version = 3.2.2

# Defining a different template bitfield
# template_bitfield = lNg=

# Parent style
# Set value to empty or to this style's name
# if this style does not have a parent style
parent = prosilver
  1. Save the file, making sure it is in the root folder for the custom style, e.g.: /styles/custom/style.cfg.

Override the preferred style’s stylesheet directives

  1. Create a theme folder for your style. In my example, this would be /styles/custom/theme.
  2. Create an images folder inside the theme folder. In my example, this would be /styles/custom/theme/images.
  3. If changing the logo, upload the logo you will use to /styles/custom/theme/images. Make a note of the image’s height and width as you will need this later.
  4. Create a file called stylesheet.css in the theme folder.
  5. To inherit styles from your parent style, you need an @import statement at the top of this file. For example, if prosilver is the preferred style, this line would be at the top of the file. Generally you just need to reference the stylesheet.css file in the parent style. You will have to amend the path so it finds the parent style’s stylesheet files. In my case for the @import line, I added “../../prosilver/theme/”. The ?v=3.2 indicates the version of phpBB expected, so it may have to be changed.
@import url("../../prosilver/theme/stylesheet.css?v=3.2");
  1. Any style changes that you want to override should now be appended to the end of this file. In the example of replacing the logo, in the prosilver style you would normally edit the .site_logo class in colours.css and common.css. In my case I added these lines at the end of my /styles/custom/theme/stylesheet.css file, which provides the correct image to use for the logo and its proper dimensions:
.site_logo {
    background-image: url("./images/mark.jpg");
    width: 181px;
    height: 229px;
}
  1. I then saved the file stylesheet.css with my changes.

Changing templates

In my example, since I am only replacing the logo so no template changes were needed. If you need to change templates there are two approaches.

  1. The simplest is to copy the template, for example, /styles/prosilver/template/overall_header.html to /styles/custom/template/overall_header.html. Then make the changes that you need to make and save the file. This has a downside: if there are changes made to this template with an update, your version won’t have them unless you manually inspect for any changes and apply them to your custom version.
  2. In many cases you want to insert some HTML or Javascript rather than change existing HTML or Javascript. In this case it’s better to use template events, if you can “hook into” an appropriate event. This way if the parent style is changed with an update, you don’t have to worry about replicating any changes to it in your style. For example, overall_header.html has a template event in it marked as <!– EVENT overall_header_head_append –>. In this case you could create an event folder in your template folder then create a file called /styles/custom/template/event/overall_header_head_append.html. Add whatever HTML you want inserted when this event is encountered into this file. A list of template events can be found here.

Install the custom style

  1. ACP > Customise > Style management > Install Styles
  2. Select the new style you created (“custom” in my example) by pressing the corresponding Install style link.

Make the custom style the primary style

ACP > General > Board configuration > Board settings. Generally you set the default style to your new custom style, the guest style to your new custom style and you may optionally want to set the override user style option to Yes. Submit the form.

Test and refine

You should not need to purge the cache if you make any stylesheet changes. However, if you make subsequent changes to any templates first purge the cache then test.

Approach when upgrading

This approach is unlikely to work correctly when upgrading. An upgrade is when you go from one minor release of phpBB to another, such as from 3.2 to 3.3. You can of course go through the process of creating a new custom style again. As for updates, this should work.

Enjoy!

phpBB 3.2 Rhea, first look

I’ve been waiting for the dust to settle to study phpBB 3.2 (Rhea). It is scheduled for release on January 7, 2017. So I finally installed a prerelease version with presumably almost all the bugs fixed. Here’s my first look:

New features

There’s not much new or sexy about phpBB 3.2 compared with phpBB 3.1, but it depends on what you are looking for. New features include:

  • Support for emoji in posts. You can cut and paste or simply type your own emoji shortcuts into posts and the emoji will render. You can find a comprehensive list of emoji shortcuts here. For example, in a post you can enter :grinning: and a scalable grinning emoji should be rendered.
  • Supports PHP 7.1. PHP 7 is a quantum leap in speed for the PHP script processor. Most sites can expect a 100% improvement in how quickly PHP will parse and render code written in PHP.
  • Global announcements are no longer an administrator only privilege.
  • FontAwesome support. FontAwesome allows scalable vector fonts and icons, controlled by cascading stylesheets. For example, if you have a FontAwesome icon of an airplane, the icon will scale to size as you increase magnification on the page without losing detail. In addition, FontAwesome allows the size, color and shadow of the font to be changed on the fly using CSS … no jQuery magic required anymore.
  • New installer. This is backend stuff. Installing phpBB looks a bit different, and looks spiffier. Before I could it install, however, I first had to run PHP from the command line to kick off a run of PHP’s composer software. Composer is used to fetch the third party libraries that phpBB uses, presumably to get a current version of these libraries. Previously they were bundled into the phpBB archive you downloaded. It’s unclear to me if this is something you will have to do when phpBB 3.2 is released before it is installed. If so it will prove an obstacle to many casual forum administrators, since they may not be familiar with working from a command prompt and it may not be an option on shared hosting. The installer’s command line interface has also been reworked. I have not yet investigated what’s new here.

Other changes of note

  • The default prosilver style looks a little bit darker, and the icons have been reworked and look a bit different, and are seamlessly scalable because they will use FontAwesome.
  • No subsilver2 support. Someone developed a subsilver2 style for phpBB 3.1 but it was not responsive (scalable for mobile devices). With 3.2 only responsive styles are supported. subsilver2 uses HTML tables to layout content, which is not responsive, hence it is not supported.
  • The reCAPTCHA spambot countermeasure has been updated to use Google’s latest (presumably the checkbox where you assert you are a human). The old one had been hacked, so this is encouraging. Perhaps it will be useful as a spambot countermeasure again.
  • New events. This is only of interest to extension authors. They have more places in the code and in templates to hook in additional functionality.
  • BBCode overhaul. TextFormatter has been integrated into phpBB to render BBCode, making a lot of longstanding BBCode related bugs go away.

Some cautions

  • You should first upgrade phpBB from 3.1 to 3.2 before you change your web host control panel to use PHP 7. (Note: if you have other PHP applications installed, make sure they can handle PHP 7!)
  • You must run at least PHP 5.4 if you want to run phpBB 3.2, so this may require a web host control panel change. Make this change before upgrading phpBB.
  • While most 3.1 extensions will probably work fine in the 3.2 architecture, some will require changes if only to assert that they will work under 3.2. I have not tested my Digests and Smartfeed extensions with 3.2 yet, but I expect no issues. I will have to issue new versions since ext.php will have to allow phpBB 3.2 to be used.

phpBB 3.1 end of life support

  • The support forums on phpbb.com will provide support for phpBB 3.1 through the end of 2017.
  • New releases of phpBB 3.1 are expected as needed through July 2017. A phpBB 3.1.11 release is in the works.

Should you upgrade now?

In general it’s a bit dangerous to be first out of the gate when phpbb.com releases a new minor version of phpBB. Unless there is a compelling reason otherwise, I’d wait a few months before upgrading to 3.2 but if you use the prosilver style with no extensions it might be worth installing when available. Check your styles and extensions and make sure each supports 3.2 before upgrading, or be prepared to use a standard style and have incompatible extensions disabled.

If you would like me to upgrade you to 3.2 contact me. Most upgrades cost $30USD.

Upgrading and updating phpBB

(Post updated July 17, 2017 to reflect phpBB 3.2.)

In general, upgrading from a major version to another version (2.0 to 3.0, for example) or from a minor version to another minor version (3.0 to 3.1) is error prone and a hassle, particularly if you used shared hosting or are not technically inclined. In these cases you might want to contact me and have it done professionally.

The phpBB group has instructions for upgrading that are linked below:

Upgrades move you from a minor version of phpBB, such as 3.1, to another minor version, such as 3.2. Updates keep you on the same minor version but add patches and bug fixes, such as 3.2.0 to 3.2.1

There are many ways of updating phpBB 3.2 to a newer version of 3.2. The phpBB group suggests the automatic update package. I disagree. It is faster and simpler to use the changed files method. This is because the automatic update package involves the hassle of telling phpBB how to use FTP and setting various file permissions. In addition, I have found it error prone.

Here is how I upgrade clients easily with the changed files method:

  1. I back up the forum’s database locally using the Administration Control Panel, Maintenance tab.
  2. I make a file backup of the phpBB directory, usually using the web host control panel file manager. This is an extra precaution but is probably not necessary if you are careful with the remaining steps. Select all files and directories in the phpBB root folder and select the compress option. Give the file an easy to remember name like forum_files_backup_before_upgrade_to_3.2.1.gz. Store it wherever you want on your web host or download it, just make sure you don’t accidentally delete it.
  3. I download the changed files archive for the current version of phpBB.
  4. Once downloaded I expand (uncompress) the archive. Inside are more archives showing the changed file for each micro version. For example, when downloading the 3.2.1 archive you will find phpBB-3.2.0_to_3.2.1.zip archive. I’ll expand that. It will create a directory called phpBB-3.2.0_to_3.2.1. You should expand the archive for your current version of phpBB, which you can find on the main Administration Control Panel web page.
  5. I go into this folder. This contains all the files that have changed from that version to the newest version. Be careful not to accidentally delete the following:
    1. config.php
    2. files folder
    3. images folder
    4. store folder
  6. Carefully use FTP to upload these to your phpBB root folder using FTP. File folders should match. For example, if there is an adm folder in the archive there should be an adm folder in the directory you are uploading to, your phpBB root directory. You will overwrite the old files, which is fine because they have been improved to add features and fix bugs.
  7. Inside the main archive is an install directory. I upload that to the phpBB root folder.
  8. Inside the main archive is also a vendor directory. I upload that to the phpBB vendor folder, overwriting whatever is there.
  9. For upgrading to phpBB 3.2, change the URL to the install folder, ex: http://www.myforum.com/phpbb3/install. Click on the update tab. Select the option to update the database only.
  10. For upgrading to a newer version of phpBB 3.1, run the program install/database_update.php, ex: http://www.myforum.com/phpbb3/install/database_update.php.
  11. After completion, I delete the install folder using FTP.

That’s it, you are done.

If for some reason something is not working correctly, you just recover your files and database since they are backed up. You may need to manually clear the contents of the phpBB cache folder with FTP.