Page MenuHomePhabricator

CurlHttpRequest fails with curl < 7.16.2
Closed, ResolvedPublic

Description

Author: slboat

Description:
i found this,is maybe a bug?

PHP Notice: Use of undefined constant CURLOPT_CONNECTTIMEOUT_MS - assumed 'CURLOPT_CONNECTTIMEOUT_MS' in w/includes/HttpFunctions.php on line 733


Version: 1.22.0
Severity: normal

Details

Reference
bz58178

Event Timeline

bzimport raised the priority of this task from to Needs Triage.
bzimport set Reference to bz58178.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Dec 8 2013, 10:27 AM

slboat wrote:

and i always got this,i dont know it's my code problem or the mw,it's been work good before V1.22

PHP Warning: curl_setopt_array() [<a href='function.curl-setopt-array'>function.curl-setopt-array</a>]: Array keys must be CURLOPT constants or equivalent integer values in /w/includes/HttpFunctions.php on line 771

here is my code:

$authUrl = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/"; //验证地址

$options = array(); //看起来定义它是必要的
$options['method']   = 'POST';
$options['timeout']  = $this->config['timeout']; //有趣的是,在class里看起来是共享的
$options['postData'] = array(
    'grant_type' => "client_credentials", //验证地址
    'scope' => "http://api.microsofttranslator.com", //使用范围,因为这套api看起来是很全面的玩意
    'client_id' => $clientID,
    'client_secret' => $clientSecret
);

wfErrorLog('工厂构造'.serialize($options), '/tmp/wm.log' ); //调试信息

$req = MWHttpRequest::factory($authUrl, $options);

slboat wrote:

(In reply to comment #1)

and i always got this,i dont know it's my code problem or the mw,it's been
work
good before V1.22

PHP Warning:  curl_setopt_array() [<a

href='function.curl-setopt-array'>function.curl-setopt-array</a>]: Array keys
must be CURLOPT constants or equivalent integer values in
/w/includes/HttpFunctions.php on line 771

here is my code:

$authUrl =

"https://datamarket.accesscontrol.windows.net/v2/OAuth2-13/"; //验证地址

$options = array(); //看起来定义它是必要的
$options['method']   = 'POST';
$options['timeout']  = $this->config['timeout'];

//有趣的是,在class里看起来是共享的

$options['postData'] = array(
    'grant_type' => "client_credentials", //验证地址
    'scope' => "http://api.microsofttranslator.com",

//使用范围,因为这套api看起来是很全面的玩意

    'client_id' => $clientID,
    'client_secret' => $clientSecret
);
 
wfErrorLog('工厂构造'.serialize($options), '/tmp/wm.log' ); //调试信息
 
$req = MWHttpRequest::factory($authUrl, $options);
wfErrorLog('开始请求\n', '/tmp/wm.log' ); //调试信息        

$status = $req->execute(); //看起来死在这里,问题是选项啥的
Anomie added a comment.Dec 8 2013, 4:30 PM

It sounds like you need to update either your version of PHP or your php-curl module. According http://www.php.net/curl_setopt the CURLOPT_CONNECTTIMEOUT_MS constant was added in cURL 7.16.2 and has been available in PHP since 5.2.3. Since MediaWiki requires PHP 5.3.2, there's no reason you shouldn't have that constant available.

slboat wrote:

hmm,i will have a try,thx!

maybe mw can make a error log:"you curl version is too low,plz upgrade"?

(In reply to comment #3)

It sounds like you need to update either your version of PHP or your php-curl
module. According http://www.php.net/curl_setopt the
CURLOPT_CONNECTTIMEOUT_MS
constant was added in cURL 7.16.2 and has been available in PHP since 5.2.3.
Since MediaWiki requires PHP 5.3.2, there's no reason you shouldn't have that
constant available.

Not the PHP extension, but rather libcurl itself -- the PHP extension may have been compiled against an old version of the library. In that case, the constant could be missing. From ext/curl/interface.c in PHP 5.3 (similar code exists even in newer PHP versions):

#if LIBCURL_VERSION_NUM > 0x071002

REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS);

#endif

slboat wrote:

thx!it had be fix,after recompile the php-curl,and update the curl 7.33.0

[No codefix in MediaWiki code, hence changing resolution to WORKSFORME]

Reopening. This was needless breakage caused by gerrit 58247,
which added a feature chiefly for Wikimedia's use. Fortunately, the
patch is very, very simple.

Change 100390 had a related patch set uploaded by PleaseStand:
Restore compatibility with curl < 7.16.2

https://gerrit.wikimedia.org/r/100390

Anomie added a comment.Dec 9 2013, 4:46 PM

I'm inclined to reclose this.

We require PHP 5.3.2, which was released 4 March 2010. Curl 7.16.2 was released 11 April *2007*, almost three years earlier. Do we really need to maintain compatibility with a version of a library that's almost 7 years old and is 3 years older than other software we require?

MaxSem added a comment.Dec 9 2013, 5:09 PM

Do we have evidence that any supported version of any popular distro is affected? If so, we should take some care to maintain compatibility. Otherwise, we can't maintain compatibility with infinite number of DIY distros/PHP builds.

(In reply to comment #11)

Do we have evidence that any supported version of any popular distro is
affected? If so, we should take some care to maintain compatibility.
Otherwise,
we can't maintain compatibility with infinite number of DIY distros/PHP
builds.

RHEL/CentOS 5, though MW 1.22 is also incompatible with that distribution's php53 package in a different way (bug 58213).

If we do wish to drop support for old versions of curl, we should add:

  • a version check in MWHttpRequest::factory(); and
  • an entry in the RELEASE-NOTES file.

Change 100390 merged by jenkins-bot:
Restore compatibility with curl < 7.16.2

https://gerrit.wikimedia.org/r/100390

Change 100556 had a related patch set uploaded by MarkAHershberger:
Restore compatibility with curl < 7.16.2

https://gerrit.wikimedia.org/r/100556

Change 100556 merged by jenkins-bot:
Restore compatibility with curl < 7.16.2

https://gerrit.wikimedia.org/r/100556

All patches merged. Assuming this is RESOLVED FIXED.

slboat wrote:

i so happy it be fixed!yep,i use centos 5,if update the curl which a lot probelm,the php53 cant install anymore,it need [yum install curl]for it!
so this is just very great for the people like me.