Tagged: concatenation, merge, minify
-
AuthorPosts
-
May 8, 2019 at 8:01 pm #1098569
For some reason the merging of stylesheets and scripts is not working when I select the Enable option under the Performance tab of the Theme settings.
When I disable merging, all of the JS and CSS files are loaded individually. When I enable them, nothing changes.Looking in the database under the wp_options table I see three options:
aviaAsset_avia-merged-styles "a:2:{s:51:""avia-merged-styles-8a8ca35c6fe58fc87e9d9bb3deebeadd"";s:21:""error-generating-file"";s:51:""avia-merged-styles-ba93e0f1159df5cfe1d5fa48d69977c7"";s:21:""error-generating-file"";}" aviaAsset_avia-merged-styles "a:2:{s:51:""avia-merged-styles-8a8ca35c6fe58fc87e9d9bb3deebeadd"";s:21:""error-generating-file"";s:51:""avia-merged-styles-ba93e0f1159df5cfe1d5fa48d69977c7"";s:21:""error-generating-file"";}" aviaAsset_avia-footer-scripts "a:2:{s:52:""avia-footer-scripts-01a4d3207943c902ca6293faf3c9c6b7"";s:21:""error-generating-file"";s:52:""avia-footer-scripts-730f76d9d70aa35ae3fe88e81b91943f"";s:21:""error-generating-file"";}"
For some reason, they all say
error-generating-file
, which upon further investigation, theasset-manager.class.php
can’t seem to generate the minified file.
How can I determine why it can’t generate the file?May 10, 2019 at 3:35 am #1099123Hey Michael,
Could you check the file permissions for the uploads/dynamic_avia folder please?
Best regards,
RikardMay 10, 2019 at 9:05 pm #1099412File permissions are:
rwx rwx r-x (775)
user/group: apache apacheWhat’s interesting is that the files end up getting generated.
- This reply was modified 5 years, 6 months ago by Michael.
May 13, 2019 at 6:26 pm #1100195Hi,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
- Install and activate ” Temporary Login Without Password “.
- Go to ” Users > Temporary Logins ” on the left-side menu.
- Click ” Create New “.
- Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
( do be sure that we have enough time to debug ). - Click ” Submit “.
- You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.
When your issue is fixed, you can always remove the plugin!
If you prefer to not use the plugin, you can manually create an admin user and post the login credentials in the “private data” field.Best regards,
BasilisMay 13, 2019 at 6:49 pm #1100214Unfortunately, we’re going to have to work interactively over some sort of chat session as I cannot provide you with access to our public website due to our corporate privacy policies.
Please set up a time that works for you that I can coordinate chat via something like Discord or Skype.
May 14, 2019 at 11:04 pm #1100762Hello?
May 15, 2019 at 12:33 am #1100767Well I’ve been looking at the theme code and I am seeing a variable naming conflict and conditional argument that should be refactored here as it is confusing, superfluous and doesn’t really handle the reasons for why the outcome wouldn’t occur in any sort of graceful manner except for failing altogether, especially if we’re going all the way to provide merging and compressing in the first place.
In the following file (/wp-content/themes/enfold/config-templatebuilder/avia-template-builder/php/asset-manager.class.php:416) I see this block of code:
//create a new file if we got any content if(trim($content) != "") { $file_path = trailingslashit($stylesheet_dir).$data['hash'].".".$file_type; $file_created = avia_backend_create_file($file_path, $content); //double check if the file can be accessed if(is_readable($file_path)) { $handle = fopen($file_path, "r"); $filecontent = fread($handle, filesize($file_path)); fclose( $handle ); $file = $this->get_file_url($data, $file_type); $request = wp_remote_get($file); $file_created = false; if( ( ! $request instanceof WP_Error ) && is_array( $request ) && isset( $request['body'] ) ) { $request['body'] = trim($request['body']); $filecontent = trim($filecontent); //if the content does not match the file is not accessible if($filecontent == $request['body']) { $file_created = true; } } } } //file creation failed if(!$file_created) return false;
If we look at lines 420, we have the variable
$file_created
, which should essentially always returntrue
. Yet we later on line 432 re-assign the same variable $file_created tofalse
, basically overriding the truthful result of the previous $file_created boolean state anyhow, regardless of it being true….???? That is a problem.I also have to ask, why in lines 424 to 444 do we even bother checking to see if the file can be accessed by comparing the local PHP access to the a HTTP GET response??!? If the code successfully generated the file in the earlier step, then the file should be there. It is not the theme’s responsibility to determine HTTP response issues, but most likely a larger problem with the server or redirections, which this entire theme code block attempts to sloppily circumvent, but fails miserably when the problem arises regardless.
At the minimum, barring all of the other code issues, I would change the code to the following:
//create a new file if we got any content if(trim($content) != "") { $file_path = trailingslashit($stylesheet_dir).$data['hash'].".".$file_type; $file_created = avia_backend_create_file($file_path, $content); //double check if the file can be accessed if(is_readable($file_path)) { $handle = fopen($file_path, "r"); $filecontent = fread($handle, filesize($file_path)); fclose( $handle ); $file = $this->get_file_url($data, $file_type); $request = wp_remote_get($file); // don't overwrite the above assignment of the $file_created variable, and remove this assignment: $file_created = false; if( ( ! $request instanceof WP_Error ) && is_array( $request ) && isset( $request['body'] ) ) { $request['body'] = trim($request['body']); $filecontent = trim($filecontent); // if the content does not match, the file is not accessible if($filecontent != $request['body']) // if the file content DOES NOT equal the request body, then.... { $file_created = false; // change from true to false } } } } //file creation failed, exit out of function if(!$file_created) return false;
- This reply was modified 5 years, 6 months ago by Michael.
May 15, 2019 at 12:37 am #1100768Oh and by the way, you should hire me on contract to fix your theme, or at least discount me.
I see you guys are looking for developers, and it looks like you need all the help you can get.
Contact me at (Email address hidden if logged out) .Thanks.
July 1, 2019 at 12:57 pm #1114878Any updates from Enfold support? Seems like the most logical response to this issue.
I thinkwp_remote_get()
is failing when the site has a self-signed certificate.An entry in the Error log as to what is going on would be helpful.
- This reply was modified 5 years, 4 months ago by Jason.
July 1, 2019 at 5:14 pm #1114933Any updates from Enfold support? Seems like the most logical response to this issue.
Ha, their support structure is extremely poor. I inherited this theme for a site I manage, but I would have never used it.
I think wp_remote_get() is failing when the site has a self-signed certificate.
That’s my case exactly as well. I’ve since replaced that function with the native PHP file_get_contents() function in my code with some affordances for ssl/tls scenarios specific to my case and stored it as a recurring patch job in my git repo.
An entry in the Error log as to what is going on would be helpful.
Amongst SO MANY OTHER THINGS.
- This reply was modified 5 years, 4 months ago by Michael.
July 5, 2019 at 10:01 am #1115988Hi,
@smartstartinc: Thank you for your contribution. We will certainly forward this to Kriesi and the team.
Where are you hosting the site? We also notice that the compression doesn’t work on other servers while it’s fine in most. If it doesn’t really work in your installation, it can be easily replaced with Autoptimize or other minify tool from popular cache plugins like W3 Total Cache. Sorry for the delay.
Best regards,
IsmaelJuly 8, 2019 at 2:54 am #1116526Hi!
@smartstartinc: We are still not sure why the compression doesn’t work on some servers, but one of our developers said that it might be related to the ssl certificate as discussed here.Related thread: https://kriesi.at/support/topic/merge-and-compress-css-js-issue-avia_head_scripts/
Best regards,
IsmaelJuly 8, 2019 at 3:21 am #1116531@ismael to answer some of your questions:
We are hosting our website on our own internal hardware with VMs running CentOS. We have a Kemp load-balancer between the server and the public. The CentOS server has self-signed certificates for SSL/TLS on it, and the Kemp load-balancer has the domain name certs that get replaced in the exchange passthrough.
This is likely why it the theme fails on its verification of files using wp_remote_get() because it is accessing/referencing itself publicly through our local NAT and not hair-pinning out on the internet and then coming through the Kemp to get the certificates.Your resource regarding this: https://wordpress.stackexchange.com/questions/167898/is-it-safe-to-use-sslverify-true-for-with-wp-remote-get-wp-remote-post#answer-167910 states the following, which I think pretty much sums up what your team should do:
If this is a publicly distributed plugin, then you might want to attach that to a simple option that the user can turn on or off. You could as well try the verified request first and if not (and if the user has opted in for a unsigned request), then switch to a potentially unsafe request.
Your team should add a switch to the settings of the theme, to turn off verifying of the SSL certificates, should we have a setup where load-balancers exist or complicated SSL certificate setups cause these sorts of errors.
- This reply was modified 5 years, 4 months ago by Michael.
July 8, 2019 at 3:24 pm #1116701Hi,
There will be a theme option “Http security level for checking readability of merged files” in Performace Tab in the next release.
Best regards,
GünterJuly 8, 2019 at 4:39 pm #1116721When is the next release scheduled?
July 8, 2019 at 4:47 pm #1116726July 8, 2019 at 4:49 pm #1116728If it’s going to take longer than a month, please let me know, or share the code blocks with the changes for this.
July 11, 2019 at 4:47 am #1117659Hi,
You’ll find the updated files in the private field. This should add a new “Http security level for checking readability of merged files” option in the Performance panel.
Best regards,
Ismael- This reply was modified 5 years, 3 months ago by Ismael.
July 30, 2019 at 6:15 pm #1123213These files are not found.
August 1, 2019 at 9:45 am #1123814 -
AuthorPosts
- You must be logged in to reply to this topic.