Skip to content
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

Warning: A non-numeric value encountered in wiki/inc/common.php on line 1675 #2756

Open
polygontwist opened this issue Apr 19, 2019 · 12 comments

Comments

@polygontwist
Copy link

commented Apr 19, 2019

I have set to the current version (2018-04-22b "Greebo", download 14.4.2019) with PHP 7.2, the data taken from the old installation (data / pages, data / media) and get erroneous error message instead of images.

I have changed the line and it works again:
$ret = substr($v, 0, -1);
to
$ret = intval(substr($v, 0, -1));

function php_to_byte($v) {
    $l   = substr($v, -1);
    $ret = intval(substr($v, 0, -1));
    switch(strtoupper($l)) {
        /** @noinspection PhpMissingBreakStatementInspection */
        case 'P':
            $ret *= 1024;
        /** @noinspection PhpMissingBreakStatementInspection */
        case 'T':
            $ret *= 1024;
        /** @noinspection PhpMissingBreakStatementInspection */
        case 'G':
            $ret *= 1024;
        /** @noinspection PhpMissingBreakStatementInspection */
        case 'M':
            $ret *= 1024;
        /** @noinspection PhpMissingBreakStatementInspection */
        case 'K':
            $ret *= 1024;
            break;
        default;
            $ret *= 10;
            break;
    }
    return $ret;
}
@peterfromearth

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

Should be already fixed with #2556

@polygontwist

This comment has been minimized.

Copy link
Author

commented Apr 19, 2019

The function is still used in other places:
media.php
mediamanager.php

some pictures and pictures in the media manager were not displayed.

@Michaelsy

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

@polygontwist Your provider is 1&1-IONOS?

@polygontwist

This comment has been minimized.

Copy link
Author

commented Apr 19, 2019

yes

@Michaelsy

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

Ok, @peterfromearth is right. Here is detailed information how to fix it: https://forum.dokuwiki.org/post/64705. I prefer the php.ini-solution.

@polygontwist

This comment has been minimized.

Copy link
Author

commented Apr 19, 2019

I have no problem with a memory limit. substr returns a string, and this is multiplied by a number. That's not good from syntax. That also says the error message.

@Michaelsy

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

Did you try the patches or the php.ini solution? You should.

@polygontwist

This comment has been minimized.

Copy link
Author

commented Apr 19, 2019

I will not patch anything else if the problem is so obvious. In my solution, the images are displayed against. Above all there 1&1 could override the next version. Respectively because I would have to think about it at the next installation.

@Michaelsy

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

Ok, who doesn't want, doesn't want.

But so that others are not put on the wrong track, here is some background information:

DokuWiki definitely can not calculate images under these conditions:

  • Version: Greebo
  • memory-limit is set to "-1" (this is the case with 1&1)
  • PHP 7.1 or higher

The root cause is that DokuWiki can not interpret the value of "-1" correctly.

As already stated, here are the solutions that will eliminate the root cause (and not the aftereffects of this incompatibility).

BTW: I guess it would be a good idea to offer a corresponding hotfix. This problem is always in demand, again and again. 1&1 is one of the largest mass providers in Germany. There are now only the PHP versions offered, with which (in connection with Greebo) the malfunction occurs. That is, almost all DokuWiki users at 1&1 are affected.

HTH - Michael Sy.

@polygontwist

This comment has been minimized.

Copy link
Author

commented Apr 19, 2019

Thanks for the background information.

The root cause is that DokuWiki can not interpret the value of "-1" correctly.

I wonder why you work with strings and then treat them as numbers - that's logically wrong, isn't it? Or is there an automatic conversion in php that turns string numbers into numbers?

With the change in the function everything works. View upload - the images are displayed correctly.

As you wrote, the next one will stumble over it, too. I think the small change in the function is also the better solution - everything else is too complicated.

@phy25

This comment has been minimized.

Copy link
Collaborator

commented Apr 19, 2019

You are welcome to provide a PR before others have time to investigate.

@Michaelsy

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

The necessary pull requests (#2420 & #2556) have already been merged.
What we IMHO need is a hotfix. Please see my comments above.

splitbrain added a commit that referenced this issue Apr 24, 2019
This refactors the php_to_byte() method to properly return integers
always. A bug when reading byte sizes under 10 bytes was fixed. Infinity
(signaled by a -1 in php.ini) is now returned as -1.

According to [1] PHP supports size shortcuts for (K)ilobytes,
(M)egabytes and (G)igagbytes only. The support for Tera- and Petabytes
has been removed.

[1] https://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
splitbrain added a commit that referenced this issue Jul 14, 2019
* master: (34 commits)
  fix color for noninstalled extensions
  show disabled extensions in gray
  warn about inaccessible repo api
  bugfix: access check was never cached
  First go on a CLI component for the extension manager
  use strict type comparison
  translation update
  translation update
  fix #dokuwiki__sitetools current item not in highlight due to Greebo change
  authplain: Add tests for group retrieval
  authplain: Add a simple method for retrieving user groups
  translation update
  Negative string offsets are allowed in PHP 7.1+ only
  improve memory check output
  fix and test php_to_byte() related to #2756 #2556
  translation update
  translation update
  translation update
  translation update
  translation update
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.