Pro 6.9.5: front-end fatal error

After updating to Pro 6.9.5 today, several of my sites show “There has been a critical error on this website” on the front end. wp-admin still works. Rolling back to the previous Pro version fixes it, and re-updating to 6.9.5 breaks it again. Switching to a default WordPress theme also clears it, and it happens with the Pro parent theme active and no child theme.

Environment: Ubuntu 24.04, PHP 8.3 (PHP-FPM), Font Awesome Load Type set to SVG in Theme Options.

Fatal error:

Uncaught TypeError: array_flip(): Argument #1 ($array) must be of type array, null given in wp-content/themes/pro/cornerstone/includes/classes/Services/FontAwesome.php:275

Stack trace (abridged):
#0 FontAwesome.php(275): array_flip()
#1 cornerstone/includes/functions/helpers.php(786): Themeco\Cornerstone\Services\FontAwesome->getIconFromUnicode()
#2 cornerstone/includes/functions/helpers.php(794): cs_fa_get_icon_from_unicode()
#3 framework/legacy/functions/icons.php(20): cs_fa_icon_tag_from_unicode()
#4 framework/legacy/functions/icons.php(69): x_icon_get()
#5 x_site_jsdata filter
#7 framework/legacy/functions/frontend/scripts.php(33): apply_filters(‘x_site_jsdata’)
#8 x_enqueue_site_scripts() on wp_enqueue_scripts

Cause: In FontAwesome.php, the icon data is lazy-loaded by ensureData(). resolveFontAlias(), getFontIcons(), getFontIds() and getFontIconsData() all call $this->ensureData() before reading $this->data. getIconFromUnicode() does not:

public function getIconFromUnicode($unicode) {
static $flippedIcons = null;

if (empty($flippedIcons)) {
  $flippedIcons = array_flip($this->data['icons']);
}
...

cs_fa_icon_tag_from_unicode() only calls getIconFromUnicode() when x_font_awesome_icon_type is “svg”. The x_site_jsdata filter in legacy/functions/icons.php calls x_icon_get() on every front-end request during wp_enqueue_scripts. If nothing earlier in the request has loaded the icon data, $this->data is null and the page fatals. That would explain why some of my SVG-mode sites on 6.9.5 break and others don’t.

Fix: Adding one line at the top of getIconFromUnicode() resolves it. I confirmed this on an affected site.

public function getIconFromUnicode($unicode) {
$this->ensureData();
static $flippedIcons = null;
…

Note: the fatal is not written to the PHP error log on my servers (only earlier warnings are). I captured it with error_get_last() in a shutdown function.

2 Likes

I will release a hotfix in Pro 6.9.6. Thanks for sending this our way. Have a great day.

1 Like

Thanks @charlie!

1 Like

You are most welcome @simeoned