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

Use absolute require file paths #91

Merged
merged 1 commit into from
Jul 27, 2022
Merged

Conversation

dd32
Copy link
Contributor

@dd32 dd32 commented Apr 1, 2022

If a WordPress install has a ABSPATH . 'vendor/autoload.php' file, that will be included here instead of __DIR__ . 'vendor/autoload.php', ultimately causing a PHP fatal error.

This is because PHP resolves relative paths relative to the current working directory (which is the web entry point at ABSPATH . 'index.php') first before trying the current directory.

Eg, in this case, realpath( 'vendor/autoload.php' ) returns /home/example.org/public_html/vendor/autoload.php.

@@ -27,13 +27,13 @@

use SeriouslySimpleStats\Classes\Stats;

require_once 'vendor/autoload.php';

define( 'SSP_STATS_VERSION', '1.3.0' );
define( 'SSP_STATS_DIR_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
Copy link
Contributor Author

@dd32 dd32 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally... this expands to this:

define( 'SSP_STATS_DIR_PATH', trailingslashit( trailingslashit( dirname( __FILE__ ) ) ) );

So it could just be:

Suggested change
define( 'SSP_STATS_DIR_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'SSP_STATS_DIR_PATH', __DIR__ . '/' );

(I'll leave it up to the plugin maintainers if they want to commit this suggestion too)

@paulvanbuuren
Copy link

Am upvoting this like a [expletive].
When are we going to see this merged, please?

davidhund added a commit to ICTU/ictuwp-plugin-Seriously-Simple-Stats-Overrides that referenced this pull request Jul 20, 2022
@zahardev zahardev changed the base branch from master to release/1.4.0 July 27, 2022 18:10
@zahardev zahardev merged commit bd9b312 into CastosHQ:release/1.4.0 Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants