Looks like your server is configured to escalate warnings to errors while your development environment probably ignores them.
MCrypt Deprecation Warning Breaks File Upload - PHP7.1 MCrypt Laravel 5.2
I am currently working on a Laravel 5.2 built intranet, and successfully migrated it from a php5.6/Ubuntu14.04 server to a php7.0/Ubuntu16.04 server with no major issues. A newer (smaller) app was built on laravel 5.6, which requires php7.1, so I performed the upgrade from 7.0-7.1, and now I am experiencing problems.
My development environment is an iMac running Valet and PHP7.1, and I cannot replicate these issues on my dev environment, only on the server. When I upgraded to php7.1 on the server, I now receive the following error when I attempt a file upload:
Whoops, looks like something went wrong.
ErrorException in Base.php line 1592:
Function mcrypt_list_algorithms() is deprecated
in Base.php line 1592
at HandleExceptions->handleError('8192', 'Function mcrypt_list_algorithms() is deprecated', '/var/www/directory/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php', '1592', array('engine' => '2')) in Base.php line 1592
at Base->isValidEngine('2') in RC4.php line 166
at RC4->isValidEngine('2') in Base.php line 1659
at Base->_setEngine() in Base.php line 494
at Base->__construct('5') in RC4.php line 134
at RC4->__construct() in SSH2.php line 1834
at SSH2->_encryption_algorithm_to_crypt_instance('arcfour256') in SSH2.php line 1601
at SSH2->_key_exchange('!����{'f�%#��[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1/ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519�aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]�aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]�[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96�[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96none,[email protected]none,[email protected]') in SSH2.php line 1097
at SSH2->_connect() in SSH2.php line 1870
at SSH2->_login('sshfileserverusername', 'sshfileserverpassword')
at call_user_func_array(array(object(SFTP), '_login'), array('sshfileserverusername', 'sshfileserverpassword')) in SFTP.php line 392
at SFTP->login('sshfileserverusername', 'sshfileserverpassword') in SecLibGateway.php line 98
at SecLibGateway->connect('sshfileserverusername') in Connection.php line 140
at Connection->getGateway() in Connection.php line 254
at Connection->put(object(UploadedFile), '/var/www/html/profilePhotos/Omobude-Pam.jpg') in EmployeesControler.php line 283
at EmployeesControler->updatePhoto('1255', object(Request))
at call_user_func_array(array(object(EmployeesControler), 'updatePhoto'), array('employees' => '1255', object(Request))) in Controller.php line 80
at Controller->callAction('updatePhoto', array('employees' => '1255', object(Request))) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(EmployeesControler), object(Route), 'updatePhoto') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in PermissionRedirectMiddleware.php line 25
at PermissionRedirectMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(PermissionRedirectMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(EmployeesControler), object(Route), object(Request), 'updatePhoto') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\EmployeesControler', 'updatePhoto') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
As you can see at lines 12-19 or so (I apologize, I don't know how to show line numbers or highlight), the previous developer is using an ssh/ftp method to store the file uploaded on a separate server (a server specifically for files), and the error is thrown by the package phpseclib.
I have looked around the internet everywhere, and cannot find a solution like this. My biggest problem is not exactly knowing the point of failure. I realize that mcrypt is deprecated in php7.1, but it has not been removed (based on my understanding), so it should not be breaking the file upload yet. We will be moving toward active directory integration in the near future for storing profile photos and information (still powered by laravel), so if it is indeed just this connection to the other server and file upload via that method causing this deprecation warning, then I wouldn't even mind a temporary solution of suppressing that warning (I couldn't find that either).
In short, I (obviously) am having trouble figuring this one out, so any help is very much appreciated!
Yes, add
"phpseclib/phpseclib": "~2.0.4"
to the require section of your projects composer.json file and then run composer install
Please or to participate in this conversation.