diff --git a/ext/mvc/url.c b/ext/mvc/url.c
index bcc3949a7ef..8709396b92d 100644
--- a/ext/mvc/url.c
+++ b/ext/mvc/url.c
@@ -295,16 +295,22 @@ PHP_METHOD(Phalcon_Mvc_Url, get){
zval *service, *route_name, *route = NULL, *exception_message;
zval *pattern = NULL, *paths = NULL, *processed_uri, **args = NULL, *query_string;
zval *matched, *regexp;
+ zval **z_local = NULL;
int local = 1;
- phalcon_fetch_params_ex(0, 2, &uri, &args);
+ phalcon_fetch_params_ex(0, 3, &uri, &args, &z_local);
PHALCON_MM_GROW();
if (!uri) {
uri = &PHALCON_GLOBAL(z_null);
}
- else if (Z_TYPE_PP(uri) == IS_STRING && strstr(Z_STRVAL_PP(uri), "://")) {
+ else if (z_local && Z_TYPE_PP(z_local) != IS_NULL) {
+ if (!zend_is_true(*z_local)) {
+ local = 0;
+ }
+ }
+ else if (Z_TYPE_PP(uri) == IS_STRING && strstr(Z_STRVAL_PP(uri), ":")) {
PHALCON_INIT_VAR(matched);
PHALCON_INIT_VAR(regexp);
ZVAL_STRING(regexp, "/^[^:\\/?#]++:/", 1);
diff --git a/ext/tag.c b/ext/tag.c
index 607c26cfed7..f1479fd5103 100644
--- a/ext/tag.c
+++ b/ext/tag.c
@@ -727,7 +727,7 @@ PHP_METHOD(Phalcon_Tag, linkTo){
zval *parameters, *text = NULL, *local = NULL, *params = NULL;
zval *action, *url = NULL, *internal_url = NULL, *link_text, *z_local;
- zval *code;
+ zval *code, *query;
PHALCON_MM_GROW();
@@ -774,18 +774,20 @@ PHP_METHOD(Phalcon_Tag, linkTo){
phalcon_array_unset_string(¶ms, SS("local"), 0);
} else {
PHALCON_INIT_VAR(z_local);
- ZVAL_TRUE(z_local);
+ ZVAL_NULL(z_local);
}
-
- if (zend_is_true(z_local) || Z_TYPE_P(params) == IS_ARRAY) {
- PHALCON_CALL_SELF(&url, "geturlservice");
-
- PHALCON_CALL_METHOD(&internal_url, url, "get", action);
- phalcon_array_update_string(¶ms, SL("href"), internal_url, PH_COPY);
+
+ if (phalcon_array_isset_string_fetch(&query, params, SS("query"))) {
+ phalcon_array_unset_string(¶ms, SS("query"), 0);
} else {
- phalcon_array_update_string(¶ms, SL("href"), action, PH_COPY);
+ PHALCON_INIT_VAR(query);
+ ZVAL_NULL(query);
}
+ PHALCON_CALL_SELF(&url, "geturlservice");
+ PHALCON_CALL_METHOD(&internal_url, url, "get", action, query, z_local);
+ phalcon_array_update_string(¶ms, SL("href"), internal_url, PH_COPY);
+
PHALCON_INIT_VAR(code);
ZVAL_STRING(code, " 'stylesheet/less'));
$this->assertEquals($html, ''.PHP_EOL);
}
+
+ public function testIssue2002()
+ {
+ $di = new Phalcon\DI\FactoryDefault();
+ $di->getshared('url')->setBaseUri('/');
+ \Phalcon\Tag::setDI($di);
+
+ $html = Phalcon\Tag::linkTo(array('signup/register', 'Register Here!', 'class' => 'btn-primary', 'query' => array('from' => 'github', 'token' => '123456')));
+ $this->assertEquals($html, 'Register Here!');
+ }
}