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

[CMSP-899] Remove our global for the upload_dir infinite loop #34

Merged
merged 1 commit into from Mar 4, 2024

Conversation

jazzsequence
Copy link
Contributor

@jazzsequence jazzsequence commented Feb 28, 2024

Per WordPress/gutenberg#58839 the issue causing the infinite loop when upload_dir is used inside font_dir should be addressed.

This change removes our workaround for that issue and uses wp_get_upload_dir directly in the font_dir folder.

Note: While these changes have been merged into Gutenberg, they have not yet been merged into core or made part of the latest Gutenberg release. This should not be merged until this can be tested and confirmed working (PHP Unit tests are not sufficient).

Todo:

  • Testing against latest core/Gutenberg

@jazzsequence jazzsequence requested a review from a team as a code owner February 28, 2024 22:15
@ander-murane
Copy link

@pwtyler pwtyler changed the title Remove our global for the upload_dir infinite loop [CMSP-899] Remove our global for the upload_dir infinite loop Mar 1, 2024
@jazzsequence
Copy link
Contributor Author

jazzsequence commented Mar 4, 2024

this PR is confirmed working with WP 6.5-beta3-57756 & Gutenberg 17.8.2 (active and deactivated).
https://admin.dashboard.pantheon.io/sites/61d28a5a-e18a-4d10-8232-6b7d0034d9a5#dev/code

Comment on lines +26 to 31
$upload_dir = wp_get_upload_dir();

// Set our font directory.
$font_dir = $_pantheon_upload_dir['basedir'] . '/fonts';
$font_url = $_pantheon_upload_dir['baseurl'] . '/fonts';
$font_dir = $upload_dir['basedir'] . '/fonts';
$font_url = $upload_dir['baseurl'] . '/fonts';

Copy link
Member

@pwtyler pwtyler Mar 4, 2024

Choose a reason for hiding this comment

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

Can't make a suggestion on the whole function with the structure of the diff— I took a stab at simplifying but I'm swinging back and forth over here whether the following makes it less readable. Apply if you wish.

function pantheon_font_dir( $defaults ) {
	$upload_dir = wp_get_upload_dir();

	// Set our font directory.
	$defaults['basedir'] = $upload_dir['basedir'] . '/fonts';
	$defaults['baseurl'] = $upload_dir['baseurl'] . '/fonts';

	$defaults['path'] = $defaults['basedir'];
	$defaults['url'] = $defaults['baseurl'];
	return $defaults;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like defining $font_dir/$font_url and then saving those to the various $defaults values is more explicit about what's going on.

@jazzsequence jazzsequence merged commit 8898aab into main Mar 4, 2024
7 checks passed
@jazzsequence jazzsequence deleted the gutenberg-58839-remove-global branch March 4, 2024 22:16
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.

None yet

3 participants