I am using codeigniter to upload images to a amazon storage bucket.Iam getting this error and i dont know what to do to overcome this problem
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 65: necessary data rewind wasn't possible [url] https://public-ww-lk.s3.amazonaws.com/images/gallery/the-kingsbury-colombo-sri-lanka-21401-293x154.jpg' in E:\projects\wwlk\application\third_party\Awsmy\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php:338 Stack trace: #0 E:\projects\wwlk\application\third_party\Awsmy\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php(279): Guzzle\Http\Curl\CurlMulti->isCurlException(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array) #1 E:\projects\wwlk\application\third_party\Awsmy\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php(244): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array) #2 E:\projects\wwlk\application\third_party\Awsmy\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php(227): Guzzle\Http\Curl\CurlMulti->processMessages() #3 E:\pro in E:\projects\wwlk\application\third_party\Awsmy\vendor\aws\aws-sdk-php\src\Aws\Common\Client\AbstractClient.php on line 285
Try setting CURL option body_as_string to true.
Something like this:
<?php
$client->getConfig()->set('curl.options', array('body_as_string' => true));
Related
I have a third party application which inserts product data to WooCommerce via the REST API. The third party application does not log outbound API requests.
The third party application is making a request to WooCommerce which is causing a PHP error.
[16-Jan-2023 14:52:23 UTC] PHP Fatal error: Uncaught TypeError: preg_match(): Argument #2 ($subject) must be of type string, WP_REST_Request given in /home/CENSORED/public_html/wp-includes/formatting.php:1596
Stack trace:
#0 /home/CENSORED/public_html/wp-includes/formatting.php(1596): preg_match('/[\\x80-\\xff]/', Object(WP_REST_Request))
#1 /home/CENSORED/public_html/wp-includes/formatting.php(2207): remove_accents(Object(WP_REST_Request))
#2 /home/CENSORED/public_html/wp-includes/class-wp-hook.php(310): sanitize_title(Object(WP_REST_Request))
#3 /home/CENSORED/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Object(WP_REST_Request), Array)
#4 /home/CENSORED/public_html/wp-includes/taxonomy.php(1751): apply_filters('pre_term_slug', Object(WP_REST_Request), 'pa_colour')
#5 /home/CENSORED/public_html/wp-includes/taxonomy.php(1653): sanitize_term_field('slug', Object(WP_REST_Request), 0, 'pa_colour', 'db')
#6 /home/CENSORED/public_html/wp-includes/taxonomy.php(2385): sanitize_term(Array, 'pa_colour', 'db')
#7 /home/CENSORED/public_html/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-terms-controller.php(407): wp_insert_term('DENIM BLUE', 'pa_colour', Array)
#8 /home/CENSORED/public_html/wp-includes/rest-api/class-wp-rest-server.php(1171): WC_REST_Terms_Controller->create_item(Object(WP_REST_Request))
#9 /home/CENSORED/public_html/wp-includes/rest-api/class-wp-rest-server.php(1018): WP_REST_Server->respond_to_request(Object(WP_REST_Request), '/wc/v2/products...', Array, NULL)
#10 /home/CENSORED/public_html/wp-includes/rest-api/class-wp-rest-server.php(442): WP_REST_Server->dispatch(Object(WP_REST_Request))
#11 /home/CENSORED/public_html/wp-includes/rest-api.php(410): WP_REST_Server->serve_request('/wc/v2/products...')
#12 /home/CENSORED/public_html/wp-includes/class-wp-hook.php(308): rest_api_loaded(Object(WP))
#13 /home/CENSORED/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters(NULL, Array)
#14 /home/CENSORED/public_html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#15 /home/CENSORED/public_html/wp-includes/class-wp.php(399): do_action_ref_array('parse_request', Array)
#16 /home/CENSORED/public_html/wp-includes/class-wp.php(780): WP->parse_request('')
#17 /home/CENSORED/public_html/wp-includes/functions.php(1332): WP->main('')
#18 /home/CENSORED/public_html/wp-blog-header.php(16): wp()
#19 /home/CENSORED/public_html/index.php(17): require('/home/CENSORED...')
#20 {main}
thrown in /home/CENSORED/public_html/wp-includes/formatting.php on line 1596
I believe the PHP error is a bug that needs to be reported to WooCommerce and/or WordPress. I am unable to capture the contents of the request so that I can provide steps to reproduce for the bug report.
I am testing on a completely blank and up-to-date installation of WordPress and WooCommerce with no other plugins (except those mentioned below).
I have tried:
Looking in the Apache access log, the request body is not included
Using this plugin https://wordpress.org/plugins/wp-rest-api-log/ but it does not capture the request. It captures valid requests, but not the request that causes the error
Using this plugin https://wordpress.org/plugins/log-http-requests/ it does not appear to capture REST API requests
Using this code https://iandunn.name/2016/02/05/logging-wordpress-rest-api-errors/ it does not add any content to the error_log when the error occurs. I fired other invalid requests to the REST API and it did work, so I can only assume that the request is a valid REST API request syntactically and the resulting error is an internal PHP bug.
How can I capture the full request so that I can confirm this is a WooCommerce or WordPress bug and report to the appropriate github?
I suggest: "debugging by printf" or "debugging by print_r" in this special case.
Edit /home/CENSORED/public_html/index.php and insert just before line 17:
syslog(LOG_ERROR, print_r($_GET, TRUE));
syslog(LOG_ERROR, print_r($_POST, TRUE));
depending on the request type your plugin fires, the content should appear in one of these log outputs.
You could also go to /home/CENSORED/public_html/wp-includes/formatting.php and insert before line 1596:
syslog(LOG_ERROR, print_r($text, TRUE));
to get the malformed string variable.
After doing so, you should be able to find the log lines in the server's syslog via:
tail -f /var/log/syslog
If you unfortunately don't have access to the wp source code on the server machine, you should capture the request on the desktop machine which is running the plugin via Wireshark or TShark. I wouldn't blame it overkill. By filtering the capture by server IP, protocol http and method (http.request.method == GET or http.request.method == POST) the heart of the matter should be revealed soon (Maybe you have to reset the request scheme from https to http).
I am getting the error "Cannot modify header information - headers already sent" from PHP code.
Note that I am NOT getting the error "Cannot modify header information - headers already sent by (output started at [filename]:[linenumber])".
I get the former with SAPI=apache2module and the later with SAPI=cli.
I am quite familiar with the error, and can usually tell exactly where it is coming from. In my current case, I can't. (My best guess so far is that the mail() function is doing output.)
How do I convince PHP to use the form with "by (output started at %s:%d)"?
Examining PHP source, it apparently only uses the later form if the location was recorded. But what makes it record or not?
<?php
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
try {
header('Content-Type: text/plain');
printf("before sapi = %s\n", php_sapi_name());
flush();
header('X-test: something');
print "after\n";
} catch (Exception $ex) {
print($ex);
}
Expected and correct, CLI:
$ php flush_test5.php
before sapi = cli
exception 'ErrorException' with message 'Cannot modify header information - headers already sent by (output started at /dir/file.php:10)' in /dir/file.php:12
Stack trace:
#0 [internal function]: exception_error_handler(2, 'Cannot modify h...', '/name/david/bar...', 12, Array)
#1 /dir/file.php(12): header('X-test: somethi...')
$
Obtained, apache2module:
before sapi = apache2handler
exception 'ErrorException' with message 'Cannot modify header information - headers already sent' in /dir/file.php:12
Stack trace:
#0 [internal function]: exception_error_handler(2, 'Cannot modify h...', '/name/david/bar...', 12, Array)
#1 /dir/file.php(12): header('X-test: somethi...')
#2 {main}
I would like to get, from apache2module:
before sapi = apache2handler
exception 'ErrorException' with message 'Cannot modify header information - headers already sent by (output started at /dir/file.php:10)' in /dir/file.php:12
Stack trace:
#0 [internal function]: exception_error_handler(2, 'Cannot modify h...', '/name/david/bar...', 12, Array)
#1 /dir/file.php(12): header('X-test: somethi...')
#2 {main}
I am trying to download an external file using guzzle. This is the code that I use:
// $url is a URL I receive from Openload's API request
$url = 'https://abvzps.example.com/dl/l/4spxX_-cSO4/The+quick+brown+fox.mp4';
$path = storage_path('app/remote-uploads/test.mp4');
$client = new Client();
$client->get($url, ['sink' => $path]);
The code works and downloads from localhost just fine, but when I push it to production I receive this error:
[2017-03-25 19:08:06] production.ERROR: RuntimeException: Cannot read from non-readable stream in /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/psr7/src/Stream.php:208
Stack trace:
#0 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php(132): GuzzleHttp\Psr7\Stream->read(120)
#1 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php(105): GuzzleHttp\Exception\RequestException::getResponseBodySummary(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#3 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#4 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#5 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#6 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)
#7 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\Promise\Promise->invokeWaitFn()
#8 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\Promise\Promise->waitIfPending()
#9 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\Promise\Promise->invokeWaitList()
#10 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /var/www/vhosts/clooud.tv/httpdocs/vendor/guzzlehttp/guzzle/src/Client.php(129): GuzzleHttp\Promise\Promise->wait()
...
I am not quite sure how to go about this and would really appreciate any help!
It's hard to say something without the real URL and debugging.
Just set a breakpoint before the exception and take a look at the response. IMO it should contain an error, but I have no idea, which one exactly.
There is a web service URL which returns a country's cities details. I can access this web service URL in browser by direct Http Request using GET method
and works fine :
[Snip: I changed my actual domain name with example]
http://alpha.example.com/WSV2/StaticData.php?xml=<StaticDataRequest><Header><Code>TT4533</Code><Username>skyman211</Username><Password>ammkj43</Password></Header><Body><GetStaticData>cities</GetStaticData><ExtraParams><CountryCode>67</CountryCode></ExtraParams></Body></StaticDataRequest>
But when I try to access above URL via SoapClient :
/* Line 36 */
$cities = new SoapClient("http://alpha.example.com/WSV2/StaticData.php?xml=<StaticDataRequest><Header><Code>TT4533</Code><Username>skyman211</Username><Password>ammkj43</Password></Header><Body><GetStaticData>cities</GetStaticData><ExtraParams><CountryCode>67</CountryCode></ExtraParams></Body></StaticDataRequest>");
Gets me following error :
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
Couldn't find <definitions> in 'http://alpha.example.com/WSV2/StaticData.php?xml=
<StaticDataRequest><Header><Code>TT4533</Code><Username>skyman211</Username>
<Password>ammkj43</Password></Header><Body><GetStaticData>cities</GetStaticData>
<ExtraParams><CountryCode>67</CountryCode></ExtraParams></Body></StaticDataRequest>'
in /srv/www/htdocs/test/inc/client.php:36 Stack trace: #0 /srv/www/htdocs/test/
inc/client.php(36): SoapClient->SoapClient('http://alpha.ex...') #1 /srv/www/
htdocs/ortmas/index.php(6): InitData->getCities(67) #2 {main} thrown in /srv/
www/htdocs/test/inc/client.php on line 36
You must pass the URL to the WSDL, instead of the actual call itself.
Something like that for example :
$cities = new
SoapClient("http://alpha.example.com/WSV2/StaticData.wsdl");
If that url worked on your browser, you can try to do the following in PHP :
$url = "http://alpha.example.com/WSV2/StaticData.php?xml=<StaticDataRequest><Header><Code>TT4533</Code><Username>skyman211</Username><Password>ammkj43</Password></Header><Body><GetStaticData>cities</GetStaticData><ExtraParams><CountryCode>67</CountryCode></ExtraParams></Body></StaticDataRequest>";
$data = file_get_contents($url);
I am using soap call request to below URL using PHP SoapClient.
https://stagingxml.tamarindtours.in/Version1.0/BaseDetails.svc?wsdl
I have used follwing code.
$HeaderSecurity = array("UsernameToken"=>array("Username"=>"xxx",
"Password"=>"xxx",
)
);
$client = new SoapClient('https://stagingxml.tamarindtours.in/Version1.0/BaseDetails.svc?wsdl',array('trace' => 1));
$header[] = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd","Security",$HeaderSecurity);
$client->__setSoapHeaders($header);
//$client->__setLocation("https://YourTargetLocation/"); if you have wsdl file you don't need to use this line
$REsponse = $client->GetCountries();
I am getting following error.
Fatal error: Uncaught SoapFault exception: [a:InvalidSecurity] An
error occurred when verifying security for the message. in
/opt/lampp/htdocs/wssoap.php:148 Stack trace: #0
/opt/lampp/htdocs/wssoap.php(148): SoapClient->__call('GetCountries',
Array) #1 /opt/lampp/htdocs/wssoap.php(148):
SoapClient->GetCountries() #2 {main} thrown in
/opt/lampp/htdocs/wssoap.php on line 148
Can you please help me out? Thanks.
Server may have an invalid SSL certificate.
If this error is not important for you, try to ignore SSL certificate check as explained here : https://stackoverflow.com/a/8447706/911718 (see comments too about allow_self_signed option)
Edit : Same error as you & error solved at https://stackoverflow.com/a/16794759/911718