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

Annotations-related syntax errors in the minified WordPress build #985

Closed
adamziel opened this issue Jan 30, 2024 · 0 comments · Fixed by #986
Closed

Annotations-related syntax errors in the minified WordPress build #985

adamziel opened this issue Jan 30, 2024 · 0 comments · Fixed by #986
Labels
[Aspect] WordPress [Type] Bug An existing feature does not function as intended

Comments

@adamziel
Copy link
Collaborator

Loading WordPress on PHP 7.4 yields the following error:

Parse error: syntax error, unexpected 'has' (T_STRING) in /wordpress/wp-includes/class-wp-recovery-mode-email-service.php on line 4

This is caused by the minification of PHP files via php -w.

PHP 8.0, which is currently used, outputs:

<?php
 #[AllowDynamicProperties] final class WP_Recovery_Mode_Email_Service {  /* ... code ... */ $message = __( 'Howdy!', '

WordPress has a built-in feature ...

The class declaration is treated as a comment by PHP 7.4.

However, PHP 7.4 outputs:

<?php
final class WP_Recovery_Mode_Email_Service {  /* ... code ... */ $message = __( 'Howdy!', '

WordPress has a built-in feature ...

Note the missing annotation.

Proposed solution

I have two ideas:

  1. Postprocess the minified files and insert newline after each annotation
  2. Produce two separate minified WordPress builds for PHP >= 8.0 and PHP < 8.0

I'll explore the first one

@adamziel adamziel added [Type] Bug An existing feature does not function as intended [Aspect] WordPress labels Jan 30, 2024
@adamziel adamziel changed the title WordPress: Syntax error, unexpected 'has' (T_STRING) in /wordpress/wp-includes/class-wp-recovery-mode-email-service.php on line 4 Annotations-related syntax errors in the minified WordPress build Jan 30, 2024
adamziel added a commit that referenced this issue Jan 30, 2024
Adds a newline character after every PHP annotation.

## Rationale

Loading WordPress on PHP 7.4 yields the following error:

```
Parse error: syntax error, unexpected 'has' (T_STRING) in /wordpress/wp-includes/class-wp-recovery-mode-email-service.php on line 4
```

This is caused by the minification of PHP files via `php -w`.

**PHP 8.0, which is currently used, outputs:**

```php
<?php
 #[AllowDynamicProperties] final class WP_Recovery_Mode_Email_Service {  /* ... code ... */ $message = __( 'Howdy!', '

WordPress has a built-in feature ...
```

The class declaration is treated as a comment by PHP 7.4.

**However, PHP 7.4 outputs:**

```php
<?php
final class WP_Recovery_Mode_Email_Service {  /* ... code ... */ $message = __( 'Howdy!', '

WordPress has a built-in feature ...
```

Note the missing annotation.

Closes #985

## Testing instructions

Confirm the CI tests pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Aspect] WordPress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant