views:

1665

answers:

15

I am in the process of testing a Magento 1.3 site using Magento 1.4. I am seeing very weird and inconsistent behavior. Instead of including the URL of my javascript files, Magento is creating tags with the full filesystem path of the js files, as so:

<script type="text/javascript" src="/home/my_username/public_html/js/prototype/prototype.js"></script>

I believe this is related to the new "Themes JavaScript and CSS files combined to one file" function. In fact, when I log into the admin and click "Flush JavaScript/CSS Cache", then the first page load is successful, and I see a single JS include similar to:

<script type="text/javascript" src="/media/js/5b8cfac152fcb2a5f93ef9571d338c54.js"></script>

But subsequent age loads load every single JS file, with the full path names. Which obviously isn't going to work. Anyone have any ideas on what could be wrong or how to fix this issue?

A: 

What are the values for the various Base URL fields under "Web" in the configuration? Should be something along the lines of

{{unsecure_base_url}}skin/

for the base skin URL.

Chris Norton
Yeah, that's what it was. I even tried replacing {{unsecure_base_url}} with http://my.domain.name/ to no avail...
Josh
A: 

I have the same problem. Did you manage to find an answer for this?

Mattias Bomelin
+3  A: 

go to System -> Configuration -> Developer Settings -> Javascript Settings -> Merge JavaScript Files (beta) and set it to "no". It is realy a beta :D

ThaKilla
A: 

The problem is related with the javascript merge option. Unfortunatly the form does not work without javascript. You have to change the merge_files option in app/code/core/Mage/Core/etc/config.xml to 0.

        <js>
            <merge_files>0</merge_files>
            <deprecation>0</deprecation>
        </js>

After that I removed all cache files and session files in var directory.

giftnuss
+1  A: 

Editing the config.xml didn't do the trick for me, I had to disable it in the database.

In table 'core_config_data' set the value of the row with path 'dev/js/merge_files' (config_id 772) to '0'.

Thanks for pointing me in the right direction though!

Ben
A: 

Well, you actually didn't find a solution. I had the same problem, and finally I came up to the solution in my case: 1) Verify that the permissions on media/js belong to the same user that the magento installation's folder is. 2) Clean the CSS/JS cache using the admin.

The combination of the two actually got things back to normal. And to make it clear - merging in magento 1.4 does actually work.

Cheers!

Avi Shefi
A: 

the sollution above (by avi shefi) works for me.. but only the first time. to clarify,

I checked all permissions, I cleaned the cache. in the media/js and media/css folder, all files are removed.

I visit the first detail page of product A. The page loads fast, when I view source, I can see 1 hashed css and 1 hashed js file. They also exist in the media/js and css folder.

Now if I refresh the detail page, it takes a long time, when I view source, all JS paths are back to the filesystem path instead of 1 hashed JS file. Css is correct though. the hashed JS files in de media/js folder still exists. The moment I remove it from the media/js folder it works again.. but again, only the first refresh.

anybody any idea on how to solve it? I really want to use the mergin. i makes page loads way faster.

Fragilem17
A: 

@Fragilem - Are you sure both the owner and the group of ALL files on your Magento installation do belong to the right user? I had the same symptoms until I finally chgrp & chown'd all files to my web user.

Avi Shefi
A: 

Here's the solution:

Edit app/code/core/Mage/Core/Helper/Data.php around line 631

REPLACE:

if (filemtime($file) > $targetMtime) {

WITH:

if (@filemtime($file) > $targetMtime) {

Good luck :)

Unirgy
+1  A: 

Editing the config.xml didn't do the trick for me, I had to disable it in the database.

In table 'core_config_data' set the value of the row with path 'dev/js/merge_files' (config_id 772) to '0'.

Thanks for pointing me in the right direction though!

This solution is worked for me, thanks.

Rohit
A: 

I had the same Problem.

Its because magento can't find a javascript file. Look at your /var/log/exception.log (You have to enable the log in System -> Config -> Developer Options)

In my log was the following error:

exception 'Exception' with message 'Warning: filemtime() [function.filemtime]: stat failed for /var/www/js/calendar/lang/calendar-en.js in /var/www/app/code/core/Mage/Core/Helper/Data.php on line 631' in /var/www/app/code/core/Mage/Core/functions.php:245

So I created the file and voila it works !

ThaKilla
+1  A: 

Thanks for the help guys, I followed Rohit's instruction:

In table 'core_config_data' set the value of the row with path 'dev/js/merge_files' (config_id 772) to '0'

Although my config ID was different (I used phpmyadmin to search on the path 'dev/js/merge_files'). javascript burst back in to life, allowing me to use the admin cache management to flush the JS cache.

All seems OK now...

Digitiser
A: 

@rohit Thanks ! It did the tick for me too. Don't forget 'dev/css/merge_css_files' too

Kirby
A: 

The solution by Ben (above) works for me.

Sam