Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSGroupings fails to minify minified files, missing javascript cache files #10000

Open
sweettbug3 opened this issue Mar 28, 2023 · 0 comments
Open
Labels
Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Needs Assessed Needs the core team to assess Type: Bug Bugs within the core SuiteCRM codebase

Comments

@sweettbug3
Copy link
Contributor

sweettbug3 commented Mar 28, 2023

Issue

JSGroupings lists many files in the grouping that already are minified, and then the code in minify_utils.php checks if it it can find the minified files .. incorrectly.
minify_utils.php

                $already_minified = false;
                $minified_loc = str_replace('.js', '-min.js', $loc);
                if (is_file($minified_loc)) {
                    $loc = $minified_loc;
                    $already_minified = true;
                }

if the file is resize-min.js, it now checks for resize-min-min.js in the baseline, which it does not find. So then it tries to minify the minified file. Unfortunately I had an issue in my deployed instance where it is missing half the cache/include/javascript/*.js files. It throws a fatal error in the (vendor/tedivm/jshrink/src/JShrink/Minifier.php:290) called several levels up by jssource/SugarMin.php:40
Exception in Controller: Unclosed regex pattern at position: 18261
and more debugging shows that it fails to minify a minified file. I believe minifying the minified files causes an error in the minifier: I believe that this is due to the minified files sometimes hitting: tedious/JShrink#87

This code exists in suitecrm 7.13.2 and also in the suitecrm 8.2.4 baseline.

Expected Behavior

JSGroupings should be created consistently in the cache directory.

JSGroupings should not list minified files in the groupings. And perhaps the SuiteCRM baseline should not contain minified files (#7333).

Actual Behavior

When building the cached JS Groupings files, the code tries to minify the already minified javascript. It can run into errors in the minifier: (tedious/JShrink#87) and fail to create some of the cached javascript files.

Possible Fix

Find and replace '-min.js' in jssource/JSGroupings.php with '.js'

Steps to Reproduce

  1. Build system
  2. Deploy on Tanzu cloud foundry
  3. System starts up
  4. look in the cache/include/javascript directory are all of the JSGroupings files there
  5. Go to a page that requires a JSGroupings file, you will get 404 because it doesnt exist.

Context

Your Environment

  • SuiteCRM Version used: 7.13.2, 8.2.4
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Microsoft Edge: 108.0.1462.76 and Firefox 102.6.0esr
  • Environment name and version (e.g. MySQL, PHP 7): PHP 8.0, Mariadb
  • Operating System and version (e.g Ubuntu 16.04): Tanzu PHP buildpack, has cflinuxfs3 runs a flavor of Ubuntu (https://github.com/cloudfoundry/cflinuxfs3/blob/main/receipt.cflinuxfs3.x86_64)
@sweettbug3 sweettbug3 changed the title JSGroupings lists minified files, then tries to minify them again JSGroupings fails to minify minified files, missing javascript cache files Mar 28, 2023
@johnM2401 johnM2401 added Type: Bug Bugs within the core SuiteCRM codebase Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Needs Assessed Needs the core team to assess labels May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:Important Issues & PRs that are important; broken functions, errors - there are workarounds Status:Needs Assessed Needs the core team to assess Type: Bug Bugs within the core SuiteCRM codebase
Projects
None yet
Development

No branches or pull requests

2 participants