Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

A non well formed numeric value encountered [Solved]
https://www.tinywebgallery.com/forum/viewtopic.php?f=1&t=4218
Page 1 of 1

Author:  Erik Bachmann [ 5. Feb 2017, 20:48 ]
Post subject:  A non well formed numeric value encountered [Solved]

After switching from HTTP to HTTPS I keep getting this error message in the debug file:
Code:
02.05.2017 18:25:26 (en) - ERROR 8 in /httpd.www/twg/inc/filefunctions.inc.php, line 2956: A non well formed numeric value encountered

I've even removed all galleries and cleared the cache - but still this error keeps popping up

Author:  TinyWebGallery [ 5. Feb 2017, 23:20 ]
Post subject:  Re: A non well formed numeric value encountered

Can you post the line - because line numbers always depends on the version And I don't know which one you use...

In the latest version here some server variables like memory_limit are read. I don't see why https should be a problem.
If this is really the line you have some server configs that should not be that way ;).

Best, Michi

Author:  Erik Bachmann [ 6. Feb 2017, 00:08 ]
Post subject:  Re: A non well formed numeric value encountered

OK - what should I look for??

Author:  TinyWebGallery [ 6. Feb 2017, 21:07 ]
Post subject:  Re: A non well formed numeric value encountered

Please see my last post - first line.

Best, Michael

Author:  Erik Bachmann [ 7. Feb 2017, 06:33 ]
Post subject:  Re: A non well formed numeric value encountered

Code:
function return_kbytes($val)
{
    if ($val) {
        $val = trim($val);
        $last = strtolower($val{strlen($val) - 1});
        switch ($last) {
            case 'g':
                $val *= 1024;
            case 'm':
                $val *= 1024;   // 2956: This line tricks the error
            case 'k':
                $val *= 1;
        }
    }
    return $val;
}

Author:  TinyWebGallery [ 7. Feb 2017, 08:07 ]
Post subject:  Re: A non well formed numeric value encountered

Then please check your php server settings.

There e.g. memory-limit has 500mb instead of 500m
In the administration you can see the php info on the info page.

Best Michael

Author:  Erik Bachmann [ 8. Feb 2017, 22:19 ]
Post subject:  Re: A non well formed numeric value encountered

The memory limit is 536870912. And PHP version 7.1
Quote:
info.php reports: - Memory limit Very Good (536870912)

I'm not quite sure, where this takes me..??

Author:  TinyWebGallery [ 8. Feb 2017, 23:53 ]
Post subject:  Re: A non well formed numeric value encountered

The function that reports an error tells you that the value that should be parsed is not a number. The fuction does remove from e.g. 500m the m - so 500 is the value.
On your server something like 500mb I think is defined. So you have to find the value that is entered in an incorrect.

On the info page is also a button php info which shows all the values. Chck this and look for invalid entries there. This is not a TWG issue. This is a server configuration issue.

Best, Michael

Author:  Erik Bachmann [ 9. Feb 2017, 14:04 ]
Post subject:  Re: A non well formed numeric value encountered

Close - but no cigar (yet!) 8)
Good old fasion searching:
Code:
find . -name "*.php" -exec grep -n -H "return_kbytes" {} ;

lead me to check the values of:
Quote:
upload_max_filesize 96M
post_max_size 96M
memory_limit 536870912

The processed value is "96M" - a string.

In PHP 7.1 a type casting is needed:
Code:
function return_kbytes($val)
{
    if ($val) {
        $val = trim($val);   //$ val is a string
        $last = strtolower($val{strlen($val) - 1});
        $val = (int)$val;   //2017-02-09/EBP: Type casting bugfix
        switch ($last) {
            case 'g':
                $val *= 1024;
            case 'm':
                $val *= 1024;   // A string was multiplied with a number
            case 'k':
                $val *= 1;
        }
    }
    return $val;
}

Same problem has been seen in Joombla: https://github.com/joomla/joomla-cms/pull/12311 :mrgreen:

Author:  TinyWebGallery [ 9. Feb 2017, 16:22 ]
Post subject:  Re: A non well formed numeric value encountered

is php 7 now so picky.

So it is solved now?

Because then i'll add this to the next release.

Author:  Erik Bachmann [ 9. Feb 2017, 17:46 ]
Post subject:  Re: A non well formed numeric value encountered

Works smoothly!
How do I close this topic?

Author:  TinyWebGallery [ 9. Feb 2017, 17:52 ]
Post subject:  Re: A non well formed numeric value encountered

This version of the forum does not have something like this. You can add [solved] to the title if you like.

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/