Skip to content

Check for .env file instead of users table#2199

Merged
nabeelio merged 2 commits into
phpvms:releases/7.0from
BossOfGames:patch-3
Apr 29, 2026
Merged

Check for .env file instead of users table#2199
nabeelio merged 2 commits into
phpvms:releases/7.0from
BossOfGames:patch-3

Conversation

@BossOfGames

@BossOfGames BossOfGames commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

closes #2198

Summary by CodeRabbit

  • Bug Fixes
    • Updated the installer's detection mechanism for existing installations to ensure more reliable system initialization on subsequent setup attempts.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@BossOfGames has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 26 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 78919310-dbed-472c-a636-f775aacfe0b2

📥 Commits

Reviewing files that changed from the base of the PR and between 8a16829 and 05abd5f.

📒 Files selected for processing (1)
  • app/Http/Controllers/System/InstallerController.php

Walkthrough

The installer's already-installed detection gate was refactored from checking database state (users table presence and user count) to checking configuration state (.env file existence), resolving a failure when Schema::hasTable is called without a valid database connection.

Changes

Cohort / File(s) Summary
Installer Configuration Gate
app/Http/Controllers/System/InstallerController.php
Modified the already-installed condition in step1(), step2(), envsetup(), and dbsetup() methods from database introspection (Schema::hasTable() and User::count()) to filesystem detection (.env file existence).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A rabbit hops through the installer's gate,
No .env check? That sealed its fate!
Now we sniff the config file instead,
Before the database makes us dread.
A simpler path, a quicker way—
The system installs bright and gay! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: replacing database table detection with .env file detection in the installer.
Linked Issues check ✅ Passed The code changes directly address issue #2198 by replacing Schema::hasTable calls with .env file existence checks, eliminating the problematic assumption of a valid database connection.
Out of Scope Changes check ✅ Passed All changes are focused on the installer gate logic and directly relate to the linked issue; no out-of-scope modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 45 minutes and 26 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/Http/Controllers/System/InstallerController.php`:
- Around line 225-227: The current check if (file_exists(base_path('.env'))) in
InstallerController prevents dbsetup() from running right after envsetup();
remove or replace this gate so dbsetup() is not blocked by the just-created
.env. Specifically, update the InstallerController method that returns
view('system.installer.errors.already-installed') to stop using
file_exists(base_path('.env')) as the sentinel; instead use a separate marker
(e.g., a dedicated installed flag in .env like APP_INSTALLED, a database/lock
file, or a storage/install.lock) and have dbsetup() proceed when only .env
exists but the installed marker is absent. Ensure references to dbsetup() and
envsetup() remain intact and that the new sentinel check prevents real re-entry
after full install without blocking the immediate redirect from envsetup().
- Around line 164-166: The envsetup() method declares a RedirectResponse return
type but returns a View when .env exists (view
'system.installer.errors.already-installed'), causing a type error; fix by
making the method's declared return type compatible with both responses (e.g.,
change signature to return
Illuminate\Http\Response|Illuminate\Http\RedirectResponse or Symfony Response
union) or change the early-exit to return a RedirectResponse instead (redirect
to an appropriate route) so the actual return type matches the method signature;
update the signature for envsetup() and ensure imports for the chosen Response
class are present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 415920c7-dc33-4319-9b30-e5ae2fa3aa5e

📥 Commits

Reviewing files that changed from the base of the PR and between 0c88769 and 8a16829.

📒 Files selected for processing (1)
  • app/Http/Controllers/System/InstallerController.php

Comment thread app/Http/Controllers/System/InstallerController.php
Comment thread app/Http/Controllers/System/InstallerController.php Outdated
@nabeelio

Copy link
Copy Markdown
Member

This is what happens when I just copy and paste blindy. Thanks for the fix

@nabeelio nabeelio merged commit 29f0a73 into phpvms:releases/7.0 Apr 29, 2026
6 checks passed
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.

3 participants