On Fri, 14 Apr 2017 20:20:05 +0300, Juha Heinanen wrote: > When I try to open a web page implemented using PHP, I get error > > [Fri Apr 14 20:04:15.147463 2017] [:error] [pid 977] [client ::1:48700] PHP > Parse error: syntax error, unexpected 'new' (T_NEW) in > /usr/share/php/HTTP/Request.php on line 412 > > The offending line is here: > > function setURL($url) > { > $this->_url = &new Net_URL($url, $this->_useBrackets); > > This page used to work on Jessie, but now fails on Stretch.
That is due to a backwards incompatible change in PHP 7.0, see <http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.new-by-ref>: | The result of the new statement can no longer be | assigned to a variable by reference: I've attached a patch, but it would be better to switch to HTTP/Request2, I think. Regards, -thh
--- HTTP_Request-1.4.4/Request.php 2017-08-12 19:39:37.542731105 +0200 +++ HTTP_Request-1.4.4/Request.php.NEW 2017-08-12 19:39:41.074815507 +0200 @@ -409,7 +409,7 @@ */ function setURL($url) { - $this->_url = &new Net_URL($url, $this->_useBrackets); + $this->_url = new Net_URL($url, $this->_useBrackets); if (!empty($this->_url->user) || !empty($this->_url->pass)) { $this->setBasicAuth($this->_url->user, $this->_url->pass); @@ -729,11 +729,11 @@ if ($keepAlive && !empty($sockets[$sockKey]) && !empty($sockets[$sockKey]->fp)) { - $this->_sock =& $sockets[$sockKey]; + $this->_sock = $sockets[$sockKey]; $err = null; } else { $this->_notify('connect'); - $this->_sock =& new Net_Socket(); + $this->_sock = new Net_Socket(); $err = $this->_sock->connect($host, $port, null, $this->_timeout, $this->_socketOptions); } PEAR::isError($err) or $err = $this->_sock->write($this->_buildRequest()); @@ -746,7 +746,7 @@ $this->_notify('sentRequest'); // Read the response - $this->_response = &new HTTP_Response($this->_sock, $this->_listeners); + $this->_response = new HTTP_Response($this->_sock, $this->_listeners); $err = $this->_response->process( $this->_saveBody && $saveBody, HTTP_REQUEST_METHOD_HEAD != $this->_method @@ -776,7 +776,7 @@ $this->disconnect(); // Store the connected socket in "static" property } elseif (empty($sockets[$sockKey]) || empty($sockets[$sockKey]->fp)) { - $sockets[$sockKey] =& $this->_sock; + $sockets[$sockKey] = $this->_sock; } // Check for redirection @@ -791,7 +791,7 @@ // Absolute URL if (preg_match('/^https?:\/\//i', $redirect)) { - $this->_url = &new Net_URL($redirect); + $this->_url = new Net_URL($redirect); $this->addHeader('Host', $this->_generateHostHeader()); // Absolute path } elseif ($redirect{0} == '/') {