Antelope-Valley-College / polr

GNU General Public License v2.0
24 stars 11 forks source link

Installation fails, and stats can't be viewed #2

Open timothevs opened 1 year ago

timothevs commented 1 year ago

Hey there, so very glad that you've taken over the reins. We too use Polr at our University, and I am looking to avoid moving to another tool till we absolutely must.

So, I was glad to see you have started updating it for PHP 8. I tried to give your version a shot on a clean Ubuntu 22.04 LTS server with PHP 8.1.2, and MySQL 8.0.

Composer installed dependencies correctly, and I used the wizard to setup the application on /setup. I didn't choose any SAML settings.

Expectedly the setup failed with a 500 error, although the tables were created. I manually inserted a user but I am unable to use the application the way it is intended.

For example trying to access http://<server>/admin/stats/<shorturl>

[2022-12-23 20:30:49] production.ERROR: Method App\Http\Controllers\LinkController::displayStats does not exist. {"exception":"[object] (BadMethodCallException(code: 0): Method App\\Http\\Controllers\\LinkController::displayStats does not exist. at /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:68)
[stacktrace]
#0 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Illuminate\\Routing\\Controller->__call()
#1 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction()
#2 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Route.php(260): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#3 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#4 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Router.php(798): Illuminate\\Routing\\Route->run()
#5 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#6 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#7 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#8 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#9 /var/www/html/polr/app/Http/Middleware/VerifyCsrfToken.php(30): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#10 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): App\\Http\\Middleware\\VerifyCsrfToken->handle()
#11 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#12 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#13 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#14 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#15 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
#16 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#17 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#18 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#19 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#20 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Router.php(799): Illuminate\\Pipeline\\Pipeline->then()
#22 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Router.php(776): Illuminate\\Routing\\Router->runRouteWithinStack()
#23 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Router.php(740): Illuminate\\Routing\\Router->runRoute()
#24 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Routing/Router.php(729): Illuminate\\Routing\\Router->dispatchToRoute()
#25 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(190): Illuminate\\Routing\\Router->dispatch()
#26 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#27 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#28 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#29 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#30 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#31 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#32 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#33 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#34 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#35 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#36 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#37 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
#39 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#41 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Pipeline\\Pipeline->then()
#43 /var/www/html/polr/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(134): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#44 /var/www/html/polr/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#45 {main}
"} 

Any help would be appreciated!

PineappleCat22 commented 1 year ago

Did you ever find anything out? any alternatives or fixes? I've been butting heads with Polr issues for the good part of an afternoon and now it's 1 am and I can't seem to find any more excuses to keep at this.

llbbl commented 1 year ago

This problem is the route is wrong. Don't have time for a PR, so you get an image.

CleanShot 2023-01-23 at 20 05 12

mwilmes-at-avc commented 1 year ago

Thanks. I have another reason to be back in the code, so I'll look at this too.

mwilmes-at-avc commented 1 year ago

Ok, so here's what I've found: The stats URL appears to be an AJAX callback for history about the use of a link. I haven't found that anywhere in the code and don't recall removing that. Calling the URL directly (when fixed) sends you back to the main page.

What I ran into with another project on Monday is that strict mode in MySQL may be causing you grief. I run MariaDB 10.5 with the Galera Cluster option, which I think had strict mode turned off when I created the database. MySQL strict mode requires all fields to be populated with data or have defaults, and I don't think this code meets those requirements. I will see if we can create a database upgrade/migration that will get this working out of the box with current MySQL.

mwilmes-at-avc commented 1 year ago

@timothevs I think this ready for you to try, and it also addresses a few of the internal problems I created from the upgrade but didn't catch in my testing because I didn't need those steps.

If you're willing to start a new server from scratch, please delete all the tables from your database. Install on your webserver using the following steps (assuming Apache or Nginx is ready):

git clone https://github.com/Antelope-Valley-College/polr.git --depth=1
cd polr
git fetch origin '+refs/heads/*:refs/remotes/origin/*'
git checkout origin/issue/2-setup-is-broken
rm composer.lock
composer.phar install --no-dev -o
chmod -R 755 .
chown -R www-data:www-data .

and continue with your install. This should deploy a database that can be used by the website; the schema that is currently in master does not define default values for all the cases needed, and this version of Laravel does not fill in the blanks (pun intended).

Please let me know how far you get. This still does not address the stats issue, but I figured being able to make links would be more important. For now, let's confirm that you're able to make, use, and manage links. I'll take a look back at the base code and see where the stats route was in the site.

Greetings, Mike

mwilmes-at-avc commented 1 year ago

I finally tracked down the stats link. It's only available in the admin pages when the advanced data analytics is enabled. This also requires a Maxmind DB license key to work correctly. If you supply the key at setup and your PHP does not have the memory limit set high enough, the setup will crash and not setup your DB completely; you won't have a starting user. I've posted a patch to this that ups the limit to 512M at runtime only if you are using the DB and it seems to fix this issue.

Internally we are really busy so it may be a while before anyone will review my code. until then, it's available in the branch I've attached to this ticket.

Greetings, Mike

mwilmes-at-avc commented 1 year ago

@PineappleCat22 this is also for you

mwilmes-at-avc commented 1 year ago

I'm at a point where I think this branch is stable. I've uploaded the dev scripts I wrote to spin up a pair of docker containers to run php 8.1 and mysql 8.0. Polr now launches and installs in its entirety. The stats link works correctly if you install a maxmind key. If I don't hear otherwise from anyone I will post this pull request in a couple weeks.