Page 1 of 1

FlatPress Github 1102 - PHP Warnings

Posted: Mon Dec 25, 2023 8:18 am
by laborix
Test environment:
Nginx 1.24, PHP 8.1 and Flatpress Github 1102

The installation runs without errors, but Flatpress do not run under Nginx with PrettyUrls.

Two PHP warnings appear each time a page is called up:

Code: Select all

PHP Warning:  Undefined variable $file_meta in .../fpgit1102/fp-plugins/seometataginfo/plugin.seometataginfo.php on line 458
PHP Deprecated:  file_exists(): Passing null to parameter #1 ($filename) of type string is deprecated in .../fpgit1102/fp-plugins/seometataginfo/plugin.seometataginfo.php on line 458

PHP Warning:  Undefined variable $config in .../fpgit1102/fp-plugins/calendar/plugin.calendar.php on line 20
PHP Warning:  Trying to access array offset on value of type null in ../fpgit1102/fp-plugins/calendar/plugin.calendar.php on line 20
For the PrettyUrls issue, a replacement solution should be provided somehow or PrettyUrls should be deactivated by default.
Nginx is now used more often than Apache (as of 11/2023). You should keep an eye on this.

regards

Re: FlatPress Github 1102 - PHP Warnings

Posted: Mon Dec 25, 2023 5:07 pm
by fraenkiman
Hello Laborix,

thank you very much for reporting.
I have opened two issues for this. #289, #290
Can you please provide me with an example of what an nginx.conf should look like based on the PrettyURLs -htaccess file?

With best regards
Frank

Re: FlatPress Github 1102 - PHP Warnings

Posted: Tue Dec 26, 2023 2:13 pm
by laborix
fraenkiman wrote: Mon Dec 25, 2023 5:07 pm... Can you please provide me with an example of what an nginx.conf should look like based on the PrettyURLs -htaccess file? ...
Hehe, not my beer :lol: since I've always used FlatPress without PrettyURLs ...

I've done some tests with FlatPress PrettyURLs and Nginx, but all hints from search engines, blogs and various other sources don't work with FlatPress.
In this context, you should also not forget that you have to make these changes directly in nginx.conf, so you have to be a web server administrator or have access to the Nginx configuration.

Re: FlatPress Github 1102 - PHP Warnings

Posted: Wed Dec 27, 2023 12:23 pm
by laborix
fraenkiman wrote: Mon Dec 25, 2023 5:07 pm... Can you please provide me with an example of what an nginx.conf should look like based on the PrettyURLs -htaccess file? ...
Tried some more solutions, also a few .htaccess Online converter, no success :(

@Arvid
Is it possible that FlatPress does not need .htaccess for the PrettyURL plugin?
That the Pretty URL sourcecode is the actual cause of the problem with Nginx?

Edit:
According to the server access protocol, the request is

Code: Select all

/fpgit1106/index.php/2023/12/27/welcome-to-flatpress/
and only the following is loaded in the web browser

Code: Select all

https://www.site.tld/fpgit1106/
Good question where the problem is located?

Edit 2:
Is it possible that at this point Smarty v4.x implements the "smarty->assign" for handling PrettyURLs differently?


regards

Re: FlatPress Github 1102 - PHP Warnings

Posted: Sat Dec 30, 2023 5:34 pm
by laborix
fraenkiman wrote: Mon Dec 25, 2023 5:07 pm... Can you please provide me with an example of what an nginx.conf should look like based on the PrettyURLs -htaccess file? ...
It seems that FlatPress with PrettyURLs does work on an Nginx server :)
Current test environment: FlatPress Github 1108, Nginx 1.24 and PHP 8.1.27

The solution is relatively simple if you have administrative access to the "nginx.conf" file and can add the following lines there:

Code: Select all

#
# see https://stackoverflow.com/questions/72521825/convert-htaccess-to-nginx-directives
location /fpgit1108 {
  if (!-e $request_filename) {
    rewrite ^/(.+)$ /fpgit1108/index.php?u=$1 last;
    break;
  }
} 
In FlatPress you have to activate one of the two modes in the PrettyURLs configuration:
(*) HTTP Get - Example: /?u=/2011/01/01/hello-world/
or
(*) Pretty - Example: /2011/01/01/hello-world/

The .htaccess file does not have to be created in an Nginx environment, it does not matter whether it is there or not.
At the moment I don't understand FlatPress PrettyURLs or the rewrite on the Nginx server :? It should definitely be tested on a live system online ...

Re: FlatPress Github 1102 - PHP Warnings

Posted: Sun Dec 31, 2023 1:04 am
by fraenkiman
Hello Laborix,
laborix wrote: Sat Dec 30, 2023 5:34 pm It seems that FlatPress with PrettyURLs does work on an Nginx server :)
that's great news. I'll add your findings to the wiki.

Many thanks for testing
Frank

Re: FlatPress Github 1102 - PHP Warnings

Posted: Sat Jan 20, 2024 9:00 pm
by Arvid
Guys, thank you very much for testing and debugging this. I for myself have no experiences with nginx whatsoever :(
To answer laborix' question, URL rewriting is the very core of the PrettyURLs plugin. It completely depends on some kind of rewriting config on the web server.
Glad you found a way to solve this for nginx, and thanks for adding to the wiki. Now i wait for a productive nginx user who can confirm this is working properly.

All the best,
Arvid