Skip to content

Check theme source files in Virtual Theme Check - #26

Merged
vovayatsyuk merged 1 commit into
masterfrom
feature/virtual-theme-fixer
Aug 20, 2026
Merged

Check theme source files in Virtual Theme Check#26
vovayatsyuk merged 1 commit into
masterfrom
feature/virtual-theme-fixer

Conversation

@vovayatsyuk

Copy link
Copy Markdown
Member

Closes #19

Virtual Theme Check only told you a theme was virtual. It could not tell a theme whose DB flag is simply wrong from one whose source files are unavailable — and Fix All happily made both physical. Converting the second kind is exactly what produced the Required parameter 'theme_dir' was not passed exception behind the missing product images in #19.

Check

Two new columns — Path and Status:

Theme Path Status
Argento Breeze Blank frontend/Swissup/argentobreeze-blank 🔴 Virtual
Breeze Evolution frontend/Swissup/breeze-evolution 🔴 Virtual (Magento can't read registration.php, theme.xml)

registration.php and theme.xml are probed through the theme's registered directory.

Why it never says "removed"

The issue asks to mark a theme "removed" when its source files are gone. The module deliberately does not claim that, because it cannot prove it:

  • ComponentRegistrar::getPath() returning null means not registered, not not present. A theme under app/design whose directory lacks read permission is skipped by the glob() in app/etc/NonComposerComponentRegistration.php with no error at all — files sitting right there, invisible to Magento.
  • file_exists() returning false proves nothing either. If a parent directory lacks execute permission the stat fails identically to the file being absent.

So the status reports what was actually observed — the files could not be read — and leaves the cause to the admin. Same information, no invented certainty.

Fixer

Fix All now, per theme:

  1. chmods any unreadable source file to 0644 and re-checks it — recovers the common permissions case without manual shell work
  2. skips the theme entirely if a file is still unreadable, leaving its virtual flag alone
  3. reports back which themes were skipped, by title

The response carries fixed / skipped counts, so the JS shows the real outcome instead of a hardcoded "Success!" — the table is hidden only when something actually changed, and the button stays available while themes remain skipped.

Structure

The readability check lives in Swissup\Core\Model\Theme\SourceFiles so the block and the controller cannot drift apart: getUnreadable() returns the filenames for the status text, makeReadable() returns whether the theme is safe to convert.

.swissup-config-table and .font-mono are split out of .swissup-modules-table and shared with this table.

Testing

Exercised against a real install for each case — theme registered and readable, registered with theme.xml at chmod 000 (recovered by the fixer), theme absent from disk, and a theme with no theme_path. Fix All verified end to end in the admin.

Making a virtual theme physical while its source files are unavailable is
what breaks the storefront with "Required parameter 'theme_dir' was not
passed", so the check now reports the state of the files and the fixer
refuses to touch the themes it cannot read.

- Virtual Theme Check gets Path and Status columns
- Status names the files Magento can't read. Unreadable file is never
  reported as a removed one - a failed stat cannot tell them apart
- Fix All opens up the permissions of unreadable source files and skips
  the themes that are still unreadable, listing them in the response
- Readability check extracted into Swissup\Core\Model\Theme\SourceFiles,
  shared by the block and the controller
- Config table styles shared between Modules and Virtual Theme Check

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vovayatsyuk
vovayatsyuk requested a balanced review from Copilot August 20, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds source-file validation and safer repair behavior for virtual Magento themes.

Changes:

  • Reports each virtual theme’s path and unreadable source files.
  • Repairs file permissions and skips unsafe conversions.
  • Displays accurate fix results and shares table styling.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Model/Theme/SourceFiles.php Checks and repairs required theme files.
Controller/Adminhtml/Theme/FixVirtualThemes.php Safely converts eligible themes and reports outcomes.
Block/Adminhtml/Config/Form/Field/VirtualCheck.php Collects theme path and source-file status.
Block/Adminhtml/Config/Form/Field/FixVirtualThemes.php Updates the fixer container class.
view/adminhtml/templates/config/field/virtual_check.phtml Renders the expanded status table.
view/adminhtml/templates/config/field/modules.phtml Adopts shared table and monospace styles.
view/adminhtml/web/js/virtualfix.js Handles fixed/skipped results dynamically.
view/adminhtml/web/css/system-config/modules.less Extracts reusable configuration-table styling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@vovayatsyuk
vovayatsyuk merged commit 88915a0 into master Aug 20, 2026
2 checks passed
@vovayatsyuk
vovayatsyuk deleted the feature/virtual-theme-fixer branch August 20, 2026 14:16
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.

Improve virtual theme fixer

2 participants