Is there a version of PSWebServiceLibrary.php running with PHP v7.0? - php

I have site A that runs on Prestashop 1.6.1.5 and to retrieve data on another site (site B) which also runs under Prestashop 1.6.1.5, I use a module "homemade" (by my predecessor) which uses, among other things, PSWebServiceLibrary.php.
When I change version of PHP (from version 5.6 to version 7.0) on site B and I want to use the module on site A, I have some errors including PSWebServiceLibrary.php
I thus have the following error message:
Fatal error: Uncaught exception 'PrestaShopWebserviceException' with message
'This call to PrestaShop Web Services failed and returned an HTTP status of 500. That means: Internal Server Error.' in www.ndd.fr/PSWebServiceLibrary.php:95
Stack trace:
0 www.ndd.fr/PSWebServiceLibrary.php(297): PrestaShopWebservice->checkStatusCode(500)
1 www.ndd.fr/modules/orderlist/classes/orderArrayCreator.class.php(145): PrestaShopWebservice->get(Array)
2 www.ndd.fr/modules/orderlist/controllers/admin/AdminOrderList.php(125): orderArrayCreator->createDistantOrderArray()
3 www.ndd.fr/classes/controller/Controller.php(178): AdminOrderListController->postProcess()
4 www.ndd.fr/override/classes/Dispatcher.php(335): ControllerCore->run()
5 www.ndd.fr/override/classes/Dispatcher.php(107): Dispatcher->dispatch_16()
6 www.ndd.fr/admin/index.php(58): Dispatcher->dispatch()
7 {main} thrown in www.ndd.fr/PSWebServiceLibrary.php on line 95
If I come back to version 5.6, I have no problem, the module works normally.
So this is a problem related to version 7 of PHP.
Is there a version of PSWebServiceLibrary.php that works with PHP v 7.0?
In advance thank you for your help because I am a beginner in PHP

Indeed PrestaShop 1.6.1.5 is not officially PHP 7.x compatible, however, you should be able to fix this error easily:
Edit the file /classes/webservice/WebserviceRequest.php and on line 794 replace:
if (count(self::$shopIDs)) {
by
if (is_array(self::$shopIDs) && count(self::$shopIDs)) {
Download the latest version of PSWebServiceLibrary.php (here)
To make sure everything's now ok, create a new file test-ws.php with the following code (and type in your url/credentials) :
<?php
require_once('./PSWebServiceLibrary.php');
try
{
$ws = new PrestaShopWebservice('http://www.yourstore.com', 'YOURWSKEYHERE', false);
echo '<pre>';
print_r($ws);
}
catch (PrestaShopWebserviceException $ex)
{
echo 'Error : '.$ex->getMessage();
}
?>
If it works you should get something like:
PrestaShopWebservice Object
(
[url:protected] => http://www.yourstore.com
[key:protected] => YOURWSKEYHERE
[debug:protected] =>
[version:protected] => unknown
)
In case you still get a 500 error after that: Turn on error_logs in your php.ini configuration file and check the errors logs. Alternately, you can try to set _PS_MODE_DEV_ to true in /config/defines.inc.php.

Related

Problems using SAPI with PHP through COM, on IIS

I am attempting to get Text To Speech and Speech Recognition to work in PHP using Microsoft's SAPI through COM objects.
In the past, I already used this code to get TTS to work (Apache 2.1, PHP 5.5, on Windows 2003 Server)
// Instantiate the object
$VoiceObj = new COM("SAPI.SpVoice") or die("Unable to instantiate SAPI");
// Get the available voices
$VoicesToken=$VoiceObj->GetVoices();
$NumberofVoices=$VoicesToken->Count;
for($i=0;$i<$NumberofVoices;$i++)
{
$VoiceToken=$VoicesToken->Item($i);
$VoiceName[$i]=$VoiceToken->GetDescription();
}
// Get and print the id of the specified voice
$SelectedVoiceToken=$VoicesToken->Item(0);
$SelectedVoiceTokenid=$SelectedVoiceToken->id;
// Set the Voice
$VoiceObj->Voice=$SelectedVoiceToken;
$VoiceName=$VoiceObj->Voice->GetDescription();
$VoiceFile = new COM("SAPI.SpFileStream");
$VoiceFile->Open('./test.wav', 3, false);
// Speak to file
$VoiceObj->AudioOutputStream = $VoiceFile;
$VoiceObj->Speak("What an unbelievable test", 0);
$VoiceFile->Close();
On my new setup (IIS 7.5, PHP 7.0, Windows Server 2008R2) the same code fails at
$VoiceObj->Speak("What an unbelievable test", 0);
Fatal error: Uncaught com_exception: <b>Source:</b> Unknown<br/><b>Description:</b> Unknown in \\web\tts.php:30 Stack trace: #0 \\web\tts.php(30): com->Speak('this is a marve...', 0) #1 {main}
With such little detail (where to retrieve more?) I can't figure out what the problem may be.
Writing permissions checked.
PHP 7.0 replaced with 5.5, still not working.
Same code tested with a Win32 app, and it works flawlessly.
Any hints?
Two years later, I casually happen to find an answer to this problem.
PHP COM Objects can't perform file operations on network paths, even with all the required permissions
Once the development folders were moved on the same machine where IIS runs, a bunch of previously broken tests started working. They all had one thing in common: they were using COM interfaces to save files or something like that.

Soundcloud API Upload suddenly throwing code 422

Been using the PHP Soundcloud API for some time now, and it's been working fine. The code I use to create the track array is (and has always been):
$track = json_decode($client->post('tracks', array(
'track[title]' => $title,
'track[asset_data]' => $filename,
'track[description]' => $desc,
'track[genre]' => "Podcast",
'track[artwork_data]' => $image
)));
And it's always been working just fine - until this morning, when I got this error message when uploading a track using my home-made PHP tool:
Fatal error: Uncaught exception 'Services_Soundcloud_Invalid_Http_Response_Code_Exception' with message 'The requested URL responded with HTTP code 422.' in /home/csicon/public_html/PodcastAuthor/lib/Soundcloud.php:943 Stack trace: #0 /home/csicon/public_html/PodcastAuthor/lib/Soundcloud.php(621): Services_Soundcloud->_request('https://api.sou...', Array) #1 /home/csicon/public_html/PodcastAuthor/2-publish.php(52): Services_Soundcloud->post('tracks', Array) #2 {main} thrown in /home/csicon/public_html/PodcastAuthor/lib/Soundcloud.php on line 943
Now, I'm no newb, and know what HTTP code 422 is all about, so I checked the contents of $title, $filename, $desc and $image. They are, in order:
Geekdays #274: 2015-11-17
#/home/csicon/public_html/PodcastAuthor/uploads/g274.mp3
Snowden, the FBI and the Oxford Dictionary are getting blamed for things that they may or may not have done. Also; the air you're breathing might be killing you. This, and so much more, on today's episode of Geekdays.
#/home/csicon/public_html/wp-content/uploads/2014/10/geekdays-600x600.png
All paths (to the mp3 and the image) check out, there's nothing wonky in the character set being used, and it's all worked before. What might have happened here? I'm stumped.
UPDATE! Turns out my webhost has upgraded their PHP environment from 5.4 to 5.6, and this is what broke it. What's changed between 5.4 and 5.6 that might have caused this, in that case?
Turns out my webhost has upgraded their PHP environment from 5.4 to 5.6, and this is what broke it. What's changed between 5.4 and 5.6 that might have caused this, in that case?
How cURL file uploads are handled has changed.
CURLOPT_SAFE_UPLOAD is set to true by default from PHP 5.6 on, and that means file uploads are not possible any more using the #-file path syntax, but CURLFile should be used for file uploads instead.
Try setting CURLOPT_SAFE_UPLOAD to false, using the setCurlOptions method.
Magically started working when I changed to the sebdesign/php-soundcloud version of the curl-file branch. Not sure why the "normal" curl-file branch didn't work, however.

PHP Fatal error: Failure in wincache (windows azure)

I have codeigniter framework in my project. My website is running on windows azure platform. Sometimes it's giving me this error:
PHP Fatal error: Failure in Wincache[6484] free_memory: Block 0x41d56d8 not in use
in D:\home\site\wwwroot\system\libraries\Log.php on line 44
I tried to change php.ini file by changing value of memory:
ini_set('memory_limit','2048M');
But, then after I checked memory_get_peak_usage(); then I found that application is not even using more than 1MB. I don't know what's going on here. I am getting blank page and website gets down when this happens.
Please, ask me if you need more information or code.
Log.php:
public function __construct()
{
$config =& get_config();
$this->_log_path = ($config['log_path'] != '') ? $config['log_path'] : APPPATH.'logs/';
if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) // This is line 44.
{
$this->_enabled = FALSE;
}
if (is_numeric($config['log_threshold']))
{
$this->_threshold = $config['log_threshold'];
}
if ($config['log_date_format'] != '')
{
$this->_date_fmt = $config['log_date_format'];
}
}
log.php file is default codeigniter file.
FINAL SOLUTION:
I have updated my php.ini file with this:
wincache.fcenabled=0
wincache.ocenabled=0
wincache.ucenabled=0
wincache.reroute_enabled = 0
wincache.srwlocks = 0
It's an issue with IIS or WinCache on Windows Server. You can follow official thread on a iis forum.
Just to be sure, check following options in your php.ini:
wincache.reroute_enabled = 0
wincache.srwlocks = 0
Also update wincache to a latest version.
The specific WinCache error message has been removed as of WinCache 1.3.7.5, which was pushed out in a recent Azure Web Services update.
As for the meaning of the error message: While attempting to free a block of memory in a cross-process shared memory segment, WinCache detected that the block had already been freed. The message indicates that WinCache detected the problem, and avoided corrupting memory. The message should really be a Warning level message. Further, the executing request should run to completion, and a response should be returned to the customer.
Prior to WinCache 1.3.7.4, WinCache did not detect this scenario, and would wind up corrupting memory, which would eventually lead to an AV. So, the error message actually indicates that WinCache just saved you from crashing, and you're welcome!

Amazon S3 - deleteObjects() - "guzzle" errors?

Here's the reduced but accurate code I'm working with.
$client = S3Client::factory(array('key'=>$ak,'secret'=>$sk));
foreach(range(1,10) as $i) $temp[] = array('Key'=>$i);
$result = $client->deleteObjects(array('Bucket'=>'bucket','Objects'=>$temp));
return $result;
Everything works, it deletes the objects as requested but it throws all of these errors from the phar file. Running this locally as you can see below.
Fatal error: Uncaught exception 'Guzzle\Http\Exception\CurlException' with message '[curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete=' in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285
Guzzle\Http\Exception\CurlException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Guzzle/Http/Curl/CurlMulti.php on line 365
Aws\Common\Exception\TransferException: [curl] 56: Problem (2) in the Chunked-Encoded data [url] https://bucket.s3.amazonaws.com?delete= in phar://C:/wamp/www/bucket/local/aws.phar/Aws/Common/Client/AbstractClient.php on line 285
I was also having this problem running WampServer on Windows 7 x64. Through dumb luck, I just stumbled across the solution.
Simply add 'scheme' => 'http' to the factory config settings and it starts working!
Little late I realize, but searches for this returned very little, hopefully this might help someone else.
I was also getting this error only when trying to deleteObjects, WAMPSERVER (64 BITS & PHP 5.4) 2.4, Windows 7 x64. I think something is wrong with the Curl extension in this version of WAMP. I installed WAMPSERVER (32BITS & PHP 5.4) 2.4 and had no issues with deleteObjects.
Possible solution is to add
'curl.options' => array('CURLOPT_HTTP_VERSION'=>'CURL_HTTP_VERSION_1_0')
to S3Client::factory options.
No more mentioned curl errors, but now I sometimes receive Simple XML error: "Entity: line 2: parser error : Extra content at the end of the document".

Class CamelCaseToSeparator not found when running zf show version

I'm trying to set up my Zend installation but when I run zf show version in the CLI I get this error message:
Fatal error: Class 'Zend\Filter\Word\CamelCaseToSeparator' not found in C:\Progr
am Files (x86)\EasyPHP-12.1\php\php546x120828095553\ZendFramework-2.0.3\library\
Zend\Filter\Word\CamelCaseToDash.php on line 18
I haven't changed anything in the files and they're in the right place with the correct names and everything.
Does anyone of you know what the error could be?
I had the same problem when I had 2 zend framework libaries includes in php.ini file for zend framework 1 and 2 versions, when I left only one, this error disapeared.

Categories