No way to get all REST params from CHttpRequest #259

qiangxue opened this Issue Feb 15, 2012 · 7 comments


None yet
6 participants

qiangxue commented Feb 15, 2012

Just found that there is no way to get all params sent with a PUT or DELETE request since CHttpRequest::getRestParams() is protected and getPut()/getDelete() need a param name specified.

If I do not know all params for example when I want to set ActiveRecord attributes with all parameters sent I need a way to get them all.

One way to get the behavior would be to return all if name is not specified in getPut() and getDelete(), another way would be to have 2 more functions for that.

Migrated from

earlier comments

stratosgear said, at 2011-12-12T19:16:49.000Z:

I think your issue is solved as per

Would that do it for you? There are two new methods getPutParams() and getDeleteParams() said, at 2011-12-13T00:53:19.000Z:

If they were public that would do it, yeah ;-)

qiang.xue said, at 2012-01-01T03:37:10.000Z:

set for 1.1.10 milestone

qiang.xue said, at 2012-01-01T03:37:36.000Z:

set for 1.1.10 milestone

I have commited a solution for this in #173

@samdark samdark closed this Mar 9, 2012

@samdark samdark reopened this Mar 9, 2012

hjellek commented Aug 22, 2012

+1 on this one, what's the status?

@ghost ghost assigned samdark Sep 24, 2012


samdark commented Sep 24, 2012

Mostly done. The only decision left is what to choose:

  1. Two extra methods getPutParams() and getDeleteParams().
  2. Allow not passing $name to getPut() and getDelete().
  3. Make getRestParams public.

Personally I prefer 2.

@qiangxue, @cebe, @mdomba thoughts?


cebe commented Sep 26, 2012

  1. Would be a way, but we have a problem with inconsistent api here. We should also add getQueryParams() and getPostParams() but in the end the last two will only wrap $_GET and $_POST which is not very cool.
  2. When we implement it, also getPost() and getQuery() should work this way. But maybe too many use cases in one method, I am not sure if I like it.
  3. I think this is the cleanest way, but we should make sure we can call it multiple times. Also this method would work when I introduce my very own HTTP request types for some reason no only for PUT and DELETE.

resurtm commented Sep 26, 2012

but we should make sure we can call it multiple times

There is no such problem. Take a look at the CHttpRequest::getRestParams() itself ( The first call "caches" result of the CHttpRequest::getRawBody() in the private property. The second and the following calls just returns "cache"-property containment directly. Btw CHttpRequest::$_restParams is changed only in CHttpRequest::getRestParams().


cebe commented Sep 26, 2012

@resurtm sorry, checked an old version of that method. It was not in there in 1.1.11 :)


samdark commented Sep 26, 2012

Agree. Will finish this one before release.

@samdark samdark closed this in 9844c80 Oct 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment