revolution icon indicating copy to clipboard operation
revolution copied to clipboard

Bug with filemtime() for static elements in Windows

Open sergant210 opened this issue 4 years ago • 13 comments

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.

sergant210 avatar Oct 19 '20 07:10 sergant210

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

opengeek avatar Oct 19 '20 13:10 opengeek

You are wrong. Take a look at the documentation.

sergant210 avatar Oct 19 '20 14:10 sergant210

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.

opengeek avatar Oct 19 '20 14:10 opengeek

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

sergant210 avatar Oct 19 '20 14:10 sergant210

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.

opengeek avatar Oct 19 '20 14:10 opengeek

static

sergant210 avatar Oct 19 '20 16:10 sergant210

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

opengeek avatar Oct 19 '20 17:10 opengeek

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 avatar Oct 19 '20 17:10 sergant210

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

sergant210 avatar Oct 19 '20 17:10 sergant210

Anything the core should take into consideration?

Mark-H avatar Oct 19 '20 18:10 Mark-H

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

sergant210 avatar Oct 19 '20 19:10 sergant210

@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 avatar Oct 19 '20 19:10 Ruslan-Aleev

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

Ruslan-Aleev avatar Oct 20 '20 12:10 Ruslan-Aleev