Hi,
I installed the services module (3.0 rc1) and all its requirements on a fresh D7 install. My goal is to expose my customized multi-user blog content as a REST service based on taxonomy categories. I created a REST server service which I can access from a test rest client I've written in Zend Framework. For some reason I always get html as a return, no matter what format I specify. Is there something I'm missing out?

These two code blocks both return the same content

$uri = 'http://local.test/services/rest';
$client = new Zend_Rest_Client($uri);
$result = $client->restGet('node/8.json');
echo $result->getBody();
$uri = 'http://local.test/services/rest';
$client = new Zend_Rest_Client($uri);
$result = $client->restGet('node/8');
echo $result->getBody();

Comments

kylebrowning’s picture

Try the dev version first and let me know if this is still an issue.

edmeister’s picture

Hi Kyle,

The dev version gives an error when loading the resources tab for a new service.

Warning: Parameter 1 to services_edit_form_endpoint_resources() expected to be a reference, value given in drupal_retrieve_form() (line 771 of [PATH]/drupal/includes/form.inc).

kylebrowning’s picture

Did you clear your cache?

edmeister’s picture

Now I did. Still the same situation.

RasputinJones’s picture

Same here.

kylebrowning’s picture

Version: 7.x-3.0-rc1 » 7.x-3.x-dev

Im still unable to reproduce, https://skitch.com/kylebrowning/r2nxh/untitled
https://skitch.com/kylebrowning/r2nx6/untitled

Can you give me any more information?

Im using 7.x-3.x dev

RasputinJones’s picture

Version: 7.x-3.x-dev » 7.x-3.0-rc1

Hey Kyle. Actually the problem comes before this bit. Ed and I apparently can't even configure the allowed resources for the new service. The error pops up when we try to configure it. I'm going to try to workaround this by downgrading, exporting the settings and reimporting.

RasputinJones’s picture

BTW. What tool are you using in your screenshot. Looks nifty.

kylebrowning’s picture

I have figured out a way for it to support sessions, but it gets the job done in most cases.

http://ditchnet.org/httpclient/

RasputinJones’s picture

StatusFileSize
new3.24 KB

Ed,

If you haven't figured this out, this workaround should work for you. Fill out the places I pointed out in the file and import it into your site. You can tweak the permissions you want to have as necessary.

Kyle - bugs still there. I tried using xdebug to do some tracing but wasn't so successful. The code's quite unfamiliar to me so can't help much more at this point.

kylebrowning’s picture

Im not really able to reproduce, can you tell me what your doing step by step?

I can enabled endpoints, I can enable resources, and I can see FULL json.

It sounds like theres two issues and I dont know which one you are still having problems with.

One issue is your seeeing html, and the other is your gettting some error when enabling(maybe?) resources.

Help me help you

RasputinJones’s picture

Sorry, if I've muddled things up for you a bit Kyle. There are two issues. Ed's reported one which is the subject of the thread.

Mine specifically is what he mentioned in #2. I can't seem to see the resources tab after installing Services 7.x-3.x. Rather I get the same error he reported.

Warning: Parameter 1 to services_edit_form_endpoint_resources() expected to be a reference, value given in drupal_retrieve_form() (line 771 of [PATH]/drupal/includes/form.inc).

This should probably be a separately marked issue.

Ras.

edmeister’s picture

Kyle,

I looked into your headers and noticed you were running PHP 5.2.x. In my different test environments (mamp & vbox ubuntu) I already switched to 5.3. When I switched back to 5.2 in my mamp, everything works well: the resources bug doesn't appear and I can access the rest server.

Rasputin, can you confirm this? Thanks for your import file, btw.

RasputinJones’s picture

Yeah I'm running Zend CE with PHP 5.3. Might be the root cause of it.

edmeister’s picture

Kyle,

I went through the code with Xdebug. When I remove the reference to the $form_state parameter in the services_edit_form_endpoint_resources() function, it is possible to load the resources page.

File: /services/plugins/export_ui/services_ctools_export_ui.class.php
Line: 116

function services_edit_form_endpoint_resources(&$form_state, $endpoint) {

Changed to

function services_edit_form_endpoint_resources($form_state, $endpoint) {

I did not run any unit tests so I'm not aware if this change breaks any other code.

kylebrowning’s picture

Title: REST service content is always returned as html » PHp 5.3 Error on pass by reference in Ctools Export
Version: 7.x-3.0-rc1 » 7.x-3.x-dev
Status: Active » Fixed

I dont see anything wrong with removing that, and IM not sure why it was put there in the first place. I just ran all the tests and everything looks good. This has been fixed in both 6.x-3.x and 7.x-3.x, let me know if you have any more issues and feel free to re-open the ticket.

I also updated the title to reflect the actual issue. If the HTML problem persists, please open another ticket.

wedge’s picture

Status: Fixed » Needs work

Is this fix really complete? Wouldn't $endpoint be uninitialized?

To me the services_edit_form_endpoint_resources part of https://github.com/boombatower/services/commit/45825dcd8f07a5b612219f4e9... looks like a better fix to this issue.

mradcliffe’s picture

Category: support » bug
StatusFileSize
new3.25 KB

I agree with wedge in #17:

Drupal 7 drupal_retrieve_form() expects $form to be passed into the form callback.

If you trace the the arguments being sent in you will find three arguments:
array(), // $form
array('build_info'....), // $form_state
object // $endpoint

With the following patch, I am not even sure $endpoint is relevant anymore, which is why boombatower's patch doesn't include it. Maybe that approach would be better. I'll look into merging what I have now with that and reposting. Just wanted to post what I had come up with separately as well (currently running through tests).

kylebrowning’s picture

Anything new or should I run the tests on this?

kylebrowning’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs work » Patch (to be ported)
StatusFileSize
new4.62 KB

Heres an updated patch. this one needs to be ported to 6.x-3.x

mradcliffe’s picture

Sorry, I have been a bit busy recently focusing on other projects and wasn't able to get back to you, Kyle.

kylebrowning’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

christianchristensen’s picture

This seems related:

I have been working with Services 6.x-3.0-rc1 on PHP 5.3 and the services page shows nothing b/c of a thrown error on variable reference:

file: services_ctools_export_ui.class.php

-function services_edit_form_endpoint_resources($form, &$form_state) {
+function services_edit_form_endpoint_resources($form, $form_state) {

I noticed a *related* change exists here: https://github.com/boombatower/services/commit/45825dcd8f07a5b612219f4e9...