modxcms / revolution

MODX Revolution - Content Management Framework
https://modx.com/
GNU General Public License v2.0
1.36k stars 529 forks source link

Bug with filemtime() for static elements in Windows #15304

Open sergant210 opened 4 years ago

sergant210 commented 4 years ago

Bug report

Summary

If you have static elements (snippets, plugins, chunks) some times you'll get this error (in Windows).

[2020-10-18 23:33:54] (ERROR @ D:\Projects\test.local\www\core\model\modx\modscript.class.php : 146) PHP warning: filemtime(): stat failed for D:/Projects/test.local/www/core/cache/includes/elements/modplugin/26.include.cache.php

modScript::loadScript() modx static

Step to reproduce

  1. Create a static snippet or plugin.
  2. Clear the cache.
  3. Refresh the page.
  4. Open the error log.

Environment

MODX 2.8.0. PHP 7.4. Windows 7, 10.

opengeek commented 4 years ago

The filemtime() check will not be executed if the $includeFilename is not readable, so your screenshot is not identifying the correct issue.

sergant210 commented 4 years ago

You are wrong. Take a look at the documentation.

opengeek commented 4 years ago

You are wrong. Take a look at the documentation.

I don't know what you are talking about. That call never executes if $result is falsewhich it will always be if the file does not exist yet. Take a look at the code.

sergant210 commented 4 years ago

I see. I was inattentive. Then why does this error appear? The problem looks like the lexicon cache issue.

opengeek commented 4 years ago

I see. I was inattentive. Then why does this error appear? The problem looks like the lexicon cache issue.

I'm having no luck reproducing the issue, so I do not know yet.

sergant210 commented 4 years ago

static

opengeek commented 4 years ago

I'm afraid this must be something unique to that particular plugin. I cannot recreate the issue with a basic plugin.

sergant210 commented 4 years ago

It's strange. I got this issue in my laptop with several static plugins. (The picture above from my desktop)

Ok. I'll dig further.

sergant210 commented 4 years ago

I think I got it. This happens only on Windows.

Mark-H commented 4 years ago

Anything the core should take into consideration?

sergant210 commented 4 years ago

@Mark-H I have no idea. There are no problems on Ubuntu.

Ruslan-Aleev commented 4 years ago

@Mark-H @sergant210 Windows has a problem with filemtime, maybe this comment will come in handy https://www.php.net/manual/en/function.filemtime.php#100692

Ruslan-Aleev commented 4 years ago

Maybe we should reopen this issue? Because the error log is constantly full of unnecessary lines.