Skip to content
This repository has been archived by the owner on Sep 6, 2020. It is now read-only.

Undefined offset: 0 #11

Closed
ghost opened this issue Feb 18, 2016 · 7 comments
Closed

Undefined offset: 0 #11

ghost opened this issue Feb 18, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented Feb 18, 2016

I has get error when dumpzone.

in Cpanel.php line 343
at HandleExceptions->handleError('8', 'Undefined offset: 0', '/home/nginx/domains/xxx/public/vendor/gufy/cpanel-php/src/Gufy/CpanelPhp/Cpanel.php', '343', array('action' => 'dumpzone', 'arguments' => array('domain' => 'xxx.com'), 'host' => 'https://10.0.0.3:2087', 'client' => object(Client))) in Cpanel.php line 343

Resolve:
change
'query' => count($arguments) > 1 ? $arguments : $arguments[0],
to
'query' => $arguments,

Please check it :)

@mgufrone
Copy link
Owner

is this happen when the $arguments is null?

@ghost
Copy link
Author

ghost commented Feb 18, 2016

no, this happen when is has one item in array.

@mgufrone
Copy link
Owner

Try it again

@mgufrone mgufrone reopened this Feb 18, 2016
@ghost
Copy link
Author

ghost commented Feb 18, 2016

tks guy :)

@mgufrone
Copy link
Owner

Use dev-master instead, i still haven't pushed it as a tag. 👍

twouters added a commit to twouters/cpanel-php that referenced this issue Feb 24, 2016
$argument is enumerated array containing the parameters passed to the method.
As far as I know, only one argument is expected here (an array of parameters to pass to the API function) so we can safely use `$arguments[0]`.
@twouters
Copy link
Contributor

This is still a problem because the $arguments parameter of __call() is always an enumerated array containing the parameters passed to the method.

$accounts = listaccts(['searchtype'=>'domain', 'search'=>'', 'exact', 'search'=>'helloworld.com']);

This would result in the following $arguments:

array(1) {
  [0]=>
  array(3) {
    ["searchtype"]=>
    string(6) "domain"
    ["search"]=>
    string(14) "helloworld.com"
    [0]=>
    string(5) "exact"
  }
}

Which results in the following POST request:

> POST /json-api/listaccts?0%5Bsearchtype%5D=domain&0%5Bsearch%5D=helloworld.com&0%5B0%5D=exact HTTP/1.1

twouters added a commit to twouters/cpanel-php that referenced this issue Feb 24, 2016
$argument is enumerated array containing the parameters passed to the method.
As far as I know, only one argument is expected here (an array of parameters to pass to the API function) so we can safely use `$arguments[0]`.
mgufrone added a commit that referenced this issue Feb 26, 2016
@ponasromas
Copy link

ponasromas commented Aug 15, 2017

Hello,

This issue still not resolved. There is code like this:

include_once ('class.cpanel.php');

$cpanel = new Cpanel();

$account_info = $cpanel->callWHMApi('accountsummary',
    [
,    'domain'        => "domain.tld"
    ]
);

if ( isset($account_info) ) {
    $result = json_decode ( $account_info, true );
    $results = $result[ 'data' ][ 'acct' ][0];

    $cgi_domain = $results[ 'domain' ];
    $cgi_inodes = $results[ 'inodesused' ];
    $cgi_mailboxes = $results[ 'maxpop' ];
    $cgi_mailsperhour = $results[ 'max_email_per_hour' ];
    $cgi_outgoingmail = $results[ 'outgoing_mail_suspended' ];
    $cgi_suspended = $results[ 'suspended' ];
    $cgi_suspend_reason = $results[ 'suspendreason' ];
    $cgi_ip = $results[ 'ip' ];
    $cgi_plan = $results[ 'plan' ];
    $cgi_user = $results[ 'user' ];
    $cgi_diskused = $results[ 'diskused' ];
    $cgi_maxsql = $results[ 'maxsql' ];
    $cgi_disklimit = $results[ 'diskused' ];
}   

Code executed and result received, but with notice:

Notice: Undefined offset: 0

Sure, I can use "@" to supress that dirty notice, but it's not the best way...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants