New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined variable `$dif` #5190

Open
KarelWintersky opened this Issue Dec 5, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@KarelWintersky

KarelWintersky commented Dec 5, 2018

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

@Oldiesmann

This comment has been minimized.

Member

Oldiesmann commented Dec 5, 2018

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.

@KarelWintersky

This comment has been minimized.

KarelWintersky commented Dec 5, 2018

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

@jdarwood007

This comment has been minimized.

Member

jdarwood007 commented Dec 5, 2018

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.

@MissAllSunday

This comment has been minimized.

Contributor

MissAllSunday commented Dec 6, 2018

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

@KarelWintersky

This comment has been minimized.

KarelWintersky commented Dec 6, 2018

vars must be defined always. Silent definition is bad practice

MissAllSunday added a commit that referenced this issue Dec 6, 2018

set $dif var
fixes #5190

@MissAllSunday MissAllSunday referenced a pull request that will close this issue Dec 6, 2018

Open

set $dif var #5191

@Sesquipedalian Sesquipedalian added this to the Final milestone Dec 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment