Skip to content

PHP8 upgrade follow-ups - #18

Merged
timwoj merged 4 commits into
masterfrom
topic/timw/php8-follow-ups
Sep 26, 2025
Merged

PHP8 upgrade follow-ups#18
timwoj merged 4 commits into
masterfrom
topic/timw/php8-follow-ups

Conversation

@timwoj

@timwoj timwoj commented Sep 25, 2025

Copy link
Copy Markdown
Member
  • Fix a repeated deprecation warning in debug.log related to the last-minute upgrade to Cake 5.4.
  • Bump the PHP container to PHP 8.4. We moved up to 8.1.33 in the original upgrade, but it's going to be end of life in December. Upgrading to 8.4 doesn't change anything about the site, so it's safe to just upgrade the containers.
  • The Markdown canonifier was rewriting relative links on Github to be absolute links, but this doesn't work for images since it's linking to the page in the repo and not to the actual content. Fix this so it rewrites the links to raw.gtihubusercontent.com instead, which is where the content lives.
  • Fix markdown conversion of tables, which I hadn't noticed on a couple of packages. This also sets the Boostrap class on generated tables so they're styled correctly.

This fixes a big block of warnings in the log when running in debug mode
According to https://endoflife.date/php, PHP 8.1 goes EOL in Dec 2025.
Might as well jump to the latest version. Nothing seems to change
code-wise because of the move.

@ckreibich ckreibich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few questions and perhaps nits re. comment wording.

if (strcasecmp(parse_url($url, PHP_URL_HOST), "github.com") == 0) {
/* If the URL passed is to github.com, replace it with
* with the raw.githubusercontent.com hostname so that it can
* load the actual image instead of the repo page for the image.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code runs for anything we render, not just images, right? I seem to recall coming in here to figure out how to grab the README.

@timwoj timwoj Sep 25, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, yes it does. I guess that could break if someone had a link to something on Github from their README and wanted to link to the GH repo view. It would require changes to the block below that too to keep the /blob/ part of the URL.

function ($matches) use ($raw_url) {
if (empty(parse_url($matches[1], PHP_URL_SCHEME))) {
return "](" . $url . "/blob/main/" . $matches[1] . ")";
return "](" . $raw_url . "/master/" . $matches[1] . ")";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just curious here how you came up with this? I can confirm it seems to work e.g. for https://raw.githubusercontent.com/zeek/hello-world/master/README.md (which has main as default branch). The default Github serves up when grabbing the raw page is https://raw.githubusercontent.com/zeek/hello-world/refs/heads/main/README.md.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was fighting this with loading one of the images, because it kept telling me it was a 404 when we were rewriting it with main, so I tried the other way around and rewrote it with master. That surprisingly worked instead. Looking at their documentation, they actually special-case master to redirect to whatever your default branch is defined as: https://github.blog/changelog/2020-07-17-links-to-deleted-branches-now-redirect-to-the-default-branch/.

I believe the same exists for refs/heads/master vs just master, but I don't have any documentation to prove that. As for the removal of the /blob/ part, that's only needed if you're looking at the image in the repo view on Github (e.g. https://github.com/esnet/zeek-exporter/blob/master/imgs/func_times.png). If you're looking at the image itself via raw.githubusercontent.com, that part of the URL isn't needed.

@ckreibich ckreibich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tim. Looks good to me, just a suggestion on the image filename extensions.


if (strcasecmp($extension, "jpg") == 0 ||
strcasecmp($extension, "jpeg") == 0 ||
strcasecmp($extension, "png") == 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe throw in gif and webp?

@timwoj
timwoj force-pushed the topic/timw/php8-follow-ups branch from 36090a6 to fd84989 Compare September 26, 2025 02:53
@timwoj
timwoj merged commit ee3555d into master Sep 26, 2025
1 check passed
@timwoj
timwoj deleted the topic/timw/php8-follow-ups branch September 26, 2025 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants