Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htaccess regeneration not working from CLI with Bedrock #27

Open
Sidlegionair opened this issue Jul 15, 2020 · 3 comments
Open

htaccess regeneration not working from CLI with Bedrock #27

Sidlegionair opened this issue Jul 15, 2020 · 3 comments
Labels
3rd party compatibility community Issues created by someone outside of our team severity: high Issues which should be resolved as quickly as possible type: bug Indicates an unexpected problem or unintended behavior

Comments

@Sidlegionair
Copy link

Sidlegionair commented Jul 15, 2020

Hi,

The regeneration command does not work when running bedrock (https://roots.io/bedrock). It fails to detect the correct htaccess path from CLI and then it will stop to work here (htaccess.php line 33)

$htaccess_file = get_home_path() . '.htaccess';

if ( ! rocket_direct_filesystem()->is_writable( $htaccess_file ) ) {
	// The file is not writable or does not exist.
	return false;
}
@GeekPress GeekPress added community Issues created by someone outside of our team needs: grooming severity: high Issues which should be resolved as quickly as possible type: bug Indicates an unexpected problem or unintended behavior labels Dec 1, 2020
@iCaspar
Copy link
Contributor

iCaspar commented Dec 1, 2020

Note for grooming: Check possible connection with #22

@crystinutzaa
Copy link
Contributor

crystinutzaa commented Dec 4, 2020

Reproduce the problem ✅

Reproduced on local installation under Flywheel + Bedrock

Identify the root cause ✅

The root cause is related to get_home_path() which brings the / path.
Based on Bedrock documents, it seems that .htaccess file needs to be located under: web/.htaccess and this is the issue.
WP Rocket uses $htaccess_file = get_home_path() . '.htaccess'; which will identify the path to .htaccess file as : /.htaccess which is not accurate.

UPDATE: IT seems this is only from CLI due to wrong ABSPATH coming from Bedrock

The issue is coming from this line:
$home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); from get_home_path() -> file.php WP class
From CLI it seems that SCRIPT_FILENAME = usr/bin/local/wp which will break totally the home_path and also our htaccess path.

Scope a solution ✅

A possible solution is that from CLI to map the get_home_path() without any SCRIPT_FILENAME and modify also flush_rocket_htaccess() function to accept the full path to htaccess file and bypass the default get_home_path()

@wp-media/php what do you think? Did I missed something?

Estimate the effort ✅

Effort [S]

@Tabrisrp
Copy link
Contributor

@Sidlegionair @crystinutzaa Can you retry this issue with v1.2 of the CLI?

One of the changes to fix #22 Could be also fixing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility community Issues created by someone outside of our team severity: high Issues which should be resolved as quickly as possible type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants