23

I recently moved my website into a new server , my database is perfectly configured but i keep getting this error and can't access my wp-admin :

Use of undefined constant REQUEST_URI - assumed 'REQUEST_URI' in /www/docs/wordpress/wp-content/themes/twentyfifteen/functions.php on line 73

I get this error with every theme and even with all my plugins disabled .

Navneet Krishna
  • 5,009
  • 5
  • 25
  • 44
user3501194
  • 385
  • 1
  • 2
  • 12
  • 3
    You `moved`your website. What are the previous and new environments? WordPress, PHP and Apache versions. – Anthony May 14 '18 at 15:23
  • 1
    This would best be handled by the theme's developers I think. – Adam May 14 '18 at 15:23
  • 1
    Could be that your new server has `display_errors` enabled, or just a higher `error_reporting` level. Both of these are set in **php.ini**. The actual fix will be to quote the REQUEST_URI string on that line, so that it stops raising the notice in the first place. – iainn May 14 '18 at 15:29
  • Did you move a live site to a development environment? – RiggsFolly May 14 '18 at 15:31
  • 1
    It may be linked with something like [this question](https://stackoverflow.com/q/556818/4932315). If so, it's up to the theme's developers to fix it. – Anthony May 14 '18 at 15:32
  • Yes I moved from PHP Version 5.5.9-1ubuntu4.24 to PHP version: 5.4.45-0+deb7u8 – user3501194 May 14 '18 at 15:35
  • @adam I get this error with every theme even the basic wordpress ones like 2015* – user3501194 May 14 '18 at 15:38
  • @RiggsFolly yes – user3501194 May 14 '18 at 15:38
  • 1
    Dev environment are normally configured to show you all the error message while live environment are configured not to. So this error has probably been there forever, just now you are seeing it. – RiggsFolly May 14 '18 at 15:41
  • Also its not normally a good idea to move any code to an older version of the interpreter i.e. PHP5.5 back to PHP 5.4. I would suggest upgrading you dev environment to the same version of Php as is on your live environment – RiggsFolly May 14 '18 at 15:42
  • @RiggsFollyYes i know but I just got the logins for the live server and the university admins are not very available . – user3501194 May 14 '18 at 15:47
  • thanks to @AnthonyB I fixed the error myself but now i get error 500 with debug true and white screen with debug false . I already increased my memory , disabled my theme and all my plugins – user3501194 May 14 '18 at 16:58
  • @user3501194 check the error logs: [Debugging in WordPress](https://codex.wordpress.org/Debugging_in_WordPress). – cabrerahector May 14 '18 at 17:28
  • You can set `display_errors=1` and `error_reporting=E_ALL` in your `php.ini`, and also set the constant `WP_DEBUG=true` in `wp-config.php` – Anthony May 15 '18 at 07:24
  • I installed php 5.6 on the server and quoted the variable now all works fine thanks – user3501194 May 15 '18 at 22:29

5 Answers5

55
$path = $_SERVER[‘HTTP_HOST’] . $_SERVER[REQUEST_URI];

to

$path = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
Tim Diekmann
  • 7,755
  • 11
  • 41
  • 69
Babu
  • 566
  • 6
  • 5
  • Is this a new PHP version issue? Why did this suddenly occur? The fix worked, thanks – TetraDev Mar 20 '19 at 21:56
  • Thanks it worked! what is the reason for this issue – Malinda Peiris Mar 24 '20 at 13:45
  • 1
    The faulty code is part of the **WP-VCD malware**, and correcting it makes the website work again, but it also makes the malware work again. See this WordFence whitepaper for more information: https://www.wordfence.com/wp-content/uploads/2019/11/Wordfence-WP-VCD-Whitepaper.pdf I have suggested edits in this answer to reflect this. The malware affects the users of the website, attempting to install a malicious browser plugin, so it's bad. And yes, @TetraDev, it's an issue triggered by an upgrade of PHP; before that, the malware worked fine and flew under the radar. – Jesper May 17 '20 at 14:22
6

Warning: Use of undefined constant REQUEST_URI - assumed 'REQUEST_URI' in /www/docs/wordpress/wp-content/themes/twentyfifteen/functions.php on line 73

The above error show on my site https://cartvela.org/ and I am changing

$path = $_SERVER[‘HTTP_HOST’] . $_SERVER[REQUEST_URI];

to

$path = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

With that code adjustment, my site comes back and error is gone

AS Mackay
  • 2,831
  • 9
  • 19
  • 25
  • 1
    Just want to make everyone aware that the faulty code is part of the **WP-VCD malware**, and correcting it makes the website work again but also makes the malware work again. See this WordFence whitepaper for more information: https://www.wordfence.com/wp-content/uploads/2019/11/Wordfence-WP-VCD-Whitepaper.pdf The malware affects the users of the website, attempting to install a malicious browser plugin, so it's bad. – Jesper May 17 '20 at 14:27
3

Convert

$path = $_SERVER[‘HTTP_HOST’] . $_SERVER[REQUEST_URI];

to

$path = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
sayhan
  • 1,168
  • 1
  • 16
  • 22
3

Be very careful when this warning occures because this can be a side effect of the wp-vcd.php malware. Check if the file wp-includes\wp-vcd.php exists. If yes, you are infected and you should not fix this warning but instead reinstall wordpress. And avoid installing nulled themes/plugins.

Fee
  • 719
  • 9
  • 24
  • 1
    You are right, the line number 73 gives this away as the **WP-VCD malware**, and correcting the bug in the malware as the other answers show how to do makes the website work again but also makes the malware work again. For anyone reading this, see this WordFence whitepaper for more information: https://www.wordfence.com/wp-content/uploads/2019/11/Wordfence-WP-VCD-Whitepaper.pdf The malware affects the users of the website and attempts to trick them into installing a malicious browser plugin, so it's bad. – Jesper May 17 '20 at 14:31
0
  1. Edit the file C:\xampp\htdocs\ngn.com\wp-content\themes\mts_splash\functions.php, proceed to line 73 and look for REQUEST_URI. Put single quotes around it (REQUEST_URI) and save the file.

  2. Proceed to WordPress and tell them about that problem

  3. Next time, proceed to WordPress immediately, as this is not a Xampp issue, its a WordPress issue.

Red Boy
  • 5,429
  • 3
  • 28
  • 41
  • 1
    The code is part of the **WP-VCD malware**, and correcting the bug makes the website work again but also makes the malware work again. See this WordFence whitepaper for more information: https://www.wordfence.com/wp-content/uploads/2019/11/Wordfence-WP-VCD-Whitepaper.pdf The bug is not a WordPress issue. The malware is bad, as it affects the users of the website and attempts to trick them into installing a malicious browser plugin. – Jesper May 17 '20 at 14:34