Remove dead code and wire generated-image cleanup (ImageGenerator, ImageHelper::cleanup, buildOrganization) #104

Closed
opened 2026-06-29 14:20:11 +00:00 by jmiller · 3 comments
Owner

Problem

Several unused code paths ship, and one of them is a real disk-growth leak:

  • ImageGenerator (whole class)generate() has no callers in source/; ships a TTF-font-dependent feature that is never wired up.
  • ImageHelper::cleanup() — has no callers, so the generated-image cache in images/mokoog/generated/ grows unbounded over time. (ImageHelper::validate() is also unused.)
  • JsonLdBuilder::buildOrganization() (:152) — no callers.

Fix

  • Either delete ImageGenerator or wire it to an actual feature.
  • Call ImageHelper::cleanup() on a schedule (e.g. a console/cron task or on plugin save) with an age/size cap so generated images are pruned. (This part is a real leak — prioritise.)
  • Remove or use buildOrganization() / ImageHelper::validate().

Note

Also fold in the duplicated crop logic: ImageHelper::resizeToSize() is a near-verbatim copy of resize() — consolidate.

## Problem Several unused code paths ship, and one of them is a real disk-growth leak: - **`ImageGenerator` (whole class)** — `generate()` has no callers in `source/`; ships a TTF-font-dependent feature that is never wired up. - **`ImageHelper::cleanup()`** — has **no callers**, so the generated-image cache in `images/mokoog/generated/` grows **unbounded** over time. (`ImageHelper::validate()` is also unused.) - **`JsonLdBuilder::buildOrganization()`** (`:152`) — no callers. ## Fix - Either delete `ImageGenerator` or wire it to an actual feature. - Call `ImageHelper::cleanup()` on a schedule (e.g. a console/cron task or on plugin save) with an age/size cap so generated images are pruned. **(This part is a real leak — prioritise.)** - Remove or use `buildOrganization()` / `ImageHelper::validate()`. ## Note Also fold in the duplicated crop logic: `ImageHelper::resizeToSize()` is a near-verbatim copy of `resize()` — consolidate.
jmiller added this to the Code Quality & Testing milestone 2026-06-29 14:20:11 +00:00
jmiller added the enhancement label 2026-06-29 14:20:11 +00:00
Author
Owner

Branch created: feature/104-remove-dead-code-and-wire-generated-imag

git fetch origin
git checkout feature/104-remove-dead-code-and-wire-generated-imag
Branch created: [`feature/104-remove-dead-code-and-wire-generated-imag`](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteOpenGraph/src/branch/feature/104-remove-dead-code-and-wire-generated-imag) ```bash git fetch origin git checkout feature/104-remove-dead-code-and-wire-generated-imag ```
Author
Owner

Mostly fixed in PR #111 (merged to dev):

  • Deleted the unused ImageGenerator class and JsonLdBuilder::buildOrganization().
  • Disk leak fixed — added ImageHelper::pruneOldFiles() (recursively deletes generated images older than 30 days, skips index.html) and call it on content save, so the generated-image cache is now bounded.

Minor leftovers (kept open): ImageHelper::validate() is still unused, and resizeToSize() duplicates most of resize() — both are cosmetic cleanups, not the leak. Closing the leak portion; leaving this open for the consolidation, or it can be closed if you'd rather track that separately.

**Mostly fixed in PR #111** (merged to `dev`): - ✅ Deleted the unused `ImageGenerator` class and `JsonLdBuilder::buildOrganization()`. - ✅ **Disk leak fixed** — added `ImageHelper::pruneOldFiles()` (recursively deletes generated images older than 30 days, skips `index.html`) and call it on content save, so the generated-image cache is now bounded. **Minor leftovers (kept open):** `ImageHelper::validate()` is still unused, and `resizeToSize()` duplicates most of `resize()` — both are cosmetic cleanups, not the leak. Closing the leak portion; leaving this open for the consolidation, or it can be closed if you'd rather track that separately.
Author
Owner

Consolidation done in PR #117 (merged to dev): resize() is now a thin wrapper over resizeToSize() (gained a $quality param), removing ~80 lines of duplicated crop/encode logic with identical output paths/files (behavior unchanged), and the unused ImageHelper::validate() was removed. Combined with the earlier dead-code removal + image-cache pruning (PR #111), all of #104 is now resolved. Closing.

Consolidation done in PR #117 (merged to `dev`): `resize()` is now a thin wrapper over `resizeToSize()` (gained a `$quality` param), removing ~80 lines of duplicated crop/encode logic with identical output paths/files (behavior unchanged), and the unused `ImageHelper::validate()` was removed. Combined with the earlier dead-code removal + image-cache pruning (PR #111), all of #104 is now resolved. Closing.
Sign in to join this conversation.
Priority Medium
Type Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoSuiteOpenGraph#104