wp-redirect(), php 5.5 and fastCGI - wordpress

I recently had to move a heavily modified wordpress project to a bare bones server. Which I had to install everything from scratch. I tried both ubuntu 14.04 and centos 7. Ubuntu came with php 5.5 and centos with 5.4
My script used to work very well on hostgator. Which was a shared host and fastCGI was enabled there with php 5.4
However when I moved this to the new server any function that used wp-redirect() stopped working. But when I install fastCGI it suddenly starts to work. Never came across this before. DO you have any idea of why this is happening?

This is happening beacuse of the way WordPress is setting header statuses. See the implementation of wp_redirect here https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/pluggable.php#L1147
See the extracted code here:
if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
You can examine the status_header function here status_header definition.
A possible fix would be to amend the function or since PHP 5.4 you can use http_response_code.

Related

SessionHandlerInterface not found when deploy Drupal 10

I've moved a website powered by Drupal 10 from local server (where everything worked fine) to remote, configured PHP 8.2 at the latter, but when I run the website in the browser I get the error
Interface "SessionHandlerInterface" not found in .../core/lib/Drupal/Core/Session/SessionHandler.php on line 15
What else should I do to resolve the issue?
Ok, I've just found out that I should install php82-session. Now it's working

Nginx and ModSecurity

I'm having a strange issue with Ubuntu 18.04 and Nginx with ModSecurity. I've compiled everything correctly and it's working when activating the ModSecurity module, however whenever I activate a rule, I get the following:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Nginx crashes and doesn't serve the page - any ideas?
I'm having this issue in Ubuntu 16.04 as well. This seems to be an issue with the latest version of ModSecurity as seen in this bug: https://github.com/SpiderLabs/ModSecurity/issues/2180
If you downloaded ModSecurity via git, you can use this command to get back to a working version:
git reset --hard d5b93c1013ca9c9a96c75369576b54832e9a2b48
Then clean your ModSecurity build directory and build it again. Once you have ModSecurity rebuild, restart nginx. Once the above bug is closed in GitHub, it will probably be safe to update to the latest version again.
Edit: This issue has been corrected. Simply update and recompile ModSecurity.

Wordpress Database Connection Error - PHP7 using MAMP

I have a localhost development environment using MAMP Pro, with a Wordpress website working successfully using PHP 5.6.8. Changing the host to PHP 7.0.13 (and changing nothing else) results in the error:
Warning: mysqli_real_connect(): (HY000/2002): No such file or
directory in [edited path]/wp-includes/wp-db.php on line 1538
Error establishing a database connection
This either means that the username and password information in your
wp-config.php file is incorrect or we can’t contact the database
server at localhost:3306. This could mean your host’s database server
is down.
Screenshot of Complete Error
wp-config.php definitely has correct username, password, hostname and the database is running. Solutions to similar issues/warnings suggest the MySQL socket path in php.ini file could be wrong, but I have compared that file across the two php versions and they are the same.
I am using the latest versions of MAMP Pro (4.1) and Wordpress (4.7.4), as well as OS X (10.12.4). Also, the website works fine again when changing the host back to PHP 5.6.8.
No idea what else to do/check. Any thoughts are much appreciated.
Wordpress 4.6 later version is not supported in Php 7.0 So please Reinstall Php 5.6 and check .so working
After updating to PHP7 you need to check the path to the mysql.sock.
Open the php.ini file and correct the path
mysql.default_socket = /Applications/MAMP/bin/IDONTKNOW...../mysql.sock

phpDocumentor with PHP 7.1 Return Type Declarations

We are attempting to start using phpDocumentor for a Symfony 3 site running PHP 7.1.
We are using return type declarations on nearly every entity to keep things clean. phpDocumentor does not seem to support this although I see several references to PHP 7 support on their GitHub.
This is the error for every single entity:
Parse Error: Syntax error, unexpected ':', expecting ';' or '{'
I encountered this problem when I migrated from PHP 5 to PHP 7.1 on Ubuntu / Linux, so you need to make sure that you are really using PHP 7.x!
Click on any route name on yourSymfonyprofiler, then click to Configuration(left bottom) and check your PHP Configuration. In my
case 7.1.9-1+ubuntu17.04.1+deb.sury.org+1. Or simply display phpinfo();
If you still using PHP < 7.x that means you need to enable PHP 7.x and disable other versions :
sudo a2enmod php7.1
sudo a2dismod phpx.x
sudo service apache2 restart
Nb: I assume that you are using Ubuntu / Linux.

How can I add PHP-FPM with nginx?

Currently I'm using nginx with HHVM but for some reasons HHVM crashs alot
What I'm trying to do is:
Rplace HHVM with php-fpm
OR
Add php-fpm as fallback
PS: I used this to install nginx + HHVM:
https://github.com/facebook/hhvm/wiki/Getting-Started
I have made this simple script to install latest HHVM/Nginx/MySQL, at once, depending on different Ubuntu Distros. Binaries that are used, come from the official repos that the HHVM team uses. Check var/log/hhvm, error.log file and create issue if you think it is a HHVM.
I use HHVM on servers, and it rarely crashes.

Resources