Skip to content

Commit e39dda5

Browse files
markrandallderickr
authored andcommitted
Use ProjectGlobals::getBackendRoot to handle backend/ moving into public/.
1 parent cfcdf82 commit e39dda5

7 files changed

Lines changed: 20 additions & 8 deletions

File tree

include/download-instructions/windows-downloads.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
2+
3+
use phpweb\ProjectGlobals;
4+
25
$baseDownloads = 'https://downloads.php.net/~windows/releases/archives/';
36

4-
$dataStr = @file_get_contents(__DIR__ . '/../../backend/win-releases.json');
7+
$dataStr = @file_get_contents(ProjectGlobals::getBackendRoot() . '/win-releases.json');
58
$releases = $dataStr ? json_decode($dataStr, true) : null;
69

710
if (!is_array($releases)) {

include/manual-lookup.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ function find_manual_page($lang, $keyword)
110110
$dbh = false;
111111
if (class_exists('PDO')) {
112112
if (in_array('sqlite', PDO::getAvailableDrivers(), true)) {
113-
if (file_exists(ProjectGlobals::getProjectRoot() . '/backend/manual-lookup.sqlite')) {
113+
if (file_exists(ProjectGlobals::getBackendRoot() . '/manual-lookup.sqlite')) {
114114
try {
115-
$dbh = new PDO( 'sqlite:' . ProjectGlobals::getProjectRoot() . '/backend/manual-lookup.sqlite', '', '', [PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => true] );
115+
$dbh = new PDO( 'sqlite:' . ProjectGlobals::getBackendRoot() . '/manual-lookup.sqlite', '', '', [PDO::ATTR_PERSISTENT => true, PDO::ATTR_EMULATE_PREPARES => true] );
116116
} catch (PDOException $e) {
117117
return find_manual_page_slow($lang, $keyword);
118118
}

include/shared-manual.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ END_USERNOTE_HEADER;
9797
function manual_notes_load(string $id): array
9898
{
9999
$hash = substr(md5($id), 0, 16);
100-
$notes_file = ProjectGlobals::getPublicRoot() . "/backend/notes/" .
100+
$notes_file = ProjectGlobals::getBackendRoot() . "/notes/" .
101101
substr($hash, 0, 2) . "/$hash";
102102

103103
// Open the note file for reading and get the data (12KB)

public/manual/vote-note.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
if (isset($_SERVER['HTTP_X_JSON']) && $_SERVER['HTTP_X_JSON'] == 'On' && !empty($_REQUEST['id']) && !empty($_REQUEST['page']) && ($N = manual_notes_load($_REQUEST['page'])) && array_key_exists($_REQUEST['id'], $N) && !empty($_REQUEST['vote']) && ($_REQUEST['vote'] === 'up' || $_REQUEST['vote'] === 'down')) {
2222
$response = [];
2323
$hash = substr(md5($_REQUEST['page']), 0, 16);
24-
$notes_file = ProjectGlobals::getPublicRoot() . "/backend/notes/" . substr($hash, 0, 2) . "/$hash";
24+
$notes_file = ProjectGlobals::getBackendRoot() . "/notes/" . substr($hash, 0, 2) . "/$hash";
2525
if (!file_exists($notes_file)) {
2626
$response["success"] = false;
2727
$response["msg"] = "Invalid request.";
@@ -61,7 +61,7 @@
6161
}
6262
else {
6363
$hash = substr(md5($_REQUEST['page']), 0, 16);
64-
$notes_file = ProjectGlobals::getPublicRoot(). "/backend/notes/" . substr($hash, 0, 2) . "/$hash";
64+
$notes_file = ProjectGlobals::getBackendRoot(). "/notes/" . substr($hash, 0, 2) . "/$hash";
6565
if (file_exists($notes_file)) {
6666
$data = [
6767
"noteid" => $_REQUEST['id'],

public/pre-release-builds.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use phpweb\ProjectGlobals;
4+
25
$_SERVER['BASE_PAGE'] = 'qa.php';
36
require_once __DIR__ . '/../include/prepend.inc';
47
require_once __DIR__ . '/../include/release-qa.php';
@@ -114,7 +117,7 @@
114117

115118
<h2 id="windows">Windows Builds</h2>
116119
<?php
117-
$winQaFile = __DIR__ . '/backend/win-qa-releases.json';
120+
$winQaFile = ProjectGlobals::getBackendRoot() . '/win-qa-releases.json';
118121
$winQaBase = 'https://downloads.php.net/~windows/qa/';
119122
$winQaMessage = '';
120123
$winQaReleases = [];

src/ProjectGlobals.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public static function getProjectRoot(): string
1313
?: throw new Error('Unable to locate project root');
1414
}
1515

16+
public static function getBackendRoot(): string
17+
{
18+
return self::getProjectRoot() . '/public/backend';
19+
}
20+
1621
public static function getPublicRoot(): string
1722
{
1823
return realpath(__DIR__ . '/../public')

tests/Unit/UserNotes/SorterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace phpweb\Test\Unit\UserNotes;
66

77
use PHPUnit\Framework;
8+
use phpweb\ProjectGlobals;
89
use phpweb\UserNotes\Sorter;
910
use phpweb\UserNotes\UserNote;
1011

@@ -98,7 +99,7 @@ public function testSortSortsSomeNotes(): void
9899

99100
public function testSortSortsFullNotes(): void
100101
{
101-
$file = file(__DIR__ . '/../../../public/backend/notes/d7/d7742c269d23ea86');
102+
$file = file(ProjectGlobals::getBackendRoot() . '/notes/d7/d7742c269d23ea86');
102103

103104
$notes = [];
104105

0 commit comments

Comments
 (0)