Page MenuHomePhabricator

https://tools.wmflabs.org/pirsquared/iw.php crashes with fatal error
Open, Needs TriagePublic

Description

2016-11-13 01:23:05: (mod_fastcgi.c.2673) FastCGI-stderr: PHP Fatal error: Call-time pass-by-reference has been removed in /data/project/pirsquared/public_html/iw.php on line 147

Here's the code that is blowing up:

iw.php
if (isset($_REQUEST['wikis']) && strlen(trim($_REQUEST['wikis']))>0) {
    $wikilist    = explode(',', preg_replace('/\s+/', '', $_REQUEST['wikis']));
    $wikis_query = $meta_pdb->prepare("SELECT slice, dbname, url FROM wiki WHERE $other_conds AND dbname IN (" . trim(str_repeat("?,", count($wikilist)), ",") . ") ORDER BY SLICE");
    $types       = str_repeat('s', count($wikilist));
    array_unshift($wikilist, $types);
    call_user_func_array(
        array(
            $wikis_query,
            "bind_param"
        ),
        &$wikilist
    );
}

The &$wikilist in the above code is the problem. The & is a "call-time pass-by-reference" conversion. This was deprecated in PHP 5.3.0 and removed in PHP 5.4.0. The Trusty exec node that this webservice is currently running on has PHP 5.5. There are various workarounds suggested in the mysqli_stmt::bind_param docs.

Event Timeline

I made this change to /data/project/pirsquared/public_html/iw.php:

iw.php
/*
call_user_func_array(
    array(
        $wikis_query,
        "bind_param"
    ),
    &$wikilist
);
*/
// Call using reflection to work around T150592
// Code from https://secure.php.net/manual/en/mysqli-stmt.bind-param.php#104073
$ref = new ReflectionClass('mysqli_stmt');
$method = $ref->getMethod('bind_param');
$method->invokeArgs($wikis_query, $wikilist)

We're discussing at T152793#2863012 about an interwiki conflict with a namespace. While to tool gives some results, it's throwing all kind of errors afterwards such as:

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /mnt/nfs/labstore-secondary-tools-project/pirsquared/public_html/iw.php on line 84

Since @PiRSquared17 is apparently not able to continue mantaining to tool I'd suggest that mantainers be added to the tool or that it be forked and mantained elsewhere. It's very useful for interwiki map removal requests.

I've also noticed another exception:

https://pirsquared.toolforge.org/iwconflict.php?wikis=&iw=gitlab
( ! ) Warning: mysqli::mysqli(): (HY000/1049): Unknown database 'meta_p' in /data/project/pirsquared/public_html/iwconflict.php on line 103

I don't know if an hand is still needed but maybe I can try to apply an hot patch to the PHP script. I'm valeriobozzolan in Toolforge if more maintainers are needed.