Skip to content

feat(FOUR-32025): Review performance: DB access and queries in login can be cached into redis, images - #8931

Merged
pmPaulis merged 6 commits into
epic/FOUR-33730from
feature/FOUR-32025_B
Oct 15, 2026
Merged

pmPaulis merged 6 commits into
epic/FOUR-33730from
feature/FOUR-32025_B

Conversation

@rodriquelca

@rodriquelca rodriquelca commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Issue & Reproduction Steps

Describe the issue this ticket solves and describe how to reproduce the issue (please attach any fixtures used to reproduce the issue).

Solution

  • Fixed asset caching: Removed the random byte generator (bin2hex) from the logo and favicon URLs in Setting.php. Replaced it with the media's updated_at->timestamp. This allows browsers to permanently cache the assets, significantly improving the login page load time.
  • Optimized loginIsDefault(): Refactored this method to directly check the database for a custom logo, eliminating unnecessary string parsing on every render.
perf.mov

How to Test

  1. Go to the login screen with your browser's Network tab open (ensure "Disable cache" is unchecked).
  2. Reload the page multiple times. Verify that the logo and favicon load instantly from the browser's disk/memory cache instead of downloading from the network.
  3. Log in as an admin and upload a new custom login logo.
  4. Return to the login screen and verify the new logo appears immediately (cache invalidation works).
  5. Remove the custom logo and ensure the default logo is properly restored.

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

ci:deploy

@rodriquelca
rodriquelca requested a review from gproly July 23, 2026 18:55
@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-a186b80932.engk8s.processmaker.net

@gproly gproly 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.

Code Review — feature/FOUR-32025_B vs develop

Verdict: Do not merge — 2 blockers.


1. defer breaks ProcessMaker.packages init order

Deferred bundles run after the sync inline that sets packages. Then app-login.js reassigns window.ProcessMaker and resets packages to [].

<script src="{{ mix('builds/login/js/manifest.js') }}" defer></script>
<script src="{{ mix('builds/login/js/vendor.js') }}" defer></script>
<script src="{{ mix('builds/login/js/app-login.js') }}" defer></script>
<script>
  window.ProcessMaker = window.ProcessMaker || {};
  window.ProcessMaker.packages = @json(\App::make(ProcessMaker\Managers\PackageManager::class)->listPackages());
</script>
<script src="{{ mix('js/translations/index.js') }}" defer></script>
window.ProcessMaker = {
  i18n: i18next,
  /**
   * A general use global event bus that can be used
   */
  EventBus: new Vue(),
  packages: [],

Expected order (pre-change): app-login.js → set packages.
Actual order (with defer): set packages → app-login.js overwrites → packages = [].

Fix: keep packages assignment after app-login execution (remove defer, or set packages after boot / merge instead of replace).


2. Login caches never invalidated on branding update

  <link rel="icon" href="{{ cache()->remember('login.favicon', 3600, function () { return \ProcessMaker\Models\Setting::getFavicon(); }) }}">
        <div class="footer">{!! cache()->remember('login.footer_html', 3600, function () use ($loginFooterSetting) { return $loginFooterSetting->config['html']; }) !!}</div>

Invalidation still only clears the old keys:

        if ($request->has('fileFavicon') && $request->input('fileFavicon') !== 'null') {
            $this->uploadFile($setting->refresh(), $request, 'fileFavicon', Setting::COLLECTION_CSS_FAVICON, Setting::DISK_CSS);
            Cache::forget('css-favicon');
        }
        // Custom Login Logo
        if ($request->has('fileLogin') && $request->input('fileLogin') !== 'null') {
            $this->uploadFile($setting->refresh(), $request, 'fileLogin', Setting::COLLECTION_CSS_LOGIN, Setting::DISK_CSS);
            Cache::forget('css-login');
        }

Footer update also never forgets login.footer_html:

    private function setLoginFooter(Request $request)
    {
        $footerContent = $request->input('loginFooter', '');
        // ...
        Setting::updateOrCreate([
            'key' => 'login-footer',
        ], [
            'config' => ['html' => $footerContent],
        ]);
    }

Impact: favicon/footer can stay stale for up to 3600s after admin update.

Fix: Cache::forget('login.favicon') / Cache::forget('login.footer_html') on CSS override + footer save (or drop these Blade caches and rely on existing Setting/media cache-bust).

@rodriquelca

rodriquelca commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor Author

  window

@gproly CR notes was fixed

@rodriquelca rodriquelca reopened this Jul 24, 2026
@rodriquelca
rodriquelca requested a review from gproly July 24, 2026 13:16
@processmaker-sonarqube

Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@vladyrichter

Copy link
Copy Markdown

QA server K8S was successfully deployed https://ci-a186b80932.engk8s.processmaker.net

@rodriquelca
rodriquelca changed the base branch from develop to feature/FOUR-32144 July 28, 2026 15:13
@pmPaulis
pmPaulis changed the base branch from feature/FOUR-32144 to epic/FOUR-33730 October 15, 2026 02:23
@cursor

cursor Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to login branding URL generation, front-end loading hints, and CSS minification; behavior shifts only if custom-login detection or cache busting differed from the old URL-string check.

Overview
Improves login page load performance by making branding asset URLs stable and cache-friendly, and by deferring non-critical scripts.

Setting branding URLs: Stops appending random ?id= query strings on default login logo, icon, and favicon URLs so browsers can cache them across reloads. Custom uploads still get a deterministic ?id= from the media updated_at timestamp so updates bust cache without changing every request. loginIsDefault() now checks whether a custom login image exists on the css-override setting (login media collection) instead of parsing the resolved logo URL for processmaker-login.

Login UI / assets: The logo component uses proper src quoting, fetchpriority="high", and explicit dimensions for the default logo. Auth script partials load login bundles and translations with defer, and ProcessMaker.packages is initialized on DOMContentLoaded. Adds .password-toggle-btn styles (alongside existing toggle selectors). Fixes a minor markup nesting issue in newLogin.blade.php. Webpack Mix now minifies public/css/app.css after compiling app.scss.

Reviewed by Cursor Bugbot for commit 355efdb. Bugbot is set up for automated code reviews on this repo. Configure here.

@decisions-sonarqube

Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 355efdb. Configure here.


foreach ($mediaFile as $media) {
$url = $media->getFullUrl();
return $url . '?id=' . $media->updated_at->timestamp;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale logo after re-upload

High Severity

Returning inside the getMedia loop selects the first collection item. Customize UI appends a new media row on every upload and Spatie orders by order_column ascending, so a replacement keeps the original file URL and updated_at cache key. Browsers then keep serving the old cached login logo, favicon, icon, or sidebar logo.

Additional Locations (3)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 355efdb. Configure here.

@pmPaulis
pmPaulis merged commit cef883f into epic/FOUR-33730 Oct 15, 2026
9 of 10 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.

4 participants