Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render LEVEL doesn't work correctly #4

Closed
sraka1 opened this issue Apr 14, 2012 · 4 comments
Closed

Render LEVEL doesn't work correctly #4

sraka1 opened this issue Apr 14, 2012 · 4 comments

Comments

@sraka1
Copy link

sraka1 commented Apr 14, 2012

Phalcon_View::setRenderLevel is broken (for me atleast).

What happens?

$this->view->setRenderLevel(Phalcon_View::LEVEL_ACTION_VIEW);
This prints out the main layout!

What should happen?

Only the view layout should've been printed.

Can anyone replicate this?

EDIT:

JCVD :)

@ghost ghost assigned phalcon Apr 14, 2012
@phalcon
Copy link
Collaborator

phalcon commented Apr 14, 2012

Yep, render level seems to be wrong, sorry, it will be fixed soon as possible. Thanks for reporting it

@sraka1
Copy link
Author

sraka1 commented Apr 15, 2012

Here's the problem:

/dev/view.c

v4 is the value read from the LEVEL_x_VIEW var

            PHALCON_INIT_VAR(t11);
    ZVAL_LONG(t11, 5);
    PHALCON_INIT_VAR(r24);
    is_smaller_or_equal_function(r24, v4, t11 TSRMLS_CC);
    if (zend_is_true(r24)) {
        PHALCON_ALLOC_ZVAL_MM(r25);
        PHALCON_CONCAT_RIGHT(r25, v2, "index.phtml");
        PHALCON_CPY_WRT(v7, r25);
        if (phalcon_file_exists(v7 TSRMLS_CC) == SUCCESS) {
            PHALCON_CALL_FUNC_NORETURN("ob_clean", 0x013);
            phalcon_require(v7 TSRMLS_CC);
            if (EG(exception) || EG(exit_status) == 255) {
                return;
            }
            PHALCON_ALLOC_ZVAL_MM(r26);
            PHALCON_CALL_FUNC(r26, "ob_get_contents", 0x012);
            phalcon_update_property_zval(this_ptr, "_content", strlen("_content"), r26 TSRMLS_CC);
        }
    }

So what's happening is if LEVEL_x_VIEW is equal or smaller than 5, then render the index.phtml. However, zend_declare_class_constant_long(phalcon_view_class_entry, "LEVEL_ACTION_VIEW", sizeof("LEVEL_ACTION_VIEW")-1, 5 TSRMLS_CC); here we can see that LEVEL_ACTION_VIEW is equal to 5 and this will be rendered. This isn't properly written.

There has to be something that checks "if greater than", if you want to keep your vars untouched.

I'm rewriting it as we speak, however not sure it'll be very good... My C is dodgy and I'm unfamiliar with the entire code... And the PHP magic vars :)

Just my 2 cents.

@phalcon
Copy link
Collaborator

phalcon commented Apr 15, 2012

Hi JCVD, it was exactly that! It was fixed at dev repository, many thanks!

@sraka1
Copy link
Author

sraka1 commented Apr 15, 2012

Yep, pretty much exactly as mine (by reversing the order of the levels). Will overwrite, I had a extra if statement, yours is great! Thanks for the quick response!

@sraka1 sraka1 closed this as completed Apr 15, 2012
ovr pushed a commit to ovr/cphalcon that referenced this issue Dec 25, 2013
Declaration of ConcatOperator::compile() should be compatible with Logic...
@phpclub phpclub mentioned this issue Mar 10, 2016
@phalcon phalcon removed their assignment Mar 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants