robrichards/xmlseclibs

PHP Warnings

Closed this issue · 4 comments

PHP Warning: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' (this will throw an Error in a future version of PHP) in /app/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php on line 136
PHP Warning: Use of undefined constant MCRYPT_MODE_CBC - assumed 'MCRYPT_MODE_CBC' (this will throw an Error in a future version of PHP) in /app/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php on line 137
PHP Warning: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' (this will throw an Error in a future version of PHP) in /app/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php on line 136

The above seems to be related to a dependency I have on "robrichards/wse-php" which is going to require the "robrichards/xmlseclibs": "^2.0" and pass those warnings.

Is there a way to quiet them. Could a check be made before they are defined? Then only used if they are defined?

As you've already touched upon a bit, mcrypt has been removed in version 2.0. This because mcrypt has been considered obsolete. The best way to solve your problem is to upgrade to 2.0 and get rid of the mcrypt dependency altogether.

Regardless, your problem is likely that you do not have the php-mcrypt module installed or active, which results in the undefined constants.

Hi, I recently experienced this same issue on PHP 7.2 with version 2.0.1 of this library installed. I think this is still an issue. As far as I can tell it was a non-fatal error. Everything on my site still worked as expected, but the warning is still present.

The comment above is false.. mcrypt was dropped in 3.0.0 as you can read in the changelog.
2.x has some security issues, so I would recommend you upgrade.. If that's not an option, you have to install the php-mcrypt extension, but this is really not recommended.

Thanks for the reply. I can confirm that the error is resolved in 3.x. I was expecting this to be fixed in the 2.x as well given the backported commit I saw in 2.1.0. That would have been my preference since 2.x to 3.x is technically a compatibility breaking update. I'm also not using the library directly. It's being used by the wse-php library (which I'm sure you know) which is being used by the Salesforce Marketing Cloud's Fuel SDK for PHP, which is the primary library I'm using in my code. Fortunately Marketing Cloud has an update that allowed composer to update this library to 3.x so I was able to get it. Had I been constrained in those cases, I would have needed a backport.

Thanks.