Use of undefined constant SIGTERM - > assumed 'SIGTERM' - php

Currently running PHPUnit with Codeception on my Windows machine gives me an error:
[PHPUnit_Framework_Exception]
Use of undefined constant SIGTERM -
assumed 'SIGTERM'
As far as I know is that SIGTERM is a constant provided by PCNTL, which is not supported in Windows. In that way this CONSTANT shouldnt be used for a test running on Windows env. at all.
My PHP setup:
PHP 5.6.17 (cli) (built: Jan 6 2016 13:28:38)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
PHPUnit
PHPUnit 5.7.15
Codeception
Codeception PHP Testing Framework v2.2.9
phiremock-codeception-extension
phiremock-codeception-extension v1.2.2

The problem is depending on phiremock-codeception-extension which uses SIGTERM without checking the OS/PCNTL extension is available. So I created a Bug report at GitHub https://github.com/mcustiel/phiremock-codeception-extension/issues/4..
This are the infected code lines - https://github.com/mcustiel/phiremock-codeception-extension/blob/master/src/Extension/PhiremockProcess.php#L74
/**
* Stops the process.
*/
public function stop()
{
$this->process->signal(SIGTERM);
$this->process->stop(3, SIGKILL);
}
I will update this answer once the problem has been fixed by the developer.
Update
This issue has beend fixed in phiremock-codeception-extension v.1.2.3.

Related

php complaining that abstract methods aren't implemented when they are, apache restart fixes it for a while

This problem started a few days ago.
The error message:
Fatal error: Class Session contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::open) in D:\xampp\htdocs\itasecure_class_session.php on line 38
Restarting apache fixes it, for a few hours or maybe a day or two, but then the error comes back.
For reference, the open() method most definitely is implemented.
Here's a snippet showing how the class and this particular method override are defined:
class Session implements SessionHandlerInterface
{
...
public function open ( $savePath, $sessionName )
{
...
}
...
}
PHP 7.1.6 (cli) (built: Jun 8 2017 02:06:32) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
Windows Server 2008 R2 Standard
P.S. This is not a question about how to implement abstract methods. This is a question about whether there's some obscure bug or configuration problem in php causing code that usually works to suddenly start having problems.

Executing gulp in php returns error but works in shell

I have a wierd problem with executing gulp from php script. Tests:
browser: http://server.com/pull.php <- does not work
shell: php pull.php <- works
shell: gulp <- works
Here is my setup:
Ubuntu 12.04.5 LTS
Node v5.6.0
PHP 5.5.30-1+deb.sury.org~precise+1 (cli) (built: Oct 4 2015 16:14:34)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
Here are packages in package.json:
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-less": "^3.0.5",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.2",
"gulp-uglifycss": "^1.0.6",
"gulp-watch": "^4.3.5"
It works perfectly when i run this from shell but returns error when run in php as webserver:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object #<Object> has no method 'existsSync'
at /usr/local/lib/node_modules/gulp/node_modules/liftoff/lib/find_config.js:21:10
at Liftoff.buildEnvironment (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:67:20)
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:192:32)
at /usr/local/lib/node_modules/gulp/node_modules/liftoff/node_modules/flagged-respawn/index.js:17:3
at Liftoff.<anonymous> (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:185:9)
at /usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:159:9
at /usr/local/lib/node_modules/gulp/node_modules/v8flags/index.js:99:14
at Array.0 (/usr/local/lib/node_modules/gulp/node_modules/v8flags/index.js:38:7)
at EventEmitter._tickCallback (node.js:192:41)
Command to run it is simple:passthru('gulp 2>&1');. I hoestly don't know what is wrong, owner of the files, web server (nginx runs as) user and git owner is the same user named git. Tried various different things as making bash script to run it from php but no luck. I am guessing i am missing some system variables?
Thanks in advance, let me know if you need more info.
Turns out node couldn't play nicely with gulp. My solution:
passthru('node ./node_modules/gulp/bin/gulp.js 2>&1');
I can't explain why, just tried few random ideas and that one worked. One thing bothers me though, why can't i get full info on git pull? I am only getting:
Updating dcd958f..db05960

Troubleshoot Codeigniter CLI stopped

I have been using the CLI interface to send out cron jobs from my codeigniter page. It worked fine until I updated Wordpress yesterday. I do not know how this effected Codeigniter but that is when the trouble started. I also installed cURL at about the same time. I am not sure if that could have made a difference.
SYMPTOMS:
None of my codeigniter CLI scripts work. I have two scripts that send out email reminders, and another that synchronizes my database and none function.
ERRORS:
I had some errors come up when I tried to run my scripts such as:
Use of undefined constant __DIR__ - assumed '__DIR__'
This was never a problem before. But for now I change that to
dirname(__FILE__)
and that seemed to help. At least that error stopped.
Next another error notice appeared regarding code in my scripts that I was not getting before: "Can't use method return value in write context in . . ."
This error was in reference to this line of code:
if (!empty($this->get_available_hours($date, $provider_id))) {
I modified this to
$availabehours=$this->get_available_hours($date, $provider_id);
if (!empty($availabehours)) {
And the error stopped. But the script usually sends out email regarding availability and no email is sent.
Now I have no errors. I run the scripts and I get no results. If I purposefully mess with the code and do things wrong, I get the appropriate error messages. So, at some level it is reading the file.
I tried just running a simple "hello world file" as discribed here
https://ellislab.com/codeigniter/user-guide/general/cli.html
And nothing was returned.
I tried a simple email script that would send out an email without accessing my database and it did not send anything to me.
It appeares to me like something has caused my code to be interpreted in an older version of php. So I looked at the version currently running:
When logged into the terminal in PuTTY I get:
PHP 5.2.17 (cli) (built: Feb 23 2012 10:42:34)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
Out of date ...
But when I look in the terminal within WinSCP I get:
PHP 5.5.28 (cli) (built: Sep 4 2015 12:07:49)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
This looks up to date.
Running this works: php -r 'echo "Hello World!\n";'
MY QUESTIONS:
1) What tests can I run to find out what is blocking things with my CLI?
Any tips would be appreciated.
2) Why am I seeing two different versions of PHP depending on the terminal I am running and could this be the cause of my problem?

Call to a member function getAction() on a non-object

Hi there i followed these instructions (http://pietervogelaar.nl/php-xdebug-netbeans-vagrant/) to get XDebug up and running with vagrant and NetBeans.
It now works .... almost.
Anytime i run a code that fire a breakpoints, NetBeans works fine allowing me to do my debug thing with no problems.
The thing is at the end of the request Laravel will always return that error :
Call to a member function getAction() on a non-object, specifying a code location that looks weird : xdebug:/­/­debug-eval:1.
Even stranger, my page is rendered and the html is here, but the standard laravel error page is rendered also, at the end of my own page ......
Of course if i disable my breakpoint, everything runs just fine.
My versions right now :
Apache :
Server version: Apache/2.2.22 (Ubuntu)
Server built: Apr 17 2014 21:49:25
PHP :
PHP 5.4.28-1+deb.sury.org~precise+1 (cli) (built: May 5 2014 09:32:44)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
Ok i finally found it.
Problem doesn't come from XDebug or Php or Laravel.
Problem comes from Netbeans.
I had an expression in my watch list i wasn't using anymore.
Deleting every custom entries in the watch list just solves the issues.
Hope at some point it helps someone else ....

Segmentation Fault error in PHP, using SOAP to connect to SalesForce

I'm integrating my software (PHP) with SalesForce, using the SalesForce PHP Toolkit.
So far, everything's worked great, but when I started writing the code to call convertLead(), I got a "Segmentation Fault" error.
This is the code I'm running:
require_once('../salesforce/SforceEnterpriseClient.php');
ini_set('soap.wsdl_cache_enabled', 0);
$SForce = new SforceEnterpriseClient();
$result = $SForce->createConnection('../salesforce/enterprise.wsdl.xml');
$result = $SForce->login('user', 'pass+token');
echo "Logged In!";
$data = array(
'convertedStatus' => 'Converted',
'leadId' => '00QC000000mDcmJMAS'
);
$result = $SForce->convertLead(array($data));
That's it. And i'm getting a Segmentation Fault. I tried using StdClass instead of a keyed array, same thing. The convertLead method in the SF toolkit is really simple, it just calls the same method into a SoapClient instance...
NOTE: I'm running this script from the CLI, not through Apache.
UPDATE: Just tried running "strace" with my script. The last lines of it are:
close(4) = 0
write(1, "Logged IN!", 10Logged IN!) = 10
open("error_log", O_WRONLY|O_CREAT|O_APPEND, 0644) = 4
--- SIGSEGV (Segmentation fault) # 0 (0) ---
+++ killed by SIGSEGV +++
Also, in case it's relevant:
php --version
PHP 5.2.13 (cli) (built: Jul 17 2010 22:01:13)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by ionCube Ltd., and
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
This also happens in my dev machine (Windows), so I doubt it's the Accelerators or anything like that:
php --version
PHP 5.2.13 (cli) (built: Feb 24 2010 14:37:44)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
This may or may not be specific to SalesForce. Probably not, seems like a bug in the SOAP PHP library. Maybe the request/response are broken, but I can't see those because they're HTTPS.
Any ideas how I can go about diagnosing (or more importantly, working around) this issue?
Thank!
Daniel
There is a bug (still after 4 years) in the PHP soap extension. It has to do with how it handles WSDL caching. Disabling caching with ini_set() does not work. You also need to turn off caching for your particular client instance.
return new SforceEnterpriseClient('../salesforce/enterprise.wsdl.xml', array(
'cache_wsdl' => WSDL_CACHE_NONE
));
This is true even when using the native PHP SoapClient class.
Ok, this doesn't solve the underlying issue, but, in case someone got this same problem with SalesForce and PHP...
Despite what the documentation implies, fields SendNotificationEmail and OverwriteLeadSource ARE MANDATORY, you MUST specify them in the call.
Not doing so should give you a nice error, not a SegFault, but still, that solves it.

Categories