cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[2.0.0] Assets filter issue

Open borisdelev opened this issue 11 years ago • 10 comments

I have some issue with assets- when i try to filter them and join- and specify which resource is non local and non be filtered- then server crash. This issue occur and with JS files.

    $this->assets->collection('css')
        ->addCss('http://someurl.com/css/libs/normalize.css', false, false)
        ->addCss('http://someurl.com/css/libs/basic.css', false, false)
        ->addCss("css/default.css");
        ->setTargetPath('css/compile.css')
        ->setTargetUri('css/compile.css')
        ->join(true)
        ->addFilter(new \Phalcon\Assets\Filters\Cssmin());

Thank you for Phalcon - amazing framework! PS: sorry for my english

borisdelev avatar Apr 10 '15 09:04 borisdelev

Is just this the code to reproduce the issue?

<?php

$assets = new Phalcon\Assets\Manager;

$assets->collection('css')
    ->addCss('http://someurl.com/css/libs/normalize.css', false, false)
    ->addCss('http://someurl.com/css/libs/basic.css', false, false)
    ->addCss("css/default.css")
    ->setTargetPath('css/compile.css')
    ->setTargetUri('css/compile.css')
    ->join(true)
    ->addFilter(new \Phalcon\Assets\Filters\Cssmin());

I've tested it and seems to work.

andresgutierrez avatar Apr 12 '15 16:04 andresgutierrez

Hi there, It was in controller (MVC, multi module), so... i copy/paste your code and yes- same issue - crash without error- i think is something like a loop or try to make connection (to join) but didnt make it. I didnt mention that server is my local pc- XAMPP- with last DLL (32 bit / PHP 5.6.0 (VC11)) from April 08 2015.

I test all url-s and they work. Its happened when i include external resources :/ I will continue to test and try to figure out what is the issue.

So... thank you... let the force be with u... always :)

borisdelev avatar Apr 13 '15 10:04 borisdelev

I have some details here... after review my apache logs i found some errors, fix them by removing extension php_xdebug (do some restart stuff "AH00428: Parent: child process 3496 exited with status 255 -- Restarting."- no idea)... and the error occur in browser:

Resource 'http://someurl.com/css/libs/normalize.css' have the same source and target paths

...So... i google it and found that this is some issue... and it was found on all Phalcon dll version before 1.3.4.

Is there solution for that?

borisdelev avatar Apr 14 '15 18:04 borisdelev

@andresgutierrez You need to call outputCss at the end to see the exception.

olivier-monaco avatar Apr 14 '15 20:04 olivier-monaco

@butamuh4o There's a bug... but from http://docs.phalconphp.com/en/latest/reference/assets.html:

Some resources may be remote, that is, they’re obtained by HTTP from a remote source for further filtering. It is recommended to convert the external resources to local eliminating the overhead of obtaining them.

olivier-monaco avatar Apr 14 '15 20:04 olivier-monaco

@butamuh4o Oups... I didn't see the "false" after each URL... Forget my comment.

olivier-monaco avatar Apr 14 '15 20:04 olivier-monaco

From 1.3.4 (https://github.com/phalcon/cphalcon/blob/master/ext/assets/manager.c#L727):

            if (zend_is_true(local)) {

From 2.0.0 (https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/assets/manager.zep#L475):

                if join {

olivier-monaco avatar Apr 14 '15 20:04 olivier-monaco

Please check with latest 2.0.0.

olivier-monaco avatar Apr 14 '15 21:04 olivier-monaco

Thanks, mate :) i will check and will notify what ive did xD ...this is with latest 2.0.0 version (from April 08 / dll ) :/ I will check when new 2.0.0 will be released.

borisdelev avatar Apr 15 '15 08:04 borisdelev

Hi again :) after update- all works now. FIlter is working properly.

But we have new issue!

If u see same example up... ive try to combine all local css but didnt want to include external files... If i mark some resource to be not included in compiled file (not filtered) - third parameter in addCSS (see docuemnation)- Phalcon compile them all- and that is the issue: didnt use the settings i give.

So- old problem is solved, new appear :/ I hope you understand me. My english is not so good.

borisdelev avatar Apr 18 '15 15:04 borisdelev