pilif / sacy

Smarty Asset Compiler (warning: all branches but master are subject to force pushes)
http://pilif.github.com/sacy
MIT License
34 stars 12 forks source link

Sacy not creating cache and weird file issue #15

Open FizzyGiant opened 11 years ago

FizzyGiant commented 11 years ago

Hi firstly I would like to say thanks for providing this library.

I seem to be having a few issues:

1: Sacy creates the fragments directory correctly but doesn't generate the cache files. I'm guessing it might be related to issue 2

2: In the generated file (block.asset_compile.php) there is some weird characters which I don't think are mean't to be present in the file, They start at around line 124, Annoyingly though GitHub won't copy the characters in so I've attached a screenshot of the area I'm talking about. sacy-issue

The very last issue I seem to get is if I comment out the following bit of code at line 84

if ($res === false){
    // rendering failed.
    // because we don't know which one, we just enter emergency mode
    // and return the initial content unharmed:
    return $content;
}

I then get the following error

[Thu Jul 18 13:52:01 2013] [warn] [client 80.229.221.152] mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'PharException' with message 'phar "inc/classes/Smarty/plugins/block.asset_compile.php" SHA1 signature could not be verified: broken signature' in /inc/classes/Smarty/plugins/block.asset_compile.php:3
[Thu Jul 18 13:52:01 2013] [warn] [client 80.229.221.152] mod_fcgid: stderr: Stack trace:
[Thu Jul 18 13:52:01 2013] [warn] [client 80.229.221.152] mod_fcgid: stderr: #0 /inc/classes/Smarty/plugins/block.asset_compile.php(3): Phar::mapPhar('sacy.phar')
[Thu Jul 18 13:52:01 2013] [warn] [client 80.229.221.152] mod_fcgid: stderr: #1 /inc/classes/Smarty/internals/core.load_plugins.php(69): include_once('/var/www/vhosts...')
[Thu Jul 18 13:52:01 2013] [warn] [client 80.229.221.152] mod_fcgid: stderr: #2 /inc/templates/compiled/%%BF^BFB^BFBBFDB1%%common_head.html.php(4): smarty_core_load_plugins(Array, Object(Smarty))
[Thu Jul 18 13:52:01 2013] [warn] [client 80.229.221.152] mod_fcgid: stderr: #3 /inc/classes/Smarty/Smarty.class.php(1868): include('/var/www/vhosts...')
[Thu Jul 18 13:52:01 2013] [warn] [client 80.229.221.152] mod_fcgid: stderr: #4 /inc/templates/compiled/%%63^63B^63B43 in /inc/classes/Smarty/plugins/block.asset_compile.php on line 3

Now this error might just be because I commented out that code snippet above but I thought I would paste it here in case it was of any help, I commented it out as I'm trying to debug the issues I'm having.

I'm using the latest HEAD, Any help would be greatly appreciated.

FizzyGiant commented 11 years ago

Ok I just read up on what __halt_compiler(); does so I guess we can ignore the binary code, Also since recompiling with

if ($res === false){
    // rendering failed.
    // because we don't know which one, we just enter emergency mode
    // and return the initial content unharmed:
    return $content;
}

Commented out it doesn't throw the SHA1 error I guess I edited the wrong file before and instead of editing the source and rebuilding I must have been editing the final file directly.

But even with all that still not sure why its not creating the cache files or working correctly :(

pilif commented 11 years ago

The output of build.php is a phar archive. The error message I'm seeing from your report:

PHP Fatal error: Uncaught exception 'PharException' with message 'phar "inc/classes/Smarty/plugins/block.asset_compile.php" SHA1 signature could not be verified: broken signature'

points to an issue with the signature of the phar file. build.php does not sign the archive, so that's why the verification fails. You seem to have phar.require_hash enabled in your php.ini. Try disabing that or send me a pull request to make build.php sign the archive

FizzyGiant commented 11 years ago

Hi pilif thanks for getting back to me, I turned phar.require_hash off which fixed the SHA1 issue. However, the cache files are still not being generated.

Also just to double check ASSET_COMPILE_OUTPUT_DIR should be an absolute path right? because If I set a relative path (assets/cache) it throws:

Fatal error: Uncaught exception 'sacy\Exception' with message 'Failed to create fragments cache directory' in phar:///inc/classes/Smarty/plugins/block.asset_compile.php/sacy/fragment-cache.php on line 14

However, it does correctly create the fragments directory, just not the cache files. With an absolute path it doesn't throw this error and still creates the fragments directory as it should but it still doesn't create the cache files