Smf2.1: Undefined variable `$dif`

Created on 5 Dec 2018  路  5Comments  路  Source: SimpleMachines/SMF2.1

Description

Undefined variable $dif

Steps to reproduce

https://github.com/SimpleMachines/SMF2.1/blob/release-2.1/Sources/Class-Graphics.php#L304

if (($idx == -1) || ($d < $dif))
            {
                $idx = $i;
                $dif = $d;
            }

$dif is undefined anywhere in scope.

Environment (complete as necessary)

  • Version/Git revision: all

Additional information/references

Minor Bug

All 5 comments

This is old code that was written by someone else not involved with SMF (see the information in the file header comments). It's only used if you don't have the appropriate GIF functions via GD. I don't know that there's much SM can do about this.

make GD required PHP extension and remove old code from repo forever.

Could try to define $dif = null; before the for loop and see if that resolves it. It should be how PHP would handle this before.

Indeed this is only an issue on host with weird configurations, ie, when they explicitly need a var to be set, not a bad policy or bad configuration, in fact I favor var declaration for everything

vars must be defined always. Silent definition is bad practice

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sesquipedalian picture Sesquipedalian  路  6Comments

XinYenFon picture XinYenFon  路  11Comments

Arantor picture Arantor  路  4Comments

albertlast picture albertlast  路  11Comments

Dzonny picture Dzonny  路  9Comments