Skip to content

[paths] Store relative paths instead of absolute paths to the storage.#198

Merged
vovafeldman merged 6 commits intodevelopfrom
feature/store-relative-paths-to-sdk-storage
Nov 12, 2017
Merged

[paths] Store relative paths instead of absolute paths to the storage.#198
vovafeldman merged 6 commits intodevelopfrom
feature/store-relative-paths-to-sdk-storage

Conversation

@fajardoleo
Copy link
Copy Markdown
Contributor

No description provided.

@fajardoleo fajardoleo self-assigned this Nov 6, 2017
return;
}

if ( version_compare( $sdk_prev_version, '1.2.2.11', '<' ) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo the upcoming version is 1.2.3, not 1.2.2.11. This is also relevant for all comments.

*
* @return string
*/
private function get_absolute_path( $path, $module_type = false ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo you're using tabs instead of spaces. Please modify your settings to use 4 spaces instead of tabs and realign all the changes.

get_theme_root() );

if ( 0 !== strpos( $path, $module_root_dir ) ) {
$path = ( $module_root_dir . '/' . $path );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo I'd recommend using $path = trailingslashit( $module_root_dir ) . $path; instead to avoid situations where some environments may already have a trailing slash at the end of the plugin/theme path variable.

) {
if ( file_exists( $this->_storage->plugin_main_file->prev_path ) ) {
return $this->_storage->plugin_main_file->prev_path;
$absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo I noticed that you've forgot to migrate $this->_storage->plugin_main_file->prev_path to the relative path structure (in the migration logic, not here).

if ( $caller_file_path == fs_normalize_path( realpath( trailingslashit( $themes_dir ) . basename( dirname( $caller_file_path ) ) . '/' . basename( $caller_file_path ) ) ) ) {
$module_type = WP_FS__MODULE_TYPE_THEME;
$caller_file_candidate = $caller_file_path;
$caller_file_candidate = basename( dirname( $caller_file_path ) ) .
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo I'll add a comment that this calculates the relative path of the theme + also add an inline example in the comment.

* @return string
*/
function get_plugin_basename() {
function get_plugin_basename( $plugin_main_file_path = false ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo you've added $plugin_main_file_path as an argument, but I don't see any call to this method with an argument.

*
* @return string
*/
private function get_relative_path( $path ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo this method is confusing. It gets a $path argument but it doesn't really work for any path beside the path of the current context module.

$this->is_plugin() :
( WP_FS__MODULE_TYPE_PLUGIN === $module_type );

$module_root_dir = fs_normalize_path( $is_plugin ?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fajardoleo I suggest creating a helper method to calculate the get_module_root_dir_path( $module_type = false ) since you have it here and in get_relative_path().

@vovafeldman vovafeldman merged commit 07bbe92 into develop Nov 12, 2017
@vovafeldman vovafeldman deleted the feature/store-relative-paths-to-sdk-storage branch November 12, 2017 14:27
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.

2 participants