Skip to content

♻️ refactor(features): remove feature hooks left without implementers - #4750

Open
mauretto78 wants to merge 3 commits into
developfrom
refactor/remove-unimplemented-feature-hooks
Open

♻️ refactor(features): remove feature hooks left without implementers#4750
mauretto78 wants to merge 3 commits into
developfrom
refactor/remove-unimplemented-feature-hooks

Conversation

@mauretto78

Copy link
Copy Markdown
Contributor

Summary

Three feature-hook event classes were dispatched from core but implemented only by the Airbnb plugin,
whose handlers were a no-op, inert, and superseded by a core setting respectively. With the plugin
handlers gone (matecat/airbnb_plugin#122) the events, their dispatch sites and the plumbing that fed
them have no remaining purpose, so they are removed here.

Also drops BaseFeature::getBuildFiles(), which no plugin or core code has ever called.

Type

  • feat — new user-facing feature
  • fix — bug fix
  • refactor — restructure without behavior change
  • chore — build, deps, config, docs
  • perf — performance improvement
  • test — test coverage

Changes

File Change
lib/Model/FeaturesBase/Hook/Event/Filter/ProjectUrlsEvent.php deleted — sole implementer was an identity pass-through
lib/Model/FeaturesBase/Hook/Event/Filter/FilterRevisionChangeNotificationListEvent.php deleted — sole implementer needed a config key that exists in no environment
lib/Model/FeaturesBase/Hook/Event/Filter/AnalysisBeforeMTGetContributionEvent.php deleted — sole implementer duplicated the per-project enable_mt_analysis setting
lib/Controller/API/V2/UrlsController.php, lib/View/API/V2/Json/Job.php drop the ProjectUrls dispatch; render the formatted object directly
lib/View/API/V2/Json/Job.php, lib/View/API/V3/Json/Chunk.php fillUrls() no longer needs the FeatureSet argument — parameter and call sites updated
lib/Plugins/Features/ReviewExtended/ReviewedWordCountModel.php drop the recipient-list dispatch from _sendNotificationEmail()
lib/Utils/AsyncTasks/Workers/Analysis/TMAnalysis/Service/EngineService.php drop the pre-MT dispatch from getMTTranslation()
lib/Plugins/Features/BaseFeature.php remove getBuildFiles() — no callers anywhere
tests/unit/Core/** drop the cases covering the removed events and helper; update the two fillUrls() overrides for the new signature
plugins/airbnb submodule bumped to the matching plugin commit

Testing

  • vendor/bin/phpunit --exclude-group=ExternalServices --no-coverage passes
  • ./vendor/bin/phpstan passes (0 errors, with baseline)
  • Manual testing performed (describe below)
  • New tests added for changed behavior
  • Regression tests added for bug fixes

PHPStan level 8 over the whole repository → 0 errors.
The directly affected suites — UrlsControllerTest, BaseFeatureTest, FilterEventSubclassTest
pass (91 tests, 180 assertions), as does plugins/airbnb/tests (89 tests, 108 assertions).

The full suite on the development machine reports pre-existing
SQLSTATE[HY000] [2002] Connection refused errors because no database is reachable from the
container. The only two genuine assertion failures, both in
EngineServiceUnitTest::getMTTranslation_*, were verified to fail identically at HEAD with these
changes stashed, so they are unrelated.

AI Disclosure

  • No AI tools were used in this PR
  • AI tools were used — name the agent/tool below

Claude Code (claude-opus-5)

Notes

Merge order. matecat/airbnb_plugin#122 must merge first. Until it does, the submodule gitlink here
points at a commit that lives on the plugin's remove-obsolete-code branch rather than its master.

One intentional behaviour change, inherited from the plugin side: the Airbnb handler used to flip
the engine's analysis flag back to false after EngineService had set it, which made the
skip-analysis gate in AbstractEngine::call() unreachable and forced MMT to be queried during
analysis regardless of the project setting. Airbnb projects will now honour their own
enable_mt_analysis value like every other customer.

Follow-up, not in this PR. The plugin's characterLengthCount() hook stays for now.
character_counter_mode (google_ads / exclude_cjk / all_one) already generalises that
behaviour, but it is read only by public/js/utils/charsSizeCounterUtil.js
SizeRestriction::getCleanedStringLength() still hardcodes mb_strlen + CJK + emoji and ignores the
job metadata. Teaching the PHP counter to honour the setting would let the last plugin hook and
CharacterLengthCountEvent go too.

ProjectUrlsEvent, FilterRevisionChangeNotificationListEvent and
AnalysisBeforeMTGetContributionEvent were dispatched only for the airbnb plugin, whose
handlers were respectively a no-op, inert without a config key, and superseded by the
per-project enable_mt_analysis setting.

Removing the ProjectUrls dispatch also leaves fillUrls() with no use for the FeatureSet it
was handed, so the parameter goes with it.
…aseFeature

No plugin or core code ever called it. Plugins that ship static assets register them
through their own decorators instead.
Pairs with matecat/airbnb_plugin#122, which removes the plugin-side handlers for the three
hooks deleted here. That PR must merge first so this commit is reachable from the plugin's
master branch.
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

🧪 Test-Guard Report

✅ PASS — All changed source files have adequate test coverage.

Coverage Analysis: ❌ FAIL

Changed lines: 100.0% covered (threshold: 80%)

📋 9 files: 3 ❌ fail, 6 ✅ pass
File Verdict Reason
lib/View/API/V2/Json/Job.php ✅ pass 100% diff coverage ≥ 80% threshold
lib/View/API/V3/Json/Chunk.php ✅ pass 100% diff coverage ≥ 80% threshold
lib/Model/FeaturesBase/Hook/Event/Filter/AnalysisBeforeMTGetContributionEvent.php ❌ fail not in coverage report
lib/Model/FeaturesBase/Hook/Event/Filter/FilterRevisionChangeNotificationListEvent.php ❌ fail not in coverage report
lib/Model/FeaturesBase/Hook/Event/Filter/ProjectUrlsEvent.php ❌ fail not in coverage report
lib/Controller/API/V2/UrlsController.php ✅ pass in coverage report, but no executable lines changed
lib/Plugins/Features/BaseFeature.php ✅ pass in coverage report, but no executable lines changed
lib/Plugins/Features/ReviewExtended/ReviewedWordCountModel.php ✅ pass in coverage report, but no executable lines changed
lib/Utils/AsyncTasks/Workers/Analysis/TMAnalysis/Service/EngineService.php ✅ pass in coverage report, but no executable lines changed

Test File Matching: ❌ FAIL

File matching: 4 pass, 2 warning, 3 fail

📋 9 files: 3 ❌ fail, 2 ⚠️ warning, 4 ✅ pass
File Verdict Reason
lib/Controller/API/V2/UrlsController.php ✅ pass Test file modified in PR: tests/unit/Core/Controllers/UrlsControllerTest.php
lib/Model/FeaturesBase/Hook/Event/Filter/AnalysisBeforeMTGetContributionEvent.php ❌ fail No matching test file found
lib/Model/FeaturesBase/Hook/Event/Filter/FilterRevisionChangeNotificationListEvent.php ❌ fail No matching test file found
lib/Model/FeaturesBase/Hook/Event/Filter/ProjectUrlsEvent.php ❌ fail No matching test file found
lib/Plugins/Features/BaseFeature.php ✅ pass Test file modified in PR: tests/unit/Core/Plugins/Features/BaseFeatureTest.php
lib/Plugins/Features/ReviewExtended/ReviewedWordCountModel.php ⚠️ warning Test file exists (tests/unit/Core/Features/ReviewExtended/ReviewedWordCountModelTest.php) but was not modified in this PR
lib/Utils/AsyncTasks/Workers/Analysis/TMAnalysis/Service/EngineService.php ⚠️ warning Test file exists (tests/unit/Core/Workers/TMAnalysisV2/EngineServiceTest.php) but was not modified in this PR
lib/View/API/V2/Json/Job.php ✅ pass Test file modified in PR: tests/unit/Core/View/API/V2/Json/JobTest.php
lib/View/API/V3/Json/Chunk.php ✅ pass Test file modified in PR: tests/unit/Core/View/API/V3/Json/ChunkTest.php

Per-File Evaluation: ✅ PASS

All files resolved by deterministic shortcuts.

📋 9 files: 2 ✅ pass, 7 ⏭️ skip
File Verdict Reason
lib/Controller/API/V2/UrlsController.php ⏭️ skip shortcut → in coverage report, but no executable lines changed
lib/Model/FeaturesBase/Hook/Event/Filter/AnalysisBeforeMTGetContributionEvent.php ⏭️ skip shortcut → deleted file
lib/Model/FeaturesBase/Hook/Event/Filter/FilterRevisionChangeNotificationListEvent.php ⏭️ skip shortcut → deleted file
lib/Model/FeaturesBase/Hook/Event/Filter/ProjectUrlsEvent.php ⏭️ skip shortcut → deleted file
lib/Plugins/Features/BaseFeature.php ⏭️ skip shortcut → in coverage report, but no executable lines changed
lib/Plugins/Features/ReviewExtended/ReviewedWordCountModel.php ⏭️ skip shortcut → in coverage report, but no executable lines changed
lib/Utils/AsyncTasks/Workers/Analysis/TMAnalysis/Service/EngineService.php ⏭️ skip shortcut → in coverage report, but no executable lines changed
lib/View/API/V2/Json/Job.php ✅ pass shortcut → coverage 100% ≥ 80%
lib/View/API/V3/Json/Chunk.php ✅ pass shortcut → coverage 100% ≥ 80%

Result: ✅ PASS

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.

1 participant