Commit c72c953a authored by catch's avatar catch
Browse files

Issue #3186795 by mondrake, daffie: Deprecate Drupal\Core\Database\StatementEmpty

parent 030bfb84
Loading
Loading
Loading
Loading
+7 −0
Changes for core/lib/Drupal/Core/Database/StatementEmpty.php: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

namespace Drupal\Core\Database;

@trigger_error('\Drupal\Core\Database\StatementEmpty is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no replacement. Use mocked StatementInterface classes in tests if needed. See https://www.drupal.org/node/3201283', E_USER_DEPRECATED);

/**
 * Empty implementation of a database statement.
 *
@@ -12,6 +14,11 @@
 * result set that happens to contain no records.
 *
 * @see \Drupal\search\SearchQuery
 *
 * @deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no
 *   replacement. Use mocked StatementInterface classes in tests if needed.
 *
 * @see https://www.drupal.org/node/1234567
 */
class StatementEmpty implements \Iterator, StatementInterface {

+3 −0
Changes for core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,8 +15,11 @@ class EmptyStatementTest extends UnitTestCase {

  /**
   * Tests that the empty result set behaves as empty.
   *
   * @group legacy
   */
  public function testEmpty() {
    $this->expectDeprecation('\Drupal\Core\Database\StatementEmpty is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no replacement. Use mocked StatementInterface classes in tests if needed. See https://www.drupal.org/node/3201283');
    $result = new StatementEmpty();

    $this->assertInstanceOf(StatementInterface::class, $result);
+1 −2
Changes for core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@

use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Log;
use Drupal\Core\Database\StatementEmpty;
use Drupal\Core\Database\StatementWrapper;

/**
@@ -57,7 +56,7 @@ public function __construct(\PDO $connection, array $connection_options, $identi
   * {@inheritdoc}
   */
  public function queryRange($query, $from, $count, array $args = [], array $options = []) {
    return new StatementEmpty();
    return NULL;
  }

  /**
+1 −2
Changes for core/tests/fixtures/database_drivers/custom/fake/Connection.php: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
namespace Drupal\Driver\Database\fake;

use Drupal\Core\Database\Connection as CoreConnection;
use Drupal\Core\Database\StatementEmpty;

/**
 * A fake Connection class for testing purposes.
@@ -22,7 +21,7 @@ class Connection extends CoreConnection {
   * {@inheritdoc}
   */
  public function queryRange($query, $from, $count, array $args = [], array $options = []) {
    return new StatementEmpty();
    return NULL;
  }

  /**