Merge pull request #20 from matomo-org/php8
Make application compatible with PHP 8 / 8.1
This commit is contained in:
commit
1baccc04ad
12 changed files with 1770 additions and 504 deletions
|
@ -1,15 +1,16 @@
|
|||
{
|
||||
"require": {
|
||||
"slim/slim": "^3.0",
|
||||
"slim/slim": "^4.9",
|
||||
"ezyang/htmlpurifier": "^4.9",
|
||||
"phpmailer/phpmailer": "^6.0",
|
||||
"erusev/parsedown": "^1.6",
|
||||
"slim/twig-view": "^2.2",
|
||||
"knplabs/github-api": "^2.5",
|
||||
"php-http/guzzle6-adapter": "^1.1",
|
||||
"cache/filesystem-adapter": "^1.0",
|
||||
"monolog/monolog": "^1.23",
|
||||
"evert/sitemap-php": "^1.2"
|
||||
"slim/twig-view": "^3.3.0",
|
||||
"knplabs/github-api": "^3.5",
|
||||
"php-http/guzzle7-adapter": "^1.0",
|
||||
"cache/filesystem-adapter": "^1.2",
|
||||
"monolog/monolog": "^2.3",
|
||||
"evert/sitemap-php": "^1.2",
|
||||
"php-di/php-di": "^6.3"
|
||||
},
|
||||
"autoload":{
|
||||
"psr-0":{
|
||||
|
|
2177
src/composer.lock
generated
2177
src/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -22,7 +22,6 @@ define('PROJECT_EMAIL', 'developer@matomo.org');
|
|||
* On the screen you don't need to give any permission. The default view public info permission is good enough.
|
||||
*/
|
||||
define('GITHUB_CLIENT_ID', '');
|
||||
define('GITHUB_CLIENT_SECRET', '');
|
||||
define('GITHUB_ORGANIZATION', 'matomo-org');
|
||||
define('GITHUB_REPOSITORY', 'matomo');
|
||||
define('NUMBER_OF_ISSUES_PER_PAGE', 100);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
namespace helpers;
|
||||
|
||||
use Cache\Adapter\Filesystem\FilesystemCachePool;
|
||||
use Github\AuthMethod;
|
||||
use Github\Client;
|
||||
use Github\ResultPager;
|
||||
use League\Flysystem\Adapter\Local;
|
||||
|
@ -47,7 +48,7 @@ class GithubImporter {
|
|||
}
|
||||
}
|
||||
|
||||
public static function buildClient($clientId, $clientSecret)
|
||||
public static function buildClient($clientId)
|
||||
{
|
||||
$filesystemAdapter = new Local(realpath('../tmp/github_api_cache'));
|
||||
$filesystem = new Filesystem($filesystemAdapter);
|
||||
|
@ -57,7 +58,7 @@ class GithubImporter {
|
|||
$client->addCache($pool);
|
||||
|
||||
if (!empty($clientId)) {
|
||||
$client->authenticate($clientId, null, Client::AUTH_HTTP_TOKEN);
|
||||
$client->authenticate($clientId, null, AuthMethod::ACCESS_TOKEN);
|
||||
}
|
||||
|
||||
return $client;
|
||||
|
|
|
@ -15,7 +15,7 @@ class Issue {
|
|||
* Upfront you should check whether the issue actually exists by calling exists().
|
||||
*
|
||||
* @param int $issueNumber
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
public function getIssue($issueNumber)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ class Page
|
|||
* Upfront you should check whether the page actually exists by calling exists().
|
||||
*
|
||||
* @param int $pageNumber
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
public function getPage($pageNumber) {
|
||||
$path = $this->getPathToFile($pageNumber);
|
||||
|
|
|
@ -11,25 +11,25 @@ namespace helpers;
|
|||
class Twig
|
||||
{
|
||||
|
||||
public static function setDateFormat(\Twig_Environment $environment) {
|
||||
$environment->getExtension("Twig_Extension_Core")->setDateFormat('F jS Y');
|
||||
public static function setDateFormat(\Twig\Environment $environment) {
|
||||
$environment->getExtension("Twig\Extension\CoreExtension")->setDateFormat('F jS Y');
|
||||
}
|
||||
|
||||
public static function registerFilter(\Twig_Environment $environment) {
|
||||
public static function registerFilter(\Twig\Environment $environment) {
|
||||
$environment->addFilter(static::getMarkdownFilter());
|
||||
$environment->addFilter(static::getColorFilter());
|
||||
$environment->addFunction(static::getPaginationFunction());
|
||||
}
|
||||
|
||||
private static function getMarkdownFilter() {
|
||||
return new \Twig_SimpleFilter('markdown', function ($text) {
|
||||
return new \Twig\TwigFilter('markdown', function ($text) {
|
||||
$parser = new Markdown();
|
||||
return $parser->text($text);
|
||||
});
|
||||
}
|
||||
|
||||
private static function getColorFilter() {
|
||||
return new \Twig_SimpleFilter(
|
||||
return new \Twig\TwigFilter(
|
||||
/**
|
||||
* modified from https://24ways.org/2010/calculating-color-contrast/
|
||||
* @param $colorstring "#ffffff"
|
||||
|
@ -45,7 +45,7 @@ class Twig
|
|||
}
|
||||
|
||||
private static function getPaginationFunction() {
|
||||
return new \Twig_Function('paginationFunction', function ($numPages, $page) {
|
||||
return new \Twig\TwigFunction('paginationFunction', function ($numPages, $page) {
|
||||
$padding = PAGINATION_PADDING;
|
||||
$pages = [1];
|
||||
$i = 2;
|
||||
|
|
|
@ -10,28 +10,19 @@ require '../vendor/autoload.php';
|
|||
require '../config/config.php';
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
$config = [
|
||||
'settings' => [
|
||||
'displayErrorDetails' => DEBUG_ENABLED,
|
||||
],
|
||||
];
|
||||
|
||||
$app = new \Slim\App($config);
|
||||
|
||||
// Get container
|
||||
$container = $app->getContainer();
|
||||
$container = new \DI\Container();
|
||||
\Slim\Factory\AppFactory::setContainer($container);
|
||||
|
||||
// Register component on container
|
||||
$container['view'] = function ($container) {
|
||||
$view = new \Slim\Views\Twig(realpath("../templates/"), [
|
||||
$container->set('view', function () {
|
||||
$view = \Slim\Views\Twig::create(realpath("../templates/"), [
|
||||
'cache' => realpath('../tmp/templates_cache'),
|
||||
'debug' => DEBUG_ENABLED,
|
||||
]);
|
||||
|
||||
// Instantiate and add Slim specific extension
|
||||
$basePath = rtrim(str_ireplace('index.php', '', $container['request']->getUri()->getBasePath()), '/');
|
||||
$view->addExtension(new Slim\Views\TwigExtension($container['router'], $basePath));
|
||||
$view->addExtension(new \Twig_Extension_Debug());
|
||||
$view->addExtension(new \Twig\Extension\DebugExtension());
|
||||
$twig = $view->getEnvironment();
|
||||
helpers\Twig::setDateFormat($twig);
|
||||
helpers\Twig::registerFilter($twig);
|
||||
|
@ -44,7 +35,15 @@ $container['view'] = function ($container) {
|
|||
$view->getEnvironment()->addGlobal('privacyPolicyURL', PRIVACY_POLICY_URL);
|
||||
|
||||
return $view;
|
||||
};
|
||||
});
|
||||
|
||||
// Create App
|
||||
$app = \Slim\Factory\AppFactory::create();
|
||||
|
||||
// Add Twig-View Middleware
|
||||
$app->add(\Slim\Views\TwigMiddleware::createFromContainer($app));
|
||||
|
||||
$app->addErrorMiddleware(DEBUG_ENABLED, true, true);
|
||||
|
||||
require '../routes/page.php';
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
|
||||
|
||||
$app->get(
|
||||
'/{number:[0-9]+}', function ($request, $response, $args) {
|
||||
|
||||
|
@ -15,24 +14,26 @@ $app->get(
|
|||
$issue = new helpers\Issue();
|
||||
|
||||
if (!$issue->exists($number)) {
|
||||
throw new \Slim\Exception\NotFoundException($request, $response);
|
||||
throw new \Slim\Exception\HttpNotFoundException($request, $response);
|
||||
}
|
||||
|
||||
$details = $issue->getIssue($number);
|
||||
return $this->view->render($response, 'issue.twig', $details);
|
||||
|
||||
return $this->get('view')->render($response, 'issue.twig', $details);
|
||||
})->setName("issue");
|
||||
|
||||
$app->get('/', function ($request, $response, $args) {
|
||||
/** @var \Slim\Http\Request $request */
|
||||
$pageNumber = (int)$request->getQueryParam('page', 1);
|
||||
/** @var \GuzzleHttp\Psr7\ServerRequest $request */
|
||||
$params = $request->getQueryParams();
|
||||
$pageNumber = $params['page'] ?? 1;
|
||||
|
||||
$page = new helpers\Page();
|
||||
|
||||
if (!$page->exists($pageNumber)) {
|
||||
throw new \Slim\Exception\NotFoundException($request, $response);
|
||||
throw new \Slim\Exception\HttpNotFoundException($request, $response);
|
||||
}
|
||||
|
||||
$details = $page->getPage($pageNumber);
|
||||
|
||||
return $this->view->render($response, 'page.twig', $details);
|
||||
return $this->get('view')->render($response, 'page.twig', $details);
|
||||
})->setName("page");
|
|
@ -23,7 +23,7 @@ if (DEBUG_ENABLED) {
|
|||
}
|
||||
|
||||
$logger->info("authenticating");
|
||||
$client = helpers\GithubImporter::buildClient(GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET);
|
||||
$client = helpers\GithubImporter::buildClient(GITHUB_CLIENT_ID);
|
||||
$importer = new helpers\GithubImporter($client, $logger);
|
||||
|
||||
try {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<ul class="pagination">
|
||||
{% if page > 1 %}
|
||||
<li class="page-item">
|
||||
<a rel="prev" href="{{ path_for('page', [], { 'page': page - 1 }) }}" class="page-link">
|
||||
<a rel="prev" href="{{ url_for('page', [], { 'page': page - 1 }) }}" class="page-link">
|
||||
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1203 544q0 13-10 23l-393 393 393 393q10 10 10 23t-10 23l-50 50q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l466-466q10-10 23-10t23 10l50 50q10 10 10 23z"></path>
|
||||
</svg>
|
||||
|
@ -47,7 +47,7 @@
|
|||
{% endfor %}
|
||||
<li class="page-item">
|
||||
{% if page < num_pages %}
|
||||
<a rel="next" href="{{ path_for('page', [], { 'page': page + 1 }) }}" class="page-link">
|
||||
<a rel="next" href="{{ url_for('page', [], { 'page': page + 1 }) }}" class="page-link">
|
||||
<svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1171 960q0 13-10 23l-466 466q-10 10-23 10t-23-10l-50-50q-10-10-10-23t10-23l393-393-393-393q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l466 466q10 10 10 23z"></path>
|
||||
</svg>
|
||||
|
@ -65,7 +65,7 @@
|
|||
|
||||
{% macro printpage(i,active) %}
|
||||
<li class="page-item {{ i == active ? "active" : "other" }}">
|
||||
<a href="{{ path_for('page', [], { 'page': i }) }}"
|
||||
<a href="{{ url_for('page', [], { 'page': i }) }}"
|
||||
class="page-link">{{ i }}</a>
|
||||
</li>
|
||||
{% endmacro %}
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
{% block head %}
|
||||
{% if currentPage > 1 %}
|
||||
<link rel="prev" href="{{ path_for('page', [] , { 'page': previousPage }) }}"/>
|
||||
<link rel="prev" href="{{ url_for('page', [] , { 'page': previousPage }) }}"/>
|
||||
{% endif %}
|
||||
|
||||
{% if currentPage != numPages %}
|
||||
<link rel="next" href="{{ path_for('page', [], { 'page': nextPage }) }}"/>
|
||||
<link rel="next" href="{{ url_for('page', [], { 'page': nextPage }) }}"/>
|
||||
{% endif %}
|
||||
|
||||
<link rel="canonical" href="https://github.com/matomo-org/matomo/issues/" />
|
||||
|
@ -38,7 +38,7 @@
|
|||
<div class="card-deck"><div class="row">
|
||||
{% for issue in issues %}
|
||||
<div class="col-lg-3 col-md-4">
|
||||
<a href="{{ path_for('issue', { 'number': issue.number }) }}" class="card overviewCard">
|
||||
<a href="{{ url_for('issue', { 'number': issue.number }) }}" class="card overviewCard">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">{{ issue.title }}
|
||||
<small>#{{ issue.number }}</small>
|
||||
|
|
Reference in a new issue