Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions SETUP/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@ see the git history.
[R202009](https://github.com/DistributedProofreaders/dproofreaders/releases/tag/R202009)
first before upgrading to R202102 or later releases.**

## R??????
## R202603
Scripts supporting this upgrade are in `SETUP/upgrade/24`

### Notices & Deprecations

This is the last release to support PHP 8.1. Future releases will only
This is the last release to support PHP 8.1 and 8.2. Future releases will only
support PHP 8.3 and later.

## Changes

* Page data (`page_events`, `wordcheck_events`, etc) older than 1 year is now
pruned (cpeel)
* Removed Greek quizzes and transliteration tool (mrducky4)
* Access to project pages now requires authentication (cpeel)
* Using Format Preview on a page is now tracked similar to WordCheck usage (cpeel)
* Sitemap has been removed now that most pages require authentication (cpeel)

## R202509
Scripts supporting this upgrade are in `SETUP/upgrade/23`

Expand Down
5 changes: 2 additions & 3 deletions SETUP/generate_manifest_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
throw new RuntimeException("Script is meant to be run via CLI");
}

if (! is_file("$relPath/base.inc")) {
if (! is_file("$relPath/manifest.inc")) {
throw new RuntimeException("First argument '$relPath' does not point to `pinc/` directory");
}

include_once($relPath."base.inc");
include_once($relPath."html_page_common.inc");
include_once($relPath."manifest.inc");

$manifest = get_js_manifest($basedir);
if (!$manifest) {
Expand Down
61 changes: 2 additions & 59 deletions pinc/html_page_common.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
include_once($relPath."languages.inc"); // html_lang_header();
include_once($relPath."languages.inc"); // lang_html_header();
include_once($relPath."manifest.inc");

define('NO_STATSBAR', false);
define('SHOW_STATSBAR', true);
Expand Down Expand Up @@ -199,61 +200,3 @@ function get_local_file_browser_cache_key($url)

return $cache_fixer;
}

/**
* @return string[]
*/
function get_js_manifest(string $basedir = ""): array
{
global $code_dir;

if (!$basedir) {
$basedir = $code_dir;
}

// first, see if the PHP version of our manifest file exists, and if so
// load it and get the opcache-cached version without hitting the disk
if (is_file("$basedir/dist/manifest.php")) {
require_once("$basedir/dist/manifest.php");
return get_cached_js_manifest(); // @phpstan-ignore function.notFound
}

// if it doesn't exist, see if the JSON version exists and if so load
// and process it
if (is_file("$basedir/dist/manifest.json")) {
$raw_manifest = json_decode(file_get_contents("$basedir/dist/manifest.json"), true) ?? [];
// webpack puts "auto" in the pathname, no idea why
foreach ($raw_manifest as $filename => $path) {
$manifest[$filename] = str_replace("auto", "dist", $path);
}
return $manifest;
}

// otherwise, just return an empty manifest
return [];
}

/**
* @param string[] $manifest
*/
function generate_cached_js_manifest(string $basedir, array $manifest): void
{
if (!$manifest) {
return;
}

if (!is_dir("$basedir/dist")) {
throw new RuntimeException("Directory '$basedir/dist' does not exist.");
}

$serialized_manifest = serialize($manifest);
$cached_php_file = <<<EOF
<?php
function get_cached_js_manifest(): array
{
return unserialize('$serialized_manifest');
}
EOF;

file_put_contents("$basedir/dist/manifest.php", $cached_php_file);
}
59 changes: 59 additions & 0 deletions pinc/manifest.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* @return string[]
*/
function get_js_manifest(string $basedir = ""): array
{
global $code_dir;

if (!$basedir) {
$basedir = $code_dir;
}

// first, see if the PHP version of our manifest file exists, and if so
// load it and get the opcache-cached version without hitting the disk
if (is_file("$basedir/dist/manifest.php")) {
require_once("$basedir/dist/manifest.php");
return get_cached_js_manifest(); // @phpstan-ignore function.notFound
}

// if it doesn't exist, see if the JSON version exists and if so load
// and process it
if (is_file("$basedir/dist/manifest.json")) {
$raw_manifest = json_decode(file_get_contents("$basedir/dist/manifest.json"), true) ?? [];
// webpack puts "auto" in the pathname, no idea why
foreach ($raw_manifest as $filename => $path) {
$manifest[$filename] = str_replace("auto", "dist", $path);
}
return $manifest;
}

// otherwise, just return an empty manifest
return [];
}

/**
* @param string[] $manifest
*/
function generate_cached_js_manifest(string $basedir, array $manifest): void
{
if (!$manifest) {
return;
}

if (!is_dir("$basedir/dist")) {
throw new RuntimeException("Directory '$basedir/dist' does not exist.");
}

$serialized_manifest = serialize($manifest);
$cached_php_file = <<<EOF
<?php
function get_cached_js_manifest(): array
{
return unserialize('$serialized_manifest');
}
EOF;

file_put_contents("$basedir/dist/manifest.php", $cached_php_file);
}
Loading