PHP CRYPT_BLOWFISH Error? - php

I'm on Redhat and using PHP Crypt_Blowfish and having following error.
ERROR:
Notice: Constant CRYPT_BLOWFISH_AUTO already defined in /usr/share/pear/Crypt/Blowfish.php on line 33 Notice: Constant CRYPT_BLOWFISH_MCRYPT already defined in /usr/share/pear/Crypt/Blowfish.php on line 38 Notice: Constant CRYPT_BLOWFISH_PHP already defined in /usr/share/pear/Crypt/Blowfish.php on line 43 Fatal error: Cannot redeclare class Crypt_Blowfish in /usr/share/pear/Crypt/Blowfish.php on line 88
My code is just something like:
include_once('Blowfish.php');
$key = '12345678';
$cipher = new Crypt_Blowfish($key);
echo Eencrypt($cipher, "hello world!");
And when i check my php.ini, the mcrypt is also already installed and enabled.
What went seriously wrong please?

Strict standards warnings are no errors. You can remove them from your error_reporting setting easily:
error_reporting(error_reporting() & ~E_STRICT);

Related

How do I run phpunit test despite tested code throwing Notices

I know ideally that I should fix all the places in my code where PHP Notices are being thrown but for now I am trying to get a simple test up and running for one part of the application.
When I try to run my test using
sudo phpunit -c tests/phpunit.xml tests/
I get the following notices:
PHP Notice: Undefined property: stdClass::$integer_value in /var/www/application/authenticate.php on line 111
PHP Notice: Undefined property: stdClass::$boolean_value in /var/www/application/authenticate.php on line 115
PHP Notice: Undefined property: stdClass::$boolean_value in /var/www/application/site/authenticate.php on line 115
PHP Notice: Undefined property: stdClass::$integer_value in /var/www/application/authenticate.php on line 111
I've tried following the advice on this answer to a similar question https://stackoverflow.com/a/8412996/3263538
and have created a phpunit.xml configuration file which includes the following xml to ignore notices and warnings
tests/phpunit.xml
<phpunit convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningEToExceptions="false">
</phpunit>
UtilitesTest.php (dummy test that returns true)
<?php
use PHPUnit\Framework\TestCase;
include_once "/var/www/application/utilities.php";
class UtilitiesTest extends TestCase
{
public function testEmpty()
{
return 1;
}
}
?>
but still no luck. Is there something I'm missing here? Ideally I'd like to suppress these Notice messages.

WordPress Importer plugin show error message when I import sample data

I use WordPress source code version 4.5.3, I install WordPress Importer plugin to import sample data from URL https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml
But when I finished importing I received more error message below:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; WP_Import has a deprecated constructor in C:\xampp\htdocs\wp\wp-content\plugins\wordpress-importer\wordpress-importer.php on line 38`
Warning: Declaration of WP_Import::bump_request_timeout() should be compatible with WP_Importer::bump_request_timeout($val) in C:\xampp\htdocs\wp\wp-content\plugins\wordpress-importer\wordpress-importer.php on line 38`
Notice: wp_get_http is deprecated since version 4.4! Use WP_Http instead. in C:\xampp\htdocs\wp\wp-includes\functions.php on line 3658`
Notice: Array to string conversion in C:\xampp\htdocs\wp\wp-content\plugins\wordpress-importer\wordpress-importer.php on line 798`
Notice: Undefined variable: _menu_item_type in C:\xampp\htdocs\wp\wp-content\plugins\wordpress-importer\wordpress-importer.php on line 800`
Notice: Undefined variable: _menu_item_type in C:\xampp\htdocs\wp\wp-content\plugins\wordpress-importer\wordpress-importer.php on line 802`
Notice: Undefined variable: _menu_item_type in C:\xampp\htdocs\wp\wp-content\plugins\wordpress-importer\wordpress-importer.php on line 804`
Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\wp\wp-includes\class-wp-http-curl.php on line 239`

new XAMPP giving me million errors

I used to have old version of Portable Xampp, all my codes where running correctly.
Today I installed the latest version - portable (then I tried install).
The pages is giving a lot of errors and the code is not running
something like this:
Notice: Use of undefined constant server_name - assumed 'server_name' in D:\xampp\htdocs\aviaeng\settings.php on line 14
Notice: Use of undefined constant db_name - assumed 'db_name' in D:\xampp\htdocs\aviaeng\settings.php on line 15
Notice: Use of undefined constant username - assumed 'username' in D:\xampp\htdocs\aviaeng\settings.php on line 16
Notice: Use of undefined constant password - assumed 'password' in D:\xampp\htdocs\aviaeng\settings.php on line 17
Notice: Use of undefined constant contact_email - assumed 'contact_email' in D:\xampp\htdocs\aviaeng\settings.php on line 18
and on the browser I have
<? echo $lang[website_name] ?>
which means the PHP is not being read by Xampp.
What am I doing wrong ?
It seems that your code is not compatible syntaxically speaking with the new PHP version you installed.
With patience, you can debug your code to adapt its syntax to your new PHP version. Courage :)

$_REQUEST issue on PHP after using PHP 5.5.3 (old version: 5.3.1)

line 55 - include('config-and-functions.php');
line 56 - $action = $_REQUEST['action'];
I'm getting this error: Notice: Undefined index: action in C:\xampp\htdocs\index.php on line 56 after using a new PHP version.
There is some modification on $_REQUEST at this new php version? (5.5.3 - XAMPP 1.8.3)
This is because of php.ini change. Basically what it tells is the $_REQUEST array is not having an index by the name 'action'. It suggests to always check for existence of an index before using it.
You can override this in php using
error_reporting(E_ALL ^ E_NOTICE);
or you can change this in php.ini
error_reporting = E_ALL & ~E_NOTICE

PHP Error log file format (php.ini error_log directive) on Windows

For an example:
php.ini file
...
; Log errors to specified file.
error_log = c:/php/php.log
...
Error log file (c:/php/php.log) contains every entry in this format:
[12-Jun-2011 12:58:55] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 12:59:01] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:01:12] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:02:11] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:11:23] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
[12-Jun-2011 13:12:10] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\r\n
Two carriage return character and one new line per one error line.
Why it happens?
How to change error log file to default format:
[12-Jun-2011 12:58:55] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 12:59:01] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:01:12] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:02:11] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:11:23] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
[12-Jun-2011 13:12:10] PHP Notice: Undefined variable: test in C:\www\phpinfo.php on line 2\r\n
PHP Version 5.3.6
Apache/2.2.15 (Win32)
Tested on Windows 7 Home Basic and Windows XP SP3, same results.
php.ini file contains only two strings
log_errors = On
error_log = c:/server/php.log
apache phpinfo() script -> http://pastehtml.com/view/awvx1vgpp.html
PS.
sever: nginx 1.0.4
FastCGI + PHP Version 5.3.6
Everything works as expected.
nginx phpinfo() script -> http://pastehtml.com/view/awvwvk9p9.html
There are more ini directives to control the output into the error log. These are explained on this PHP manual page.
By default, PHP running with not loading the ini and only having the error_log set and logging enabled, it does output a single line only. You can test that on your system as well, it demonstrates it well for the Command Line Interface (CLI) "Server Application Programming Interface (API) [SAPI]":
php -n -d error_log=./error.log -d log_errors=1 -r 'error;'
Use this command to make an isolated run and compare it with your output. If it has two line endings as well, then this is probably a bug of your php version.
If not a problem with the PHP version [not the case in the original posting (OP)] then within your application some settings looks to be altered. You need to find out which setting. Probably you can find it by registering an own error handler and then dumping the ini settings.
Last but not least, if it isn't a misunderstanding of the line ending (see my comment), then one may want to also look in the ini settings named error_prepend_string and error_append_string regarding the error display (but not the error logging).

Categories