Bugfix: Error when deleting watermark - Passing null to function's parameter

18 views
Skip to first unread message

Tim L

unread,
Apr 27, 2024, 3:28:37 PMApr 27
to ResourceSpace
RS 10.3
PHP 8.2.10

When deleting a watermark from System - Configuration page, this error occurs:

!
Sorry, an error has occurred.

Please go back and try something else.


/var/www/html/resourcespace/include/general_functions.php line 5245: substr(): Passing null to parameter #1 ($string) of type string is deprecated

This is the function causing the error:

/**
 * Update global variable watermark to point to the correct file. Watermark set on System Configuration page will override a watermark
 * set in config.php. config.default.php will apply otherwise (blank) so no watermark will be applied.
 *
 * @return void
 */
function set_watermark_image()
    {
    global $watermark, $storagedir;
   
    if ($watermark, 0, 13) == '[storage_url]') # Error in this line
        {
        $GLOBALS["watermark"] = str_replace('[storage_url]', $storagedir, $watermark);  # Watermark from system configuration page
        }
    else if ($watermark !== '')
        {
        $GLOBALS["watermark"] = dirname(__FILE__). "/../" . $watermark;  # Watermark from config.php - typically "gfx/watermark.png"
        }
    }

This replacement is needed:
    if (substr(($watermark)?$watermark:"", 0, 13) == '[storage_url]')

Dan Huby

unread,
Apr 30, 2024, 4:39:04 AMApr 30
to ResourceSpace
Thank you - I have raised a ticket with the software team.


Reply all
Reply to author
Forward
0 new messages