Skip to content

Prevent doc-lang entities loading when doc-en file removed#314

Open
jordikroon wants to merge 2 commits into
php:masterfrom
jordikroon:skip-orphan-lang-entities
Open

Prevent doc-lang entities loading when doc-en file removed#314
jordikroon wants to merge 2 commits into
php:masterfrom
jordikroon:skip-orphan-lang-entities

Conversation

@jordikroon

Copy link
Copy Markdown
Member

Prevents https://www.php.net/manual/en/install.windows.tools.php from rendering in Chinese.

@jordikroon jordikroon requested a review from alfsb July 4, 2026 09:01
@jordikroon jordikroon force-pushed the skip-orphan-lang-entities branch from 50499a6 to 8ea9c3a Compare July 4, 2026 09:02
@alfsb

alfsb commented Jul 4, 2026

Copy link
Copy Markdown
Member

This is a difficult one. The change is simple enough, but the consequences are not.

If the URL resolution of that page is wrong (in chasing the page in another language instead of 404 error), then both URL resolution and here should be changed in principle. But if URL resolution is changed (to what behaviour, other than the actual one?), then the change there may be moot. But the consequences are not.

The main point is that this change immediately break all translations, This change will avoid the creation of &install.windows.tools; entity, that is used in all translations, breaking then all.

This is the direct opposite of changes like #303 , that maximize building, even for invalid XML, instead of this change that maximize breaking.

So, first, let's clarify what the final result of URL resolution should be. If URL resolution hits a non existent file, should it:

  1. 404 always;
  2. presents the file in another language, in all cases;
  3. presents the file in another language, except for english;
  4. other behaviour?

The answers delimit where the changes are to be made, and in what direction. In fact, one change I did on #313 is to keep the actual behaviour, as to maximize the building of all translations.

Another way to pose this question is this: should all translations break, because URL resolution is not producing some specific result, for english or in the general case?

@alfsb alfsb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As commented on Discord, I'm slightly opposed to this change.

I’d much prefer to change web-php/error.php into the direct, desired behaviour, than to change the result indirectly, by breaking all translations each time a file is removed (that will happen a lot, now the manual will be splited).

But let's have it open for a while, for further comments.

@jordikroon jordikroon force-pushed the skip-orphan-lang-entities branch from 178bf68 to 8ea9c3a Compare July 4, 2026 21:16
@jordikroon

Copy link
Copy Markdown
Member Author

So policy wise the docs should always fall back to doc-en when a translation for it doesn't exist. doc-en should be considered the main language. Thus if a file doesn't exist it should not translate to the one that comes after it. Instead it should return a 404 instead. If instead we want a redirect in place for it, that should be optional I believe.

Technically said the build didn't fail. Instead it creates an empty entity instead. You can see it in this PR as well, if this would break it the tests would also fail, right?
<!ENTITY install.windows.tools ' '>

However it did result in having an empty entity reference for all translations. Which was an oversight. That should be covered with a check for $lang === "en"

So in short:

  • /en/install.windows.tools.php should give a 404
  • /zh/install.windows.tools.php should resolve

The other way round. If //zh/install.windows.tools.php wouldn't exist but /en/ would, it should fall back to /en/.

@alfsb

alfsb commented Jul 5, 2026

Copy link
Copy Markdown
Member
  • /en/install.windows.tools.php should give a 404

Then web-doc/error.php needs to be changed to not switch to other languages from en.

  • /zh/install.windows.tools.php should resolve

If by resolve this means to render the chinese page, at least for a while, then the &install.windows.tools; should be created and not empty, at least for doc-zh.

For this case, file entity creation should be maximal, as in the file entities are the union of all entities of files of languages in consideration (unique language, or fallback+translation), instead of the intersection of all files of the first language, of languages in consideration.

The other way round. If //zh/install.windows.tools.php wouldn't exist but /en/ would, it should fall back to /en/.

Covered in point one. There is a switch on 404, but en/ is excepcional.

Technically said the build didn't fail. Instead it creates an empty entity instead. You can see it in this PR as well, if this would break it the tests would also fail, right?

Creating a blank file entity will avoid the breaking of translations by the missing entity, but will erase the file's text of all translations immediately. If the "soft erased" file contains IDs or targets of XIncludes, this will start generating ID failures and manual parts will be erased immediatally, before translations can inspect the damage.

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