New guidance on phpBB and system crons

A recent release of my digests extension revealed underlying problems not only in the extension, but also on guidance I’ve been giving for setting up phpBB and system crons. I can’t seem to edit the Wiki page, but I left notes on my digests extension discussion forum. I need to place them here for wider visibility. I will update the Wiki page when that technical issue is resolved.

With my digests extension, it’s generally important for digests to be mailed on time. Otherwise it depends on board traffic to send digests, which on sites with low traffic could result in significant delays in receiving digests.

There are two ways to do this in an automated way:

  • Create a system cron
  • Use a phpBB cron, but use a tool to call the board at least hourly, which kicks off phpBB’s cron process, which includes handling any scheduled outgoing digests

With a system cron, it turns out that you can’t use a semicolon to separate commands on one line in most cases. So this guidance is wrong in most cases. It all depends on the Linux shell used by the root user, which is usually bash. So when programming a cron job, to get two commands to work on one line, you need this instead:

cd /path/to/board && ./bin/phpbbcli.php cron:run

The && acts as a conditional, essentially saying that if the command to the left of the && succeeds, then issue the command to its right.

On my test board I also discovered I had to change the permissions on the /bin/phpbbcli.php program to 755, as the cron needs the execute permission, and it’s lacking with 644 permissions. This is not ideal as this introduces a potential security issue. Considering it’s just one file, I consider the security implications minor at best. With a system cron, you need to program a real cron job and tell phpBB to not use its built in cron based on board traffic: ACP > General > Server settings > Server settings > Run periodic tasks from system cron > Yes

If you want to use phpBB’s built in cron, you need to call it at least hourly and create a cron using curl, wget or lynx to hit your phpBB board as if it were a browser. If you follow the Wiki approach it causes a HTTP redirect, which basically causes it to fail. So the cron should look more like this (all on one line):

* * * * * curl -k -A='Mozilla/5.0' https://www.yourforum.com/board/app.php/cron/cron.task.cron_task

The key here is to use app.php in the cron, to avoid the redirect.

April 2020 work summary

The number of clients I served in April dropped compared to earlier month. Last year April and May were slow too. However, I had one well paying commercial job that more than paid the bills, and should continue to do so for many months to come. It’s nice to have steady work in tough economic times. It will take a few more months to see if the economic crisis is affecting the overall customer requests I get.

This month I also discovered some new information on doing crons properly in phpBB not covered in the Wiki, but I can’t seem to change the information in the Wiki because logging in no longer works. This can affect my digests extension which can use a cron to send out digests. I’ve also started work on a spam remover extension, that will remove spam posts and private messages using the Akismet web service. Hopefully I’ll have something to show this month.

Work on my book continues at a slower pace. I’ve done two more read throughs of it, finding errors and corrections and am now on what I hope is the final read through. I’ve changed the book size to 7.5 inch by 9.25 inches, the standard size used for Dummies books. As there are lots of screenshots, it was important that they be legible. We’ll see how it goes. Hopefully I can release it this month. I still need a cover illustration.

  • I upgraded a board from phpBB 3.0.14 to 3.3.0. As part of this, I also upgraded PHP to 7.2.29. The board has 408,000 posts. Added extensions: Google Analytics, Precise Similar Topics and Topic Preview. There were issues installing extensions. For two extensions, I had to create a module category suggested by the error message first. These were installed as mods on phpBB 3.0, so that was likely the cause. The Google Analytics extension wouldn’t install using my Vivaldi browser, but would using Firefox. Go figure. I disabled the contact page, set up reCAPTCHA V2 Invisible spambot countermeasure, and created a home link. I had to make myself a founder using the database. Installed the Anime style and its extension. I investigated upgrading MariaDB to a newer version, but it requires command line instructions. A few days later I fixed an issue that brought down board by removing trailing comma from allowed_schemes_links configuration variable using MySQL and manually purging the cache. I turned this is a phpBB problem report, documented here, which looks like it will get fixed in phpBB 3.3.1.
  • Earlier, I attempted an upgrade to phpBB 3.3.0 that I had to roll back because the host (Network Solutions) didn’t have a PHP version you could select greater than 7.0! Unbelievable! Upgraded and reenabled the ShareOn extension and installed Thanks for the Posts extension.
  • I added new audio control to a board that features a streaming music player, since the old service seemed to go defunct. Some testing with the provided audio players, which were too big on the board’s header, resulted in a simple link to the music service instead, that opened in a new window.
  • Placed a new ad at top of page using Advertisement management extension. This included uploading a new ad image. I disabled the old ad.
  • I attempted to add Facebook tracking code to a custom style. I copied overall_header.html template from the AllanStyle-SUBSILVER template folder and made changes in the custom style. I tried purging the cache multiple times but the code never appeared. I even rebooted the web server. Eventually, I figured out the underlying reason was that the block of code I added was placed inside a S_ALLOW_CDN statement, before the <!– ENDIF –> statement, and since the template switch wasn’t getting executed the Facebook tracking code wasn’t getting added.
  • For my commercial client so generous to pay me my commercial rate, I spent much of the month working on this project. In March, I made an unsuccessful attempt to upgrade a test version of the database. The client made a new version of the old phpBB 3.0.11 database that was better sanitized, tried again and eventually succeeded. To convert the database, I need a PHP 5 environment, so it was hard to do on their server so I had to do it on my machine in a virtual machine, and that added time and hassle. I then began to try to retrofit the styling to make it look as close as possible to the existing styling. This meant hiding certain features and disabling others. The old styles used the Bootstrap framework and SCSS. The idea is get away from Bootstrap since styles are now responsive in phpBB, but it’s easier said than done, but otherwise keep the SCSS. Went through two iterations for client feedback, and there will likely be a couple more. In some cases I am using extensions to replace functionality, like the Board Announcements extension to see general text on the index. This is pretty challenging work and should keep me well employed probably through the end of the year. Likely in May I will be doing mostly styling work. I am using a custom style, inheriting from prosilver, to minimize the impact of future updates to phpBB. When the styling is done, there will be extensions to write to incorporate lots of additional functionality.

Edit subscribers bug fix

If the edit subscribers feature of digests is not working for you, except possibly the pagination feature, you are not alone. I haven’t had any issues with it in my development or test environments, but others have. Anyhow, there is now a solution if this is happening to you which is described in this post.

The fix will be rolled out in the next release of digests, version 3.2.16 which is in development.

Update October 10, 2019: According to this poster the <form> tag needs to have the novalidate attribute set as well. This post describes how this template can be appropriately changed.