为什么 Magento 1.4 通过文件系统路径包含 javascript 文件?

发布于 2024-08-19 09:57:29 字数 590 浏览 5 评论 0原文

我正在使用 Magento 1.4 测试 Magento 1.3 站点。我看到非常奇怪和不一致的行为。 Magento 没有包含我的 javascript 文件的 URL,而是使用 js 文件的完整文件系统路径创建标签,如下所示:

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

我相信这与新的“主题 JavaScript 和 CSS 文件合并为一个文件”功能有关。事实上,当我登录管理员并单击“刷新 JavaScript/CSS 缓存”时,第一个页面加载成功,我看到一个 JS 包含类似于:

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

但后续的年龄加载会加载每个 JS 文件,并包含完整的 JS 文件。路径名称。这显然是行不通的。有人对可能出现的问题或如何解决此问题有任何想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

童话里做英雄 2024-08-26 09:57:29

就我而言,这是权限问题。这些 ssh 命令在 Magento 的根目录中运行修复了它:

    # chown all to proper user and group, ie. www-data
    chown -R www-data:www-data *
    # change all files permissions to 644
    find . -type f -exec chmod 644 {} \;
    # change all directories permissions to 755
    find . -type d -exec chmod 755 {} \;
    # change all to be writable in var and media directories
    chmod -R 777 var/ media/

如果仍然不起作用,则将 MySQL 中 core_config_data 中路径列的这两个值从“1”更改为“0”:

  • dev/css/merge_css_files
  • dev/js /合并文件

It was permissions issue in my case. These ssh commands run in the root directory of Magento fixed it:

    # chown all to proper user and group, ie. www-data
    chown -R www-data:www-data *
    # change all files permissions to 644
    find . -type f -exec chmod 644 {} \;
    # change all directories permissions to 755
    find . -type d -exec chmod 755 {} \;
    # change all to be writable in var and media directories
    chmod -R 777 var/ media/

If it still doesn't work then change these two values for path column in the core_config_data in MySQL from "1" to "0":

  • dev/css/merge_css_files
  • dev/js/merge_files
花期渐远 2024-08-26 09:57:29

进入系统->配置->开发者设置-> JavaScript 设置 ->合并 JavaScript 文件(测试版)并将其设置为“否”。这确实是一个测试版:D

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

友欢 2024-08-26 09:57:29

编辑 config.xml 对我来说没有效果,我必须在数据库中禁用它。

在表“core_config_data”中,将路径为“dev/js/merge_files”(config_id 772) 的行的值设置为“0”。

不过还是谢谢你给我指明了正确的方向!

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!

画尸师 2024-08-26 09:57:29

我遇到了同样的问题,并提出了以下解决方案:

  1. 验证 media/js 上的权限是否属于 magento 安装文件夹所在的同一用户。
  2. 使用管理员清理 CSS/JS 缓存。

两者的结合实际上让事情恢复了正常。

I had the same problem and came up with the following solution:

  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.

凌乱心跳 2024-08-26 09:57:29

检查您的媒体文件夹是否可供您运行网络服务器的用户写入。
我有一个指向只能由 root

chown -R www-data:www-data media

帮助写入的文件夹的符号链接。

Check if your media folder is writeable by the user you webserver runs with.
I had a symlink to a folder that was only writeable by root

chown -R www-data:www-data media

helped.

陈年往事 2024-08-26 09:57:29

我有同样的问题。

这是因为 magento 找不到 javascript 文件。查看您的 /var/log/exception.log (您必须在系统 -> 配置 -> 开发人员选项中启用日志)

在我的日志中出现以下错误:

异常“异常”,并带有消息“警告:filemtime()” [function.filemtime]:第 631 行 /var/www/app/code/core/Mage/Core/Helper/Data.php 中 /var/www/js/calendar/lang/calendar-en.js 的统计失败在 /var/www/app/code/core/Mage/Core/functions.php:245

所以我创建了该文件,瞧它可以工作了!

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 !

娇纵 2024-08-26 09:57:29

编辑 config.xml 对我来说没有效果,我必须在数据库中禁用它。

在表 core_config_data 中,将路径 dev/js/merge_files (config_id 772) 的行的值设置为“0”

不过还是谢谢你给我指明了正确的方向!

这个解决方案对我有用,谢谢。

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.

海未深 2024-08-26 09:57:29

配置中“Web”下的各个基本 URL 字段的值是什么? 类似。

{{unsecure_base_url}}skin/

应该与基本皮肤 URL

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.

ヤ经典坏疍 2024-08-26 09:57:29

该问题与 javascript 合并选项有关。不幸的是,如果没有 JavaScript,该表单将无法工作。您必须将 app/code/core/Mage/Core/etc/config.xml 中的 merge_files 选项更改为 0。

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

之后,我删除了 var 目录中的所有缓存文件和会话文件。

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.

八巷 2024-08-26 09:57:29

在magento 1.4中,config_id是879(对我来说)
将此值设置为 0 可以恢复所有 .js 文件。超级奇怪

in magento 1.4 the config_id is 879 (for me)
Setting this value to 0 gave me all my .js files back. Super weird

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文