0

Since updating, I'm occasionally seeing this warning

Warning: Use of undefined constant SSL_CURRENT - assumed 'SSL_CURRENT' (this will throw an Error in a future version of PHP) in /usr/www/domain/phpmyd/listing.php on line 151

This is the line:

$pdf->Image($PMDR->get($PMDR->getConfig('map_type').'_Map')->getMapImageByCoords($listing['latitude'],$listing['longitude']),$pdf->GetX(),$pdf->GetY(),$pdf->pixelsToUnits(512),$pdf->pixelsToUnits(512),'','http'.(SSL_CURRENT ? 's' : '').'://maps.google.com/maps?q='.$listing['latitude'].','.$listing['longitude'],'N', false, 300);

Just looking at it, should it be like

$pdf->pixelsToUnits(512),'','http'.('SSL_CURRENT' ? 's' : '')

So just adding brackets around SSL_current? Was it always like this, because I never saw errors before.

Natsu
  • 111
  • 1
  • 2
  • 11
  • 1
    @Nick That makes no sense. The string `'SSL_CURRENT'` is always truthy. Why would you use it in a conditional expression? – Barmar Nov 21 '19 at 00:24
  • It's still a notice-level error. – Barmar Nov 21 '19 at 00:26
  • 1
    @Barmar presumably `SSL_CURRENT` is actually supposed to be a defined constant... – Nick Nov 21 '19 at 00:26
  • it sounds like it used to be a defined constant, but it went away in 7.2. – Barmar Nov 21 '19 at 00:26
  • @Barmar not in current versions of PHP, it's a warning as of 7.2.0 https://3v4l.org/5UZdg – Nick Nov 21 '19 at 00:27
  • I have a feeling this may be related to this question you asked yesterday: https://stackoverflow.com/questions/58944243/warning-sizeof-parameter-must-be-an-array-or-an-object-that-implements-count Maybe a change in your 7.2 update process is preventing that constant from being defined. – Don't Panic Nov 21 '19 at 00:28
  • @Nick My mistake, I thought warning and notice were the same thing. – Barmar Nov 21 '19 at 00:28
  • Alright, I'll define it like above, thats what I was thinking to begin with. @Don'tPanic I've been going through so many small changes with this update, it's been hard to really go throguh them all in detail. However, the listing function would never touch the config so its unlikely. – Natsu Nov 21 '19 at 00:29
  • Google can't find any references to the constant `SSL_CURRENT`. If this used to be defined, I'd expect to be able to find it. – Barmar Nov 21 '19 at 00:29
  • 1
    @Natsu If you define it like the above, you can just get rid of the conditional and write `'https'`. – Barmar Nov 21 '19 at 00:30
  • @Barmar Yeah I couldn't either, which is why I came here. Does it not need to be defined at all I wonder. – Natsu Nov 21 '19 at 00:30
  • 1
    @Barmar I was thinking user-defined constant e.g. `define(SSL_CURRENT, 1)` – Nick Nov 21 '19 at 00:30
  • @Nick That wouldn't go away from upgrading, unless something else was causing the script with the defines to fail. – Barmar Nov 21 '19 at 00:31
  • @Nick Search your code for something like that. – Barmar Nov 21 '19 at 00:31
  • @Barmar agreed. But based on OPs previous question, lots has been failing... – Nick Nov 21 '19 at 00:32
  • 1
    @Natsu Just because you're seeing that warning in listing doesn't mean that's where the error that kept that constant from being defined occurred, so the fact that it doesn't directly deal with config doesn't rule out that possibility IMO. – Don't Panic Nov 21 '19 at 00:32
  • @Natsu What was the PHP version it worked without any warning before? – Jimmix Nov 21 '19 at 05:15
  • You may also get `PHP Fatal error...` when it's escaped `echo \SSL_CURRENT;` and `PHP Warning` when no backslash used. (PHP7.3.11). – Jimmix Nov 21 '19 at 05:29
  • @Don'tPanic I'm starting to think you're right. We've made so many small changes lately, this will be tough to track down. We can stop the warning of course, but I'm curious now what exactly happened (prior thread change maybe..?). We were using 7.1 before this, Jimmix. – Natsu Nov 21 '19 at 20:02
  • I would expect that SSL_CURRENT constant to be defined somewhere fairly early in the request handling process, if that helps at all. Without knowing the specific setup of your project, I would just do a "Find in path" for that constant name at the project root. It may be used quite frequently though, based on how it's used here, so you may need to look for something more specific like "define(SSL_CURRENT" to find the place where it should be defined. – Don't Panic Nov 21 '19 at 20:22

1 Answers1

1

I have looked at PHP's source and the constant SSL_CURRENT was never defined in any of the PHP version starting form version 4.

Therefore this issue is not related to the change of the PHP version.

For whatever reason you could not see warning about that constant before but it is for sure not PHP version update that made that constant undefined.

Since this string:

'SSL_CURRENT'

will always evaluate to true then this conditional expression:

'SSL_CURRENT' ? 's' : '';

is not conditional at all because it will always return "s":

echo 'SSL_CURRENT' ? 's' : '';

so it can be also written this way

echo 's';

so it equals using it in your code this way:

$pdf->pixelsToUnits(512),'','https'
Jimmix
  • 5,644
  • 6
  • 44
  • 71