PHP 7 throws a notice per title of this issue due to the result of microtime() calls at cdn.module:78 and cdn.module:155 being a string.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

evgeny.chernyavskiy created an issue. See original summary.

evgeny.chernyavskiy’s picture

evgeny.chernyavskiy’s picture

Status: Needs work » Needs review
Wim Leers’s picture

Category: Bug report » Task
Status: Needs review » Postponed (maintainer needs more info)

I strongly doubt this is correct, since the return value is completely different now.

$ php --version
PHP 7.0.12 (cli) (built: Oct 17 2016 11:16:49) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.12, Copyright (c) 1999-2016, by Zend Technologies
wim.leers at acquia in ~/Work/d8/
$ php test.php
string(21) "0.92212100 1485343682"
float(1485343682.9222)
wim.leers at acquia in ~/Work/d8/
evgeny.chernyavskiy’s picture

I don't think the initial implementation was ever correct:

$foo = microtime();
$bar = microtime();

var_dump($foo, $bar);
// string(21) "0.66834000 1485350696"
// string(21) "0.88662200 1485350701"

//  $foo and $bar are cast to integer and only microseconds get subtracted from each other.
var_dump($bar - $foo);
// float(0.218282)

// ==============

$foo = microtime(true);
$bar = microtime(true);

var_dump($foo, $bar);
// float(1485350834.1571)
// float(1485350838.403)

// This is how one would measure a time period according to the microtime() documentation.
var_dump($bar - $foo);
// float(4.2459540367126)
Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

Hah! WTF. I know for a fact that it worked, but it may have well just have worked due to PHP strangeness.

(This is also pretty useless functionality, which I wrote in a time where I was fairly naïve, which is why it's gone in the Drupal 8 port :))

So, let's get this done. Thanks, and sorry for that awful code!

Wim Leers’s picture

Category: Task » Bug report
Priority: Normal » Minor

Wim Leers’s picture

Status: Reviewed & tested by the community » Fixed
Wim Leers’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.