Skip to content

chore: add global definitions for paths to simplify includes#694

Merged
mcdurdin merged 1 commit intomasterfrom
chore/prepend-header
Mar 25, 2026
Merged

chore: add global definitions for paths to simplify includes#694
mcdurdin merged 1 commit intomasterfrom
chore/prepend-header

Conversation

@mcdurdin
Copy link
Copy Markdown
Member

Adds _includes/prepended_header.php which defines _KEYMANCOM_INCLUDES and _KEYMANCOM_COMMON, which are then available to every .php page on the site.

Fixed up all require/require_once references to use the appropriate defines consistently. There remain some require_once references that do not link _KEYMANCOM_* -- these are for other files that are not under either of those include folders.

Note: regex (require_once|require|include|include_once)\b(?! _KEYMANCOM) will find all include/require[_once] references (and a few irrelevancies). Removing the local refs (e.g. to session.php in keyboards/) leaves the following files which don't use these paths and could be further cleaned up in a future PR -- but these are low priority and low risk:

7 results - 4 files

_includes\autoload.php:
   2:   require_once __DIR__ . '/../vendor/autoload.php';
   9:         $success = include(__DIR__ . "/locale/{$filename}.php");
  11:         $success = include(__DIR__ . "/2020/{$filename}.php");
  24:       $success = include(__DIR__ . "/../_common/{$filename}.php");

_includes\2020\Util.php:
  19:           require_once($_SERVER['DOCUMENT_ROOT'].'/cdn/deploy/cdn.php');

_includes\includes\servervars.php:
  19:   require_once __DIR__ . '/../../vendor/autoload.php';

_includes\locale\Locale.php:
  86:         self::$strings[$domain][$locale]-> strings = require $currentLocaleFilename;

Test-bot: skip

@keymanapp-test-bot
Copy link
Copy Markdown

User Test Results

Test specification and instructions

User tests are not required

@mcdurdin mcdurdin requested a review from darcywong00 March 24, 2026 15:44
@github-actions github-actions bot added the chore label Mar 24, 2026
@keymanapp-test-bot keymanapp-test-bot bot added this to the A19S25 milestone Mar 24, 2026
@github-project-automation github-project-automation bot moved this to Todo in Keyman Mar 24, 2026
# Also exclude testing locales for each link: 'lang=*'
builder_echo blue "---- Testing links"
npx broken-link-checker http://localhost:8053/_test --recursive --ordered ---host-requests 50 -e --filter-level 3 --exclude '*/donate' --exclude '*lang=*' | tee blc.log
npx broken-link-checker http://localhost:8053/_test --recursive --ordered ---host-requests 50 -e --filter-level 3 --exclude '*/donate' --exclude='/downloads/releases/*' --exclude '*lang=*' | tee blc.log
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Skipping the /downloads/releases/ paths shortcuts a lot of tests. There's a risk there if we change those pages of course.

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.

Do we adjust the link checker in the GHA too?

# Exclude checking locales for each link 'lang=*'
run: |
set +e
set +o pipefail
npx broken-link-checker http://localhost:8053/_test --recursive --ordered ---host-requests 50 -e --filter-level 3 --exclude '*/donate' --exclude '*lang=*' | tee blc.log
echo "BLC_RESULT=${PIPESTATUS[0]}" >> "$GITHUB_ENV"

Copy link
Copy Markdown
Member Author

@mcdurdin mcdurdin Mar 25, 2026

Choose a reason for hiding this comment

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

Do we adjust the link checker in the GHA too?

I'll do that as a separate PR, perhaps. In some ways it's better to keep the separate one.

I saw something that concerned me with the link checker -- it seemed to continue to operate with pages with server errors. I will have to review to make sure we aren't missing those.

Adds _includes/prepended_header.php which defines `_KEYMANCOM_INCLUDES`
and `_KEYMANCOM_COMMON`, which are then available to every .php page on
the site.

Fixed up all `require`/`require_once` references to use the appropriate
defines consistently. There remain some `require_once` references that
do not link `_KEYMANCOM_*` -- these are for other files that are not
under either of those include folders.

Test-bot: skip
@mcdurdin mcdurdin force-pushed the chore/prepend-header branch from 6d3345a to d591cc4 Compare March 24, 2026 15:59
Copy link
Copy Markdown
Contributor

@darcywong00 darcywong00 left a comment

Choose a reason for hiding this comment

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

lgtm

# Also exclude testing locales for each link: 'lang=*'
builder_echo blue "---- Testing links"
npx broken-link-checker http://localhost:8053/_test --recursive --ordered ---host-requests 50 -e --filter-level 3 --exclude '*/donate' --exclude '*lang=*' | tee blc.log
npx broken-link-checker http://localhost:8053/_test --recursive --ordered ---host-requests 50 -e --filter-level 3 --exclude '*/donate' --exclude='/downloads/releases/*' --exclude '*lang=*' | tee blc.log
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.

Do we adjust the link checker in the GHA too?

# Exclude checking locales for each link 'lang=*'
run: |
set +e
set +o pipefail
npx broken-link-checker http://localhost:8053/_test --recursive --ordered ---host-requests 50 -e --filter-level 3 --exclude '*/donate' --exclude '*lang=*' | tee blc.log
echo "BLC_RESULT=${PIPESTATUS[0]}" >> "$GITHUB_ENV"

@mcdurdin mcdurdin merged commit 2781882 into master Mar 25, 2026
5 checks passed
@mcdurdin mcdurdin deleted the chore/prepend-header branch March 25, 2026 04:37
@github-project-automation github-project-automation bot moved this from Todo to Done in Keyman Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants