1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Not a Bug Bug in PHP 5.4X?

Discussion in 'Resolved Bug Reports' started by Merijn, Jun 3, 2012.

  1. Merijn

    Merijn Member

    First of all, I have no experience with PHP, so anything I say or do in that direction can be utterly wrong. Don't do anything written in this post on your live install.

    I had the problem and error described here: http://xenforo.com/community/threads/8wayrun-com-xenporta-portal.26838/page-37#post-369340

    On my local install (also php 5.4) I found the same error on the same spot in the XenPorta application. I fiddled around, and did something (in the "lol I've no idea what I'm doing" fashion) and to my surprise it worked. (EDIT: To be clear, server is running linux, the local install is running on windows. Both use nginx, and have the same config for nginx, php-fpm and mysql.)

    In Node.php I looked up line 1255 and changed the following:

    Code:
                    'selected' => (strval($selectedNodeId) === '0'),
    
    To

    Code:
                    'selected' => ($selectedNodeId),
    
    And to my surprise the page loaded without the error that had come first. I have no idea what security issues this induces, so I think it's best for some professionals to look at it.

    My apologies if this isn't a bug, and I suggest for other people to NOT change this in their install.

    On another server I had a couple applications breaking because PHP handles things different in their newest version. Perhaps (what I've seen with other applications) is something between the lines of if php is lower than version 5.4 do this, else do that. Also my apologies if this all seems a bit unclear and confusing, I've been trying to get things to work all day, and am tired now.

    I hope anybody can help me, and many thanks in advance!
     
  2. MGSteve

    MGSteve Well-Known Member

    Well, Symantecally (is there such a word!) the code may work, but I suspect whatever relies on the value of 'selected' won't work as intended.

    From looking at the error, $selectedNodeId is supposed to contain a number, which converts the value in the variable into a string value.

    The bug lies in the addon though as whatever it does, its changing $selectedNodeId into an array, rather than a basic value (i.e. number).

    What you have done stops the runtime error, but there is still a bug there.
     
  3. Merijn

    Merijn Member

    Thanks for your answer MGSteve!

    Well, now I might add another layer of fluff to make it even worse. On my local install I temporarily downgraded to php 5.2.17, and there the
    Code:
    'selected' => (strval($selectedNodeId) === '0'),
    does work without a problem, where it does not work with the most recent php.

    A lot of applications have broken since php 5.4, because of tiny little things. To me it seems like an issue with the most recent php.

    (And now I'm going to bed. n_n)
     
  4. simbolo

    simbolo Well-Known Member

    I'm guessing here but in PHP 5.4 putting an array in to a ($variable) now throws an E_NOTICE whereas in previous versions it did not. Now that's a notice not an error, but could be somewhat related.
     
  5. Jaxel

    Jaxel Well-Known Member

    So I've been looking into it... and yes, even in PHP 5.3, line 1255 in Node.php didn't work even semantically. But the thing about that specific piece of array data... it was irrelevant. XenForo didn't actually use it... so the failure of the data was fine because it didn't matter...

    But now in PHP 5.4, because of it throwing an error... I guess I'll have to change things.
     
  6. Merijn

    Merijn Member

    So then I misplaced this as a XenForo bug after all. Thanks for looking into it Jaxel!
     
  7. Jaxel

    Jaxel Well-Known Member

    Merijin, instead of changing Node.php, change EWRporta/Option/ForumChooser.php...

    Line 16:
    Code:
    $forumOptions = $nodeModel->getNodeOptionsArray($nodeModel->getAllNodes(), $preparedOption['option_value'], '(unspecified)');
    To:
    Code:
    $forumOptions = $nodeModel->getNodeOptionsArray($nodeModel->getAllNodes(), false, '(unspecified)');
    Tell me if it works then...
     
  8. Merijn

    Merijn Member

    It works! On both my windows and linux install with php 5.4+ I can run this without seeing an error. With this I think it might be fixed. Many thanks!

    EDIT:

    This error exist with most of your plugins I think. (The ones who use ForumChooser.php)
     
  9. Dinh Thanh

    Dinh Thanh Well-Known Member

    Nice,
    I love to update to new things, but is there any benefits to Xenforo when we update php to 5.4?
     

Share This Page