bbdoc / PoracleWeb

Web Interface add-on to PoracleJS
GNU Affero General Public License v3.0
21 stars 33 forks source link

Loading main page (not logged in) generate unnecessary request to github/slows everything down #147

Open JabLuszko opened 1 year ago

JabLuszko commented 1 year ago

As titles states - loading main page as not logged in can be very slow - depending how fast GitHub answers 404 ;')

index.php includes header.php that includes functions.php that includes cache_handler.php and that one tries to load pokemonNames/itemNames. Only problem is both local and remote uses $locale as part of path and because $locale is empty it's testing non-existing files and then trying to download non-existed files (fe. fopen(https://raw.githubusercontent.com/WatWowMap/pogo-translations/master/static/englishRef/pokemon_.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found)

$locale is get via session $locale = @$_SESSION['locale']; and set in set_locale() https://github.com/bbdoc/PoracleWeb/blob/ed58d43b3617de6864faa088c8cfba01a198ee7e/include/functions.php#L316-L331 but only if $_SESSION['id'] exists - so not logged in users will have no locales at all.

Possible solutions: Set $_SESSION['locale'] for not logged in users as default (?) one? Force $locale as "en" if empty in cache_handler.php? Don't include cache_handler.php at all if user not logged in - is there anything need to render main login page?

Are there other parts of code depending on not set at all $_SESSION['locale']?

bbdoc commented 1 year ago

Just added a default session locale for all users, should solve it...