Coder Social home page Coder Social logo

Comments (9)

mermetbt avatar mermetbt commented on May 18, 2024

I don't think InfluxDB accept float or double values as timestamp, need to be check.

Another strange behavior is if you put a string in input like '2015-10-27 14:17:40', the method isValidTimestamp will return true because of PHP behavior.
The first test (int)$timestamp === $timestamp will be false, but we continue to check... that's not a good behavior. And in the second check PHP will consider the string as a numeric value (1) and the test $timestamp <= PHP_INT_MAX && $timestamp >= ~PHP_INT_MAX will be true. So the method return true on string values...

from influxdb-php.

andig avatar andig commented on May 18, 2024

I don't think InfluxDB accept float or double values as timestamp, need to be check.

I don't expect it to, but the timestamp check function should accept nanosec timestamps which it doesn't. Right now its very much borked.

from influxdb-php.

mermetbt avatar mermetbt commented on May 18, 2024

In fact, it can't work on 32bits systems, but on 64bits system it's supported until this date: 294247-01-09 20:00:54 which is I think long enough :-p
On 32bits systems: PHP_MAX_INT is equal to 2,147,483,647 (10 digits)
On 64bits systems: PHP_MAX_INT is equal to 9,223,372,036,854,775,807 (19 digits)

from influxdb-php.

thecodeassassin avatar thecodeassassin commented on May 18, 2024

@andig what @mermetbt says is correct. We expect the script to be run on 64 bit systems only.

from influxdb-php.

andig avatar andig commented on May 18, 2024

In fact, it can't work on 32bits systems

True for the current implementation. If you wanted to support 32 bits you could allow doubles or even strings and use ctype_digit

from influxdb-php.

thecodeassassin avatar thecodeassassin commented on May 18, 2024

@andig

ctype_digit won't work because it doesn't accept the - character (which means you cannot supply dates before the unix epoch). There are cases where you might need to enter dates before the unix epoch. However we will add the following statement to the isValidTimestamp method:

// if the code is run on a 32bit system, loosely check if the timestamp is a valid numeric
if (PHP_INT_SIZE == 4 && is_numeric($timestamp) && intval($timestamp) == $timestamp) {
    return true;
}

from influxdb-php.

thecodeassassin avatar thecodeassassin commented on May 18, 2024

@andig this issue has been addressed in 1.2.x

from influxdb-php.

andig avatar andig commented on May 18, 2024

It maybe me who doesn't get it, but intval will again be limited to 32bits. Doubles arent- so stay with isnumeric instead?

from influxdb-php.

thecodeassassin avatar thecodeassassin commented on May 18, 2024

@andig correct i will have to remove the intval() function from the equation. I'm retagging 1.2.1 with this change. Thanks!

from influxdb-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.