FlatPress Github 1102 - PHP Warnings

This is the right place to report general bugs, make suggestions or ask for help.
Post Reply
laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

FlatPress Github 1102 - PHP Warnings

Post by laborix » Mon Dec 25, 2023 8:18 am

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

User avatar
fraenkiman
Posts: 223
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: FlatPress Github 1102 - PHP Warnings

Post by fraenkiman » Mon Dec 25, 2023 5:07 pm

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
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

Re: FlatPress Github 1102 - PHP Warnings

Post by laborix » Tue Dec 26, 2023 2:13 pm

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.

laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

Re: FlatPress Github 1102 - PHP Warnings

Post by laborix » Wed Dec 27, 2023 12:23 pm

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

laborix
Posts: 118
Joined: Sat Feb 16, 2019 3:51 pm

Re: FlatPress Github 1102 - PHP Warnings

Post by laborix » Sat Dec 30, 2023 5:34 pm

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 ...

User avatar
fraenkiman
Posts: 223
Joined: Thu Feb 03, 2022 7:25 pm
Location: Berlin, Germany
Contact:

Re: FlatPress Github 1102 - PHP Warnings

Post by fraenkiman » Sun Dec 31, 2023 1:04 am

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
:pencil: You are strong in PHP and Java Script? :point_right: Then help us to improve FlatPress. :point_left:

:exploding_head: Looking for ideas, templates, examples and answers to frequently asked questions?
:bulb: You'll find it here.

My :de: FlatPress-Blog: https://frank-web.dedyn.io

User avatar
Arvid
FlatPress Coder
Posts: 576
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: FlatPress Github 1102 - PHP Warnings

Post by Arvid » Sat Jan 20, 2024 9:00 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests