@@ -2672,8 +2672,15 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, bool ext)
26722672 int rc , msgid ;
26732673 size_t dn_len ;
26742674
2675- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Op|h!" , & link , ldap_link_ce , & dn , & dn_len , & server_controls_ht ) != SUCCESS ) {
2676- RETURN_THROWS ();
2675+ if (ZEND_IS_METHOD_CALL ()) {
2676+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "p|h!" , & dn , & dn_len , & server_controls_ht ) != SUCCESS ) {
2677+ RETURN_THROWS ();
2678+ }
2679+ link = ZEND_THIS ;
2680+ } else {
2681+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Op|h!" , & link , ldap_link_ce , & dn , & dn_len , & server_controls_ht ) != SUCCESS ) {
2682+ RETURN_THROWS ();
2683+ }
26772684 }
26782685
26792686 ld = Z_LDAP_LINK_P (link );
@@ -2693,15 +2700,23 @@ static void php_ldap_do_delete(INTERNAL_FUNCTION_PARAMETERS, bool ext)
26932700 rc = ldap_delete_ext_s (ld -> link , dn , lserverctrls , NULL );
26942701 }
26952702 if (rc != LDAP_SUCCESS ) {
2696- php_error_docref (NULL , E_WARNING , "Delete: %s" , ldap_err2string (rc ));
2697- RETVAL_FALSE ;
2703+ if (ZEND_IS_METHOD_CALL ()) {
2704+ zend_throw_exception_ex (ldap_exception_ce , rc , "Delete: %s" , ldap_err2string (rc ));
2705+ } else {
2706+ php_error_docref (NULL , E_WARNING , "Delete: %s" , ldap_err2string (rc ));
2707+ RETVAL_FALSE ;
2708+ }
26982709 goto cleanup ;
26992710 } else if (ext ) {
27002711 LDAPMessage * ldap_res ;
27012712 rc = ldap_result (ld -> link , msgid , 1 /* LDAP_MSG_ALL */ , NULL , & ldap_res );
27022713 if (rc == -1 ) {
2703- php_error_docref (NULL , E_WARNING , "Delete operation failed" );
2704- RETVAL_FALSE ;
2714+ if (ZEND_IS_METHOD_CALL ()) {
2715+ zend_throw_exception_ex (ldap_exception_ce , 0 , "Delete operation failed" );
2716+ } else {
2717+ php_error_docref (NULL , E_WARNING , "Delete operation failed" );
2718+ RETVAL_FALSE ;
2719+ }
27052720 goto cleanup ;
27062721 }
27072722
@@ -2730,6 +2745,11 @@ PHP_FUNCTION(ldap_delete)
27302745/* }}} */
27312746
27322747/* {{{ Delete an entry from a directory */
2748+ PHP_METHOD (LDAP_Connection , delete )
2749+ {
2750+ php_ldap_do_delete (INTERNAL_FUNCTION_PARAM_PASSTHRU , true);
2751+ }
2752+
27332753PHP_FUNCTION (ldap_delete_ext )
27342754{
27352755 php_ldap_do_delete (INTERNAL_FUNCTION_PARAM_PASSTHRU , true);
0 commit comments