xref: /PHP-7.4/ext/xmlrpc/tests/bug47818.phpt (revision ded3d984)
1--TEST--
2Bug #47818 (Segfault due to bound callback param)
3--SKIPIF--
4<?php if (!extension_loaded("xmlrpc")) print "skip"; ?>
5--FILE--
6<?php
7
8class MyXmlRpc {
9    private $s;
10    private $method;
11
12    function impl($method_name, $params, $user_data){
13        $this->method = $method_name;
14        print "Inside impl(): {$this->method}\n";
15        return array_sum($params);
16    }
17
18    function __construct() {
19        $this->s = xmlrpc_server_create();
20        xmlrpc_server_register_method($this->s, 'add', array($this, 'impl'));
21    }
22
23    function call($req) {
24        return xmlrpc_server_call_method($this->s, $req, null);
25    }
26
27    function getMethod() {return $this->method;}
28
29}
30
31$x = new MyXmlRpc;
32$resp = $x->call(xmlrpc_encode_request('add', array(1, 2, 3)));
33
34$method = $x->getMethod();
35
36print "Global scope: $method\n";
37
38?>
39--EXPECT--
40Inside impl(): add
41Global scope: add
42