Skip to content

v2.3.1 — Hotfix: 500 on shortlink hits with the plugin enabled

Choose a tag to compare

@toineenzo toineenzo released this 26 Apr 00:10

A small but important hotfix on top of v2.3. Anyone running v2.x should upgrade — every shortlink visit was 500'ing as soon as the plugin was active.

🐛 Fix

TypeError on every shortlink visit

Visiting any short URL (https://your-yourls/<keyword>) returned an HTTP 500 with this PHP fatal in the error log:

Uncaught TypeError: lfp_handle_pre_load_template():
  Argument #1 ($request) must be of type string, array given,
  called in includes/functions-plugins.php on line 222
  and defined in user/plugins/yourls-link-front-page/plugin.php

YOURLS' yourls_do_action() always pushes its single payload onto an internal $args array before dispatching, so action callbacks receive a one-element array (['site']), not the bare scalar ('site'). Our lfp_handle_pre_load_template() and lfp_handle_loader_failed() were typed string $request and PHP 8.4 fatal'd on the type mismatch.

The bug was latent in the codebase since v1.0.1 (where the two extra hooks were added) and only became fatal because PHP 8.4 enforces argument types on internal callbacks more strictly than 8.0/8.1 did. v2.3.0 didn't change those handlers — the live site just happened to be on a PHP version that had only warned before.

How it's fixed

  • Both signatures are now mixed $request so PHP doesn't complain about the array.
  • A new lfp_unwrap_action_arg() helper peels the scalar back out of YOURLS' wrapper array (is_array($arg) ? $arg[0] ?? '' : (string) $arg) so the rest of the routing code keeps a plain string.

✅ Verified

URL Status
/ (homepage) 200 + X-LFP-Rendered: 1
/<keyword> (any shortlink) 301 redirect — works again
/login (configurable) 302 → /admin/
/contact.vcf?type=... 200 with vCard 3.0 (or 404 if no contact configured)

⬇️ Installation

cd /path/to/yourls/user/plugins
rm -rf yourls-link-front-page
unzip /path/to/YOURLS-Link-Front-Page-2.3.1.zip

…or git pull if you cloned the repo. No database changes.

Full changelog: v2.3.0…v2.3.1