🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@WilliamAlmeida
Copy link

Description

This pull request ensures that the $this->OTLtags['Plus'] index is always initialized before being used in the FONT-VARIANT-POSITION case.
Previously, if the Plus index was not set, PHP would throw an "Undefined index: Plus" error.

With this change, the code checks whether $this->OTLtags['Plus'] is set.
If not, it initializes it as an empty string before any manipulation.
This prevents runtime errors and improves reliability when processing font variant positions.


Motivation and Rationale

  • Avoid PHP notices and potential fatal errors when the Plus key is not initialized.
  • Multiple code paths can reach this logic without guaranteeing that $this->OTLtags['Plus'] exists, especially when handling new or edge-case font variants.
  • This fix makes the code more robust and easier to maintain.

Impact

  • Prevents “Undefined index: Plus” errors.
  • Improves stability when handling font-position variants.
  • No impact on other functionality or tags.

Testing

  • Verified that the error no longer occurs in scenarios where FONT-VARIANT-POSITION is set without prior initialization of $this->OTLtags['Plus'].
  • All existing and new unit tests for font-variant processing pass successfully.

Changelog

  • Added: Always initialize $this->OTLtags['Plus'] before use in FONT-VARIANT-POSITION to prevent undefined index errors.

This pull request ensures that the $this->OTLtags['Plus'] index is always initialized before being used in the FONT-VARIANT-POSITION case. Previously, if the 'Plus' index was not set, accessing it would result in an "Undefined index: Plus" PHP error.

With this change, the code now checks if $this->OTLtags['Plus'] is set. If not, it initializes it as an empty string before any manipulation. This prevents runtime errors and improves code reliability when processing font variant positions.

Motivation and Rationale

The change is necessary to avoid PHP notices and potential fatal errors when the 'Plus' tag is not initialized. Many code paths can reach this logic without guaranteeing that $this->OTLtags['Plus'] exists, especially when processing new or edge-case font variants. This fix makes the code more robust and easier to maintain.

Impact

Prevents "Undefined index: Plus" errors.
Improves stability when handling font position variants.
Does not affect any other functionality or tags.
Testing

Verified that the error no longer occurs in scenarios where FONT-VARIANT-POSITION is set without prior initialization of $this->OTLtags['Plus'].
Existing and new unit tests for font variant processing pass.
Changelog

Added: Always initialize $this->OTLtags['Plus'] before use in FONT-VARIANT-POSITION to prevent undefined index errors.
@finwe
Copy link
Member

finwe commented Sep 18, 2025

Thank you for the PR. Please provide a unit test representing the undefined index error without this code change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants