diff --git a/composer.json b/composer.json index ccaad20..f1a7d14 100644 --- a/composer.json +++ b/composer.json @@ -15,10 +15,10 @@ ], "support": { "issues": "https://www.drupal.org/project/issues/php", - "source": "https://git.drupal.org/project/php.git" + "source": "http://git.drupal.org/project/php.git" }, "license": "GPL-2.0+", "require": { - "drupal/core": "~8.0" + "drupal/core": "~8.0 || ^9" } } diff --git a/php.info.yml b/php.info.yml index cfa95f6..0703197 100644 --- a/php.info.yml +++ b/php.info.yml @@ -2,6 +2,7 @@ name: PHP Filter type: module description: Allows embedded PHP code/snippets to be evaluated. Enabling this can cause security and performance issues as it allows users to execute PHP code on your site. core: 8.x +core_version_requirement: ^8 || ^9 package: 'Filters' configure: filter.admin_overview dependencies: diff --git a/php.module b/php.module index 8f9f29e..f25d541 100644 --- a/php.module +++ b/php.module @@ -16,11 +16,11 @@ function php_help($route_name, RouteMatchInterface $route_match) { case 'help.page.php': $output = ''; $output .= '
' . t('The PHP Filter module adds a PHP filter to your site, for use with text formats. This filter adds the ability to execute PHP code in any text field that uses a text format (such as the body of a content item or the text of a comment). PHP is a general-purpose scripting language widely-used for web development, and is the language with which Drupal has been developed. For more information, see the online handbook entry for the PHP Filter module.', [':filter' => Url::fromRoute('filter.admin_overview'), ':php-net' => 'http://www.php.net', ':php' => 'https://drupal.org/documentation/modules/php']) . '
'; + $output .= '' . t('The PHP Filter module adds a PHP filter to your site, for use with text formats. This filter adds the ability to execute PHP code in any text field that uses a text format (such as the body of a content item or the text of a comment). PHP is a general-purpose scripting language widely-used for web development, and is the language with which Drupal has been developed. For more information, see the online handbook entry for the PHP Filter module.', [':filter' => Url::fromRoute('filter.admin_overview'), ':php-net' => 'http://www.php.net', ':php' => 'http://drupal.org/documentation/modules/php']) . '
'; $output .= 'register_globals
is turned off. If you need to use forms, understand and use the functions in the Drupal Form API.', [':formapi' => 'https://api.drupal.org/api/group/form_api/8']) . 'register_globals
is turned off. If you need to use forms, understand and use the functions in the Drupal Form API.', [':formapi' => 'http://api.drupal.org/api/group/form_api/8']) . 'print
or return
statement in your code to output content.') . '' . t('Drupal.org offers some example PHP snippets, or you can create your own with some PHP experience and knowledge of the Drupal system.', [':drupal' => 'https://drupal.org', ':php-snippets' => 'https://drupal.org/documentation/customization/php-snippets']) . '
'; + $output .= '' . t('Drupal.org offers some example PHP snippets, or you can create your own with some PHP experience and knowledge of the Drupal system.', [':drupal' => 'http://drupal.org', ':php-snippets' => 'http://drupal.org/documentation/customization/php-snippets']) . '
'; return $output; } else { diff --git a/src/Tests/PhpFilterTest.php b/src/Tests/PhpFilterTest.php index 8b5b521..adeb1d3 100644 --- a/src/Tests/PhpFilterTest.php +++ b/src/Tests/PhpFilterTest.php @@ -14,7 +14,10 @@ class PhpFilterTest extends PhpTestBase { */ public function testPhpFilter() { // Log in as a user with permission to use the PHP code text format. - $php_code_permission = entity_load('filter_format', 'php_code')->getPermissionName(); + $php_code_permission = \Drupal::entityTypeManager() + ->getStorage('filter_format') + ->load('php_code') + ->getPermissionName(); $permissions = [ 'access content', 'create page content', @@ -35,7 +38,10 @@ class PhpFilterTest extends PhpTestBase { $edit = []; $edit['body[0][format]'] = $this->phpCodeFormat->id(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - $this->assertRaw(t('@type %title has been updated.', ['@type' => 'Basic page', '%title' => $node->link($node->getTitle())]), 'PHP code filter turned on.'); + $this->assertRaw(t('@type %title has been updated.', [ + '@type' => 'Basic page', + '%title' => $node->toLink($node->getTitle())->toString(), + ]), 'PHP code filter turned on.'); // Make sure that the PHP code shows up as text. $this->assertNoText('print "SimpleTest PHP was executed!"', "PHP code isn't displayed."); diff --git a/src/Tests/Plugin/views/PhpArgumentValidatorTest.php b/src/Tests/Plugin/views/PhpArgumentValidatorTest.php index 00b1c8f..c31fa6c 100644 --- a/src/Tests/Plugin/views/PhpArgumentValidatorTest.php +++ b/src/Tests/Plugin/views/PhpArgumentValidatorTest.php @@ -2,7 +2,7 @@ namespace Drupal\php\Tests\Plugin\views; -use Drupal\views\Tests\ViewKernelTestBase; +use Drupal\Tests\views\Kernel\ViewsKernelTestBase; use Drupal\views\Tests\ViewTestData; use Drupal\views\Views; @@ -13,7 +13,7 @@ use Drupal\views\Views; * * @see \Drupal\php\Plugin\views\argument_validator\Php */ -class PhpArgumentValidatorTest extends ViewKernelTestBase { +class PhpArgumentValidatorTest extends ViewsKernelTestBase { /** * Views used by this test.