pressjitsu / pomodoro

A simple WordPress translation cache
GNU General Public License v3.0
68 stars 17 forks source link

Check file syntax before making it available #10

Closed mihdan closed 4 years ago

mihdan commented 5 years ago
Parse error: syntax error, unexpected ''9a955260a0b90a4beefcda895d2ae' (T_ENCAPSED_AND_WHITESPACE), expecting ')' in /tmp/5d9efa504ca7e12ff142ba48d46680bf.mocache on line 1469

@soulseekah их можно валидировать перед подключением?

soulseekah commented 5 years ago

А откуда она там берется ошибка?

mihdan commented 5 years ago

Я так понял, что из-за нехватки ресурсов (места)

soulseekah commented 5 years ago

Не знаю, нужно думать. Вариант может token_get_all, но совсем не хочется открывать файл и парсить его предварительно, ведь у нас счет на миллисекунды...

mihdan commented 5 years ago

Скорее всего ты прав, так как простого способа нет проверить перед подключением

soulseekah commented 5 years ago

Мне кажется можно это сделать через opcache_compile_file ктонибудь проверьте.

alexandru-bagi commented 4 years ago

Hello, I have encountered this issue too. I believe the cache file was being written and somehow it stopped. I can upload relevant files/screenshots if needed. Has anyone found a solution for this?

soulseekah commented 4 years ago

I think that we should check the file for syntax errors after it's written and then allow it for usage.

soulseekah commented 4 years ago

php_check_syntax()

soulseekah commented 4 years ago

Can we have a test on this, people?

Thank you!

soulseekah commented 4 years ago

php_check_syntax was removed not added in 5.0.5, I misread < and >. We're back to where we were with this one.

Other options:

I think I'd try token_get_all next, actually.

soulseekah commented 4 years ago

token_get_all gobbles up anything we give it, unfortunately.

Here's another thing, what if we write a special flag into the file like /** POMODORO_END */ and make sure it exists? That would prevent partial files from being loaded.

If that does not cover the majority of cases (or even all cases of syntax errors, what else can there be), then we can use token_get_all and make sure that there's one array, of key-strings, closed off properly.