Skip to content

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

Open
rodriquelca wants to merge 5 commits into
developfrom
feature/FOUR-32025_B
Open

feat(FOUR-32025): Review performance: DB access and queries in login can be cached into redis, images#8931
rodriquelca wants to merge 5 commits into
developfrom
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 packagesapp-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

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