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('About') . '

'; - $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 .= '

' . t('Uses') . '

'; $output .= '
'; $output .= '
' . t('Enabling execution of PHP in text fields') . '
'; - $output .= '
' . t('The PHP Filter module allows users with the proper permissions to include custom PHP code that will get executed when pages of your site are processed. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious or inexperienced user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use. Example PHP snippets can be found on Drupal.org.', [':php-snippets' => 'https://drupal.org/documentation/customization/php-snippets']) . '
'; + $output .= '
' . t('The PHP Filter module allows users with the proper permissions to include custom PHP code that will get executed when pages of your site are processed. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious or inexperienced user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use. Example PHP snippets can be found on Drupal.org.', [':php-snippets' => 'http://drupal.org/documentation/customization/php-snippets']) . '
'; $output .= '
'; return $output; } diff --git a/php.services.yml b/php.services.yml index f310bfa..fb998b5 100644 --- a/php.services.yml +++ b/php.services.yml @@ -3,5 +3,5 @@ services: class: Drupal\php\PhpUninstallValidator tags: - { name: module_install.uninstall_validator } - arguments: ['@plugin.manager.filter', '@entity.manager', '@string_translation'] + arguments: ['@plugin.manager.filter', '@entity_type.manager', '@string_translation'] lazy: false diff --git a/src/Plugin/Filter/Php.php b/src/Plugin/Filter/Php.php index 68ee07e..dbb235f 100644 --- a/src/Plugin/Filter/Php.php +++ b/src/Plugin/Filter/Php.php @@ -40,7 +40,7 @@ class Php extends FilterBase { $output .= ''; - $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' => '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.