diff --git a/core/modules/block/src/Plugin/migrate/process/d6/BlockVisibility.php b/core/modules/block/src/Plugin/migrate/process/d6/BlockVisibility.php
index 9afd180..6e8fa3a 100644
--- a/core/modules/block/src/Plugin/migrate/process/d6/BlockVisibility.php
+++ b/core/modules/block/src/Plugin/migrate/process/d6/BlockVisibility.php
@@ -7,8 +7,10 @@
 
 namespace Drupal\block\Plugin\migrate\process\d6;
 
+use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\MigrateSkipRowException;
 use Drupal\migrate\ProcessPluginBase;
 use Drupal\migrate\Row;
 use Drupal\migrate\Entity\MigrationInterface;
@@ -23,19 +25,34 @@
 class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPluginInterface {
 
   /**
-   * The migration plugin.
+   * The migration.
+   *
+   * @var \Drupal\migrate\Entity\MigrationInterface
+   */
+  protected $migration;
+
+  /**
+   * The d6 user role migration plugin.
    *
    * @var \Drupal\migrate\Plugin\MigrateProcessInterface
    */
   protected $migrationPlugin;
 
   /**
+   * The module handler.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
+  /**
    * {@inheritdoc}
    */
-  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin, ModuleHandlerInterface $module_handler) {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->migration = $migration;
     $this->migrationPlugin = $migration_plugin;
+    $this->moduleHandler = $module_handler;
   }
 
   /**
@@ -47,7 +64,8 @@ public static function create(ContainerInterface $container, array $configuratio
       $plugin_id,
       $plugin_definition,
       $migration,
-      $container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_user_role'), $migration)
+      $container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_user_role'), $migration),
+      $container->get('module_handler')
     );
   }
   /**
@@ -60,9 +78,27 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
     $visibility = array();
 
     if (!empty($pages)) {
-      $visibility['request_path']['pages'] = $pages;
       $visibility['request_path']['id'] = 'request_path';
       $visibility['request_path']['negate'] = !$old_visibility;
+
+      // If the visibility was using PHP code, handle it separately.
+      if ($old_visibility == 2) {
+        // If the PHP module is installed, migrate the old data directly.
+        if ($this->moduleHandler->moduleExists('php')) {
+          $visibility['request_path']['pages'] = $pages;
+        }
+        else {
+          throw new MigrateSkipRowException();
+        }
+      }
+      // For non-PHP code, ensure paths have leading slashes.
+      else {
+        $paths = preg_split("(\r\n?|\n)", $pages);
+        foreach ($paths as $key => $path) {
+          $paths[$key] = $path === '<front>' ? $path : '/' . ltrim($path, '/');
+        }
+        $visibility['request_path']['pages'] = implode("\n", $paths);
+      }
     }
 
     if (!empty($roles)) {
diff --git a/core/modules/block/src/Tests/Migrate/d6/MigrateBlockTest.php b/core/modules/block/src/Tests/Migrate/d6/MigrateBlockTest.php
index 49d40d7..5567d12 100644
--- a/core/modules/block/src/Tests/Migrate/d6/MigrateBlockTest.php
+++ b/core/modules/block/src/Tests/Migrate/d6/MigrateBlockTest.php
@@ -129,7 +129,7 @@ public function testBlockMigration() {
     $this->assertIdentical('bartik', $test_block_system->getTheme());
     $visibility = $test_block_system->getVisibility();
     $this->assertIdentical('request_path', $visibility['request_path']['id']);
-    $this->assertIdentical('node/1', $visibility['request_path']['pages']);
+    $this->assertIdentical('/node/1', $visibility['request_path']['pages']);
     $this->assertTrue($visibility['request_path']['negate']);
     $this->assertIdentical(-5, $test_block_system->getWeight());
 
@@ -159,7 +159,7 @@ public function testBlockMigration() {
     $this->assertIdentical('bluemarine', $test_block_block_1->getTheme());
     $visibility = $test_block_block_1->getVisibility();
     $this->assertIdentical('request_path', $visibility['request_path']['id']);
-    $this->assertIdentical('node', $visibility['request_path']['pages']);
+    $this->assertIdentical('/node', $visibility['request_path']['pages']);
     $this->assertFalse($visibility['request_path']['negate']);
     $this->assertIdentical(-4, $test_block_block_1->getWeight());
 
@@ -176,7 +176,7 @@ public function testBlockMigration() {
     $this->assertIdentical('left', $test_block_block_3->getRegion());
     $this->assertIdentical('test_theme', $test_block_block_3->getTheme());
     $visibility = $test_block_block_3->getVisibility();
-    $this->assertTrue(empty($visibility));
+    $this->assertIdentical("<front>\n/node/1\n/blog/*", $visibility['request_path']['pages']);
     $this->assertIdentical(-2, $test_block_block_3->getWeight());
   }
 }
diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/process/d6/BlockVisibilityTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/process/d6/BlockVisibilityTest.php
new file mode 100644
index 0000000..6e09a03
--- /dev/null
+++ b/core/modules/block/tests/src/Unit/Plugin/migrate/process/d6/BlockVisibilityTest.php
@@ -0,0 +1,131 @@
+<?php
+
+/**
+ * @file
+ * Contains
+ *   \Drupal\Tests\block\Unit\Plugin\migrate\process\d6\BlockVisibilityTest.
+ */
+
+namespace Drupal\Tests\block\Unit\Plugin\migrate\process\d6;
+
+use Drupal\block\Plugin\migrate\process\d6\BlockVisibility;
+use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\migrate\Entity\MigrationInterface;
+use Drupal\migrate\Plugin\MigrateProcessInterface;
+use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
+
+/**
+ * @coversDefaultClass \Drupal\block\Plugin\migrate\process\d6\BlockVisibility
+ * @group migrate
+ *
+ * @todo Extend this test to cover the $roles portion of the migration.
+ */
+class BlockVisibilityTest extends MigrateProcessTestCase {
+
+  /**
+   * The migration.
+   *
+   * @var \Drupal\migrate\Entity\MigrationInterface
+   */
+  protected $migration;
+
+  /**
+   * The d6 user role migration plugin.
+   *
+   * @var \Drupal\migrate\Plugin\MigrateProcessInterface
+   */
+  protected $migrationPlugin;
+
+  /**
+   * The module handler.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface
+   */
+  protected $moduleHandler;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->migration = $this->prophesize(MigrationInterface::class);
+    $this->migrationPlugin = $this->prophesize(MigrateProcessInterface::class);
+    $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
+    $this->plugin = new BlockVisibility([], 'map', array(), $this->migration->reveal(), $this->migrationPlugin->reveal(), $this->moduleHandler->reveal());
+  }
+
+  /**
+   * @covers ::transform
+   *
+   * @dataProvider providerTestTransform
+   */
+  public function testTransform($pages, $roles, $visibility, $expected) {
+    $value = [$pages, $roles, $visibility];
+    $transformed_value = $this->plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
+    $this->assertSame($expected, $transformed_value);
+  }
+
+  public function providerTestTransform() {
+    $data = [];
+    $data[] = [
+      '',
+      [],
+      0,
+      [],
+    ];
+    $data[] = [
+      '<front>',
+      [],
+      0,
+      ['request_path' => [
+        'id' => 'request_path',
+        'negate' => TRUE,
+        'pages' => '<front>',
+      ]],
+    ];
+    $data[] = [
+      "foo\n/bar\rbaz\r\n<front>",
+      [],
+      1,
+      ['request_path' => [
+        'id' => 'request_path',
+        'negate' => FALSE,
+        'pages' => "/foo\n/bar\n/baz\n<front>",
+      ]],
+    ];
+    return $data;
+  }
+
+  /**
+   * @covers ::transform
+   */
+  public function testTransformPhpEnabled() {
+    $this->moduleHandler->moduleExists('php')->willReturn(TRUE);
+
+    $pages = '<?php';
+    $value = [$pages, [], 2];
+    $transformed_value = $this->plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
+
+    $expected = ['request_path' => [
+      'id' => 'request_path',
+      'negate' => FALSE,
+      'pages' => $pages,
+    ]];
+    $this->assertSame($expected, $transformed_value);
+  }
+
+  /**
+   * @covers ::transform
+   *
+   * @expectedException \Drupal\migrate\MigrateSkipRowException
+   */
+  public function testTransformPhpDisabled() {
+    $value = ['<?php', [], 2];
+    $transformed_value = $this->plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
+
+    $expected = [];
+    $this->assertSame($expected, $transformed_value);
+  }
+
+}
diff --git a/core/modules/migrate_drupal/src/Tests/Table/d6/Blocks.php b/core/modules/migrate_drupal/src/Tests/Table/d6/Blocks.php
index ca9d72c..a8d6047 100644
--- a/core/modules/migrate_drupal/src/Tests/Table/d6/Blocks.php
+++ b/core/modules/migrate_drupal/src/Tests/Table/d6/Blocks.php
@@ -298,7 +298,7 @@ public function load() {
       'custom' => '0',
       'throttle' => '0',
       'visibility' => '0',
-      'pages' => '',
+      'pages' => "<front>\r\nnode/1\nblog/*",
       'title' => '',
       'cache' => '-1',
     ))->values(array(
@@ -403,4 +403,4 @@ public function load() {
   }
 
 }
-#aecc8e1067d73824c43bfaf26f9ebf8c
+#61867be078435fa043173fa346d83a5a
