Commit 1e549c4a authored by andrei.dincu's avatar andrei.dincu
Browse files

Issue #2249723 by andrei.dincu: Replace [] with Drupal wrapper in...

Issue #2249723 by andrei.dincu: Replace [] with Drupal wrapper in xmlsitemap.pages.inc, XmlSitemapEnginesTestController and xmlsitemap_engines_test.module
parent 30dfe207
......@@ -14,7 +14,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
function xmlsitemap_get_current_chunk(XmlSitemapInterface $sitemap) {
// Check if we should be displaing the index.
if (!isset($_GET['page']) || !is_numeric($_GET['page'])) {
$query = \Drupal::request()->query;
if (!isset($query->get('page')) || !is_numeric($query->get('page'))) {
if ($sitemap->getChunks() > 1) {
return 'index';
}
......@@ -23,7 +24,7 @@ function xmlsitemap_get_current_chunk(XmlSitemapInterface $sitemap) {
}
}
else {
return (int) $_GET['page'];
return (int) $query->get('page');
}
}
......@@ -45,7 +46,8 @@ function xmlsitemap_output_chunk() {
$file = xmlsitemap_sitemap_get_file($sitemap, $chunk);
// Provide debugging information if enabled.
if (\Drupal::state()->get('developer_mode', 0) && isset($_GET['debug'])) {
$query = \Drupal::request()->query;
if (\Drupal::state()->get('developer_mode', 0) && isset($query->get('debug'))) {
$output = array();
$context = xmlsitemap_get_current_context();
$output[] = "Current context: " . print_r($context, TRUE);
......
......@@ -15,13 +15,14 @@ use Drupal\Component\Utility\UrlHelper;
class XmlSitemapEnginesTestController extends ControllerBase {
public function render() {
if (empty($_GET['sitemap']) || !UrlHelper::isValid($_GET['sitemap'])) {
$query = \Drupal::request()->query->get('sitemap');
if (empty($query) || !UrlHelper::isValid($query)) {
watchdog('xmlsitemap', 'No valid sitemap parameter provided.', array(), WATCHDOG_WARNING);
// @todo Remove this? Causes an extra watchdog error to be handled.
throw new NotFoundHttpException();
}
else {
watchdog('xmlsitemap', 'Recieved ping for @sitemap.', array('@sitemap' => $_GET['sitemap']));
watchdog('xmlsitemap', 'Recieved ping for @sitemap.', array('@sitemap' => $query));
}
return new Response('', 200);
}
......
<?php
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Component\Utility\UrlHelper;
/**
* Implements hook_xmlsitemap_engine_info().
......@@ -21,12 +22,14 @@ function xmlsitemap_engines_test_xmlsitemap_engine_info_alter(&$engines) {
}
function xmlsitemap_engines_test_pinged() {
if (empty($_GET['sitemap']) || !valid_url($_GET['sitemap'])) {
$query_sitemap = \Drupal::request()->query->get('sitemap');
//$query_sitemap = $query->get('sitemap');
if (empty($query_sitemap) || !UrlHelper::isValid($query_sitemap)) {
watchdog('xmlsitemap', 'No valid sitemap parameter provided.', array(), WATCHDOG_WARNING);
// @todo Remove this? Causes an extra watchdog error to be handled.
throw new NotFoundHttpException();
}
else {
watchdog('xmlsitemap', 'Recieved ping for @sitemap.', array('@sitemap' => $_GET['sitemap']));
watchdog('xmlsitemap', 'Recieved ping for @sitemap.', array('@sitemap' => $query_sitemap));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment