Uncaught Error: Call to undefined function set_magic_quotes_runtime()
An extract from my nginx error logs. It happens when I try to open this url: https://radius.example.co/rep-batch-details.php?batch_name=5_5Cedis_Bundle
Any idea why? Am I doing something wrong?
2016/12/19 11:54:24 [error] 4845#4845: *13255 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /var/www/html/daloradius/notifications/dompdf-0.5.1/lib/class.pdf.php:4672
Stack trace:
#0 /var/www/html/daloradius/notifications/dompdf-0.5.1/include/cpdf_adapter.cls.php(578): Cpdf->addJpegFromFile('/var/www/html/d...', 492, 710.64, 57.6, 51.36)
#1 /var/www/html/daloradius/notifications/dompdf-0.5.1/include/image_renderer.cls.php(66): CPDF_Adapter->image('/var/www/html/d...', 'jpg', 492, 30, 57.6, 51.36)
#2 /var/www/html/daloradius/notifications/dompdf-0.5.1/include/renderer.cls.php(180): Image_Renderer->render(Object(Image_Frame_Decorator))
#3 /var/www/html/daloradius/notifications/dompdf-0.5.1/include/renderer.cls.php(110): Renderer->_render_frame('image', Object(Image_Frame_Decorator))
#4 /var/www/html/daloradius/notifications/dompdf-0.5.1/include/renderer.cls.php(132): Renderer->render(Object(Image_Frame_Decorator))
#5 /var/www/html/daloradius/notifications/dompdf-0.5.1/include/renderer.cls.php(13" while reading response header from upstream, client: 45.210.141.212, server: radius.khophi.co, request: "GET /include/common/notificationsBatchDetails.php?batch_name=5_5Cedis_Bundle&destination=download HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "radius.khophi.co", referrer: "https://radius.example.co/rep-batch-details.php?batch_name=5_5Cedis_Bundle"```
@seanmavley are you not able to even render the view for this page? (is there a screenshot you can also attach or do you just get a blank screen?)?
What buttons/actions are you pressing when this happens?
@lirantal The page doesn't render.
I get an HTTP ERROR 500 page
Actions: Login -> Reports -> Batch History -> Select a batch -> Download Invoice
Take a look at it in action: https://youtu.be/nP_hrNiiYv8
From: http://php.net/manual/en/function.set-magic-quotes-runtime.php
Warning This function was DEPRECATED in PHP 5.3.0, and REMOVED as of PHP 7.0.0.
Are you using PHP 7?
yes, PHP 7
On Friday, January 27, 2017, Joshua Clark [email protected] wrote:
From: http://php.net/manual/en/function.set-magic-quotes-runtime.php
Warning This function was DEPRECATED in PHP 5.3.0, and REMOVED as of PHP 7.0.0.
Are you using PHP 7?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lirantal/daloradius/issues/22#issuecomment-275719397, or mute the thread https://github.com/notifications/unsubscribe-auth/AFC0ewYgB3op8uLzG_XDUtNKMlyKNw6Aks5rWiXAgaJpZM4LQp8p .
This function is no longer part of PHP 7 so you might be able to just remove it. There are a couple instances in the code https://github.com/lirantal/daloradius/search?utf8=%E2%9C%93&q=set_magic_quotes_runtime&type=Code
Also, get_magic_quotes_runtime should probably be removed as well, since it will just return FALSE
https://github.com/lirantal/daloradius/search?utf8=%E2%9C%93&q=get_magic_quotes_runtime&type=Code
It seems like it gets the current status of magic quotes, then disables it, then sets it back to the default. Since PHP 7 doesn't even have magic quotes, it will already be disabled so you should be able to just remove all of these calls.
Thanks for chiming in @zanix That function is part of the library used for implementing the notifications. Since I don't want to change it directly (without a specific reason). Is it possible to somehow otherwise mitigate the problem?
How about if we define this function globally in daloRADIUS code for PHP v7 versions only to mitigate the 'function doesn't exist' problem?
You should be able to wrap those with function_exists
if (function_exists('set_magic_quotes_runtime')) {
set_magic_quotes_runtime($value);
}
But they are being called in PHP libraries that are external to daloRADIUS code-base. So I thought we could just define them in a similar way.
Maybe this if @seanmavley can try it out in one of the general PHP files for daloRADIUS:
if (!function_exists('set_magic_quotes_runtime')) {
function set_magic_quotes_runtime($arg1) {
return true;
}
}
That or whatever the function signature for it should probably work.
Ah, I see. I didn't realize these were 3rd party libraries.