diff --git a/src/Tests/XmlRpcBasicTest.php b/src/Tests/XmlRpcBasicTest.php index 7265b6b..19595d1 100644 --- a/src/Tests/XmlRpcBasicTest.php +++ b/src/Tests/XmlRpcBasicTest.php @@ -115,7 +115,7 @@ class XmlRpcBasicTest extends XmlRpcTestBase { * @link http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php */ public function testInvalidServer() { - $invalid_endpoint = 'http://example.invalid/xmlrpc.php'; + $invalid_endpoint = 'http://example.invalid/xmlrpc'; $result = xmlrpc($invalid_endpoint, ['system.listMethods' => []]); $this->verboseResult($result); $this->assertFalse($result, "Calling an unknown host returns an error condition"); diff --git a/src/Tests/XmlRpcTestBase.php b/src/Tests/XmlRpcTestBase.php index bbd9a4e..3683516 100644 --- a/src/Tests/XmlRpcTestBase.php +++ b/src/Tests/XmlRpcTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\xmlrpc\Tests; use Drupal\Component\Utility\SafeMarkup; +use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; use Symfony\Component\Routing\Generator\UrlGenerator; @@ -56,7 +57,7 @@ abstract class XmlRpcTestBase extends WebTestBase { */ protected function xmlRpcGet(array $args, array $headers = []) { - $url = \Drupal::url('xmlrpc', [], ['absolute' => TRUE]); + $url = Url::fromRoute('xmlrpc', [], ['absolute' => TRUE])->toString(); $result = xmlrpc($url, $args, $headers); $this->verboseResult($result); diff --git a/xmlrpc.inc b/xmlrpc.inc index d37b38a..5abca8f 100644 --- a/xmlrpc.inc +++ b/xmlrpc.inc @@ -563,7 +563,7 @@ function xmlrpc_base64_get_xml($xmlrpc_base64) { * Performs one or more XML-RPC requests. * * @param string $url - * Absolute URL of the XML-RPC endpoint, e.g. http://example.com/xmlrpc.php . + * Absolute URL of the XML-RPC endpoint, e.g. http://example.com/xmlrpc . * @param array $args * An associative array whose keys are the methods to call and whose values * are the arguments to pass to the respective method. If multiple methods diff --git a/xmlrpc.module b/xmlrpc.module index 8baaf31..6ef2be7 100644 --- a/xmlrpc.module +++ b/xmlrpc.module @@ -5,19 +5,20 @@ * Enables XML-RPC functionality. */ -use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Url; /** * Implements hook_help(). */ -function xmlrpc_help($route_name, RouteMatchInterface $route_match) { +function xmlrpc_help($route_name) { switch ($route_name) { case 'help.page.xmlrpc': $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . t('The XML-RPC module gives external systems the opportunity to communicate with the site through the XML-RPC protocol. An XML-RPC client can communicate with the site by making a request to xmlrpc.php. For more information, see the online documentation for the XML-RPC module.', array( - '!xrphp' => \Drupal::url('xmlrpc.php'), - '!xrdocs' => 'https://drupal.org/documentation/modules/xmlrpc', + $output .= '

' . t('The XML-RPC module gives external systems the opportunity to communicate with the site through the XML-RPC protocol. An XML-RPC client can communicate with the site by making a request to xmlrpc. For more information, see the online documentation for the XML-RPC module.', array( + ':url_definition' => 'https://en.wikipedia.org/wiki/XML-RPC', + ':url_endpoint' => Url::fromRoute('xmlrpc')->toString(), + ':url_docs' => 'https://drupal.org/documentation/modules/xmlrpc', )) . '

'; return $output; } @@ -28,7 +29,7 @@ function xmlrpc_help($route_name, RouteMatchInterface $route_match) { * * Usage example: * @code - * $result = xmlrpc('http://example.com/xmlrpc.php', array( + * $result = xmlrpc('http://example.com/xmlrpc', array( * 'service.methodName' => array($parameter, $second, $third), * )); * @endcode diff --git a/xmlrpc_example/src/Controller/XmlRpcExampleController.php b/xmlrpc_example/src/Controller/XmlRpcExampleController.php index beea406..d171182 100644 --- a/xmlrpc_example/src/Controller/XmlRpcExampleController.php +++ b/xmlrpc_example/src/Controller/XmlRpcExampleController.php @@ -7,6 +7,7 @@ namespace Drupal\xmlrpc_example\Controller; +use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Url; use Drupal\xmlrpc_example\XmlRpcExampleTrait; @@ -24,7 +25,7 @@ class XmlRpcExampleController extends ControllerBase { * Our router maps this method to the path 'examples/xmlrpc'. */ public function info() { - // Make the xmlrpc request. + // Make the XML-RPC request. $server = $this->getEndpoint(); $options = array('system.listMethods' => array()); $supported_methods = xmlrpc($server, $options); @@ -50,7 +51,9 @@ class XmlRpcExampleController extends ControllerBase { ], 'method_array' => [ '#theme' => 'item_list', - '#title' => $this->t('These methods are supported by !server', array('!server' => check_url($server))), + '#title' => $this->t('These methods are supported by :url', [ + ':url' => UrlHelper::stripDangerousProtocols($server), + ]), '#list_type' => 'ul', '#items' => $supported_methods, ], diff --git a/xmlrpc_example/src/Form/XmlRpcExampleAlterForm.php b/xmlrpc_example/src/Form/XmlRpcExampleAlterForm.php index 316f311..624fdf9 100644 --- a/xmlrpc_example/src/Form/XmlRpcExampleAlterForm.php +++ b/xmlrpc_example/src/Form/XmlRpcExampleAlterForm.php @@ -14,6 +14,7 @@ namespace Drupal\xmlrpc_example\Form; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Url; /** * Presents a form to enable/disable the code implemented in hook_xmlrpc_alter. @@ -53,7 +54,7 @@ class XmlRpcExampleAlterForm extends ConfigFormBase { ); $form['info'] = array( '#markup' => '
' . $this->t('Use the client submission form to see the results of checking this checkbox', array( - ':url' => $this->url('xmlrpc_example.client'), + ':url' => Url::fromRoute('xmlrpc_example.client')->toString(), )) . '
', ); diff --git a/xmlrpc_example/src/Form/XmlRpcExampleClientForm.php b/xmlrpc_example/src/Form/XmlRpcExampleClientForm.php index c46841b..b362121 100644 --- a/xmlrpc_example/src/Form/XmlRpcExampleClientForm.php +++ b/xmlrpc_example/src/Form/XmlRpcExampleClientForm.php @@ -91,7 +91,7 @@ class XmlRpcExampleClientForm extends FormBase { $form['overridden'] = array( '#type' => 'markup', '#markup' => '
' . $this->t('Just a note of warning: The alter form has been used to disable the limits, so you may want to turn that off if you do not want it.', array( - ':url' => $this->url('xmlrpc_example.alter'), + ':url' => Url::fromRoute('xmlrpc_example.alter')->toString(), )) . '
', ); } diff --git a/xmlrpc_example/src/Form/XmlRpcExampleServerForm.php b/xmlrpc_example/src/Form/XmlRpcExampleServerForm.php index 157d111..69475db 100644 --- a/xmlrpc_example/src/Form/XmlRpcExampleServerForm.php +++ b/xmlrpc_example/src/Form/XmlRpcExampleServerForm.php @@ -15,6 +15,7 @@ namespace Drupal\xmlrpc_example\Form; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Url; /** @@ -69,7 +70,7 @@ class XmlRpcExampleServerForm extends ConfigFormBase { $form['info'] = array( '#type' => 'markup', '#markup' => '
' . $this->t('Use the XML-RPC Client example form to experiment.', array( - ':url' => $this->url('xmlrpc_example.client'), + ':url' => Url::fromRoute('xmlrpc_example.client')->toString(), )), ); @@ -77,7 +78,7 @@ class XmlRpcExampleServerForm extends ConfigFormBase { $form['overridden'] = array( '#type' => 'markup', '#markup' => '
' . $this->t('Just a note of warning: The alter form has been used to disable the limits, so you may want to turn that off if you do not want it.', array( - ':url' => $this->url('xmlrpc_example.alter'), + ':url' => Url::fromRoute('xmlrpc_example.alter')->toString(), )) . '
', ); }