You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With activated Gutenberg plugin, when an SVG file is selected as the website logo AND the size of it is altered (effectively: once it is set to an explicit value) in the block's options, the website fails to load but only shows an HTTP 500 error instead.
Steps to Reproduce
Use a block-theme (I guess any block theme; i could reproduce with twenty twenty-two).
In the full page editor (Gutenberg), choose an SVG file as the website logo.
Set a custom image width in the block options of the logo.
Save the theme.
Navigate to the website.
An error message will appear.
Expected behavior
The page should display without error.
Screenshots
Environment information
Device: PC with Linux
OS: Gentoo Linux
Browser and version: Mozilla FIrefox 95.0.1 (64-bit)
Apparently, $image[1] and $image[2] are both unset (or false), which results in a division by zero, but only if the width was manually altered (and therefore $attributes['width'] is not empty.
They get set to false by the Safe SVG plugin (safe-svg/safe-svg.php, lines 226ff.):
/** * Filters the image src result. * Here we're gonna spoof the image size and set it to 100 width and height * * @param array|false $image Either array with src, width & height, icon src, or false. * @param int $attachment_id Image attachment ID. * @param string|array $size Size of image. Image size or array of width and height values * (in that order). Default 'thumbnail'. * @param bool $icon Whether the image should be treated as an icon. Default false. * * @return array */publicfunctionone_pixel_fix( $image, $attachment_id, $size, $icon ) {
if ( get_post_mime_type( $attachment_id ) == 'image/svg+xml' ) {
$image['1'] = false;
$image['2'] = false;
}
return$image;
}
A trivial fix would be to set $image[1] and $image[2] to 100 instead of false, but I have no idea what (possibly negative) side effects that could cause.
I guess it also depends on the order in which the filters are registered (gutenberg-first vs. safe-svg-first).
Lastly, a fix could also be made in the Gutenberg plugin: only perform the calculation if $image[1] and $image[2] are both set to non-zero numerical values. But I assume it is very unusual for these values to be 0 in the first place, so I wouldn't count on the Gutenberg developers to be overly enthusiastic about implementing such a fix in their plugin.
The text was updated successfully, but these errors were encountered:
fritteli
changed the title
HTTP 500 error in combination with Gutenberg plugin when website logo is an SVG file
HTTP 500 error in combination with Gutenberg plugin when website logo is an SVG file with custom dimensions
Dec 31, 2021
Describe the bug
With activated Gutenberg plugin, when an SVG file is selected as the website logo AND the size of it is altered (effectively: once it is set to an explicit value) in the block's options, the website fails to load but only shows an HTTP 500 error instead.
Steps to Reproduce
Expected behavior
The page should display without error.
Screenshots
Environment information
WordPress information
Site Health info:
` ### wp-core ###version: 5.9-beta4-52422
site_language: de_CH_informal
user_language: de_CH_informal
timezone: Europe/Berlin
permalink: /%year%/%monthnum%/%day%/%postname%/
https_status: false
multisite: false
user_registration: 0
blog_public: 0
default_comment_status: open
environment_type: production
user_count: 1
dotorg_communication: true
wp-paths-sizes
wordpress_path: /home/manuel/public_html/wordpress-beta
wordpress_size: 49.20 MB (51591651 bytes)
uploads_path: /home/manuel/public_html/wordpress-beta/wp-content/uploads
uploads_size: 50.72 kB (51937 bytes)
themes_path: /home/manuel/public_html/wordpress-beta/wp-content/themes
themes_size: 31.04 MB (32552997 bytes)
plugins_path: /home/manuel/public_html/wordpress-beta/wp-content/plugins
plugins_size: 18.80 MB (19713278 bytes)
database_size: 3.92 MB (4112384 bytes)
total_size: 103.02 MB (108022247 bytes)
wp-active-theme
name: Twenty Twenty-Two (twentytwentytwo)
version: 1.0
author: the WordPress team
author_website: https://wordpress.org/
parent_theme: none
theme_features: core-block-patterns, widgets-block-editor, post-thumbnails, responsive-embeds, editor-styles, html5, automatic-feed-links, block-templates, wp-block-styles, editor-style
theme_path: /home/manuel/public_html/wordpress-beta/wp-content/themes/twentytwentytwo
auto_update: Deaktiviert
wp-themes-inactive (12)
empowerment: version: 0.0.1-dev, author: Manuel Friedli, Automatische Aktualisierungen deaktiviert
Twenty Eleven: version: 3.9, author: the WordPress team, Automatische Aktualisierungen deaktiviert
Twenty Fifteen: version: 3.0, author: the WordPress team, Automatische Aktualisierungen deaktiviert
Twenty Fourteen: version: 3.2, author: the WordPress team, Automatische Aktualisierungen deaktiviert
Twenty Nineteen: version: 2.1, author: WordPress-Team, Automatische Aktualisierungen deaktiviert
Twenty Seventeen: version: 2.8, author: dem WordPress-Team, Automatische Aktualisierungen deaktiviert
Twenty Sixteen: version: 2.5, author: the WordPress team, Automatische Aktualisierungen deaktiviert
Twenty Ten: version: 3.5, author: the WordPress team, Automatische Aktualisierungen deaktiviert
Twenty Thirteen: version: 3.4, author: the WordPress team, Automatische Aktualisierungen deaktiviert
Twenty Twelve: version: 3.5, author: the WordPress team, Automatische Aktualisierungen deaktiviert
Twenty Twenty: version: 1.8, author: WordPress-Team, Automatische Aktualisierungen deaktiviert
Twenty Twenty-One: version: 1.4, author: the WordPress team, Automatische Aktualisierungen deaktiviert
wp-plugins-active (2)
Gutenberg: version: 12.2.0, author: Gutenberg Team, Automatische Aktualisierungen aktiviert
Safe SVG: version: 1.9.9, author: Daryll Doyle, Automatische Aktualisierungen aktiviert
wp-plugins-inactive (1)
Akismet Anti-Spam: version: 4.2.1, author: Automattic, Automatische Aktualisierungen aktiviert
wp-media
image_editor: WP_Image_Editor_GD
imagick_module_version: Nicht verfügbar
imagemagick_version: Nicht verfügbar
imagick_version: Nicht verfügbar
file_uploads: File uploads is turned off
post_max_size: 8M
upload_max_filesize: 2M
max_effective_size: 2 MB
max_file_uploads: 20
gd_version: bundled (2.1.0 compatible)
gd_formats: GIF, JPEG, PNG, BMP
ghostscript_version: 9.55.0
wp-server
server_architecture: Linux 5.15.11-gentoo x86_64
httpd_software: Apache
php_version: 8.0.12 64bit
php_sapi: apache2handler
max_input_variables: 1000
time_limit: 30
memory_limit: 128M
admin_memory_limit: 256M
max_input_time: 60
upload_max_filesize: 2M
php_post_max_size: 8M
curl_version: 7.79.1 OpenSSL/1.1.1l
suhosin: false
imagick_availability: false
pretty_permalinks: true
htaccess_extra_rules: false
wp-database
extension: mysqli
server_version: 10.5.10-MariaDB-log
client_version: mysqlnd 8.0.12
max_allowed_packet: 16777216
max_connections: 151
wp-constants
WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /home/manuel/public_html/wordpress-beta/wp-content
WP_PLUGIN_DIR: /home/manuel/public_html/wordpress-beta/wp-content/plugins
WP_MEMORY_LIMIT: 40M
WP_MAX_MEMORY_LIMIT: 256M
WP_DEBUG: false
WP_DEBUG_DISPLAY: true
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: false
CONCATENATE_SCRIPTS: undefined
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_ENVIRONMENT_TYPE: Nicht definiert
DB_CHARSET: utf8mb4
DB_COLLATE: undefined
wp-filesystem
wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
`
Additional context
PHP error log:
The problem lies in the Gutenberg plugin, in the following code (gutenberg/build/block-library/blocks/site-logo.php, lines 15ff.):
Apparently,
$image[1]
and$image[2]
are both unset (or false), which results in a division by zero, but only if the width was manually altered (and therefore$attributes['width']
is not empty.They get set to
false
by the Safe SVG plugin (safe-svg/safe-svg.php, lines 226ff.):A trivial fix would be to set
$image[1]
and$image[2]
to100
instead offalse
, but I have no idea what (possibly negative) side effects that could cause.I guess it also depends on the order in which the filters are registered (gutenberg-first vs. safe-svg-first).
Lastly, a fix could also be made in the Gutenberg plugin: only perform the calculation if
$image[1]
and$image[2]
are both set to non-zero numerical values. But I assume it is very unusual for these values to be 0 in the first place, so I wouldn't count on the Gutenberg developers to be overly enthusiastic about implementing such a fix in their plugin.The text was updated successfully, but these errors were encountered: