Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmetic changes inside php.ini #17282

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

diceydust
Copy link

This PR fixes #17266. It does some cosmetic changes to php.ini file (dev and prod). Currently inside php.ini there are lot of inconsistencies. This is an attempt to fix those. Main changes are:

  1. notation of PHP directives is standarized according to the following rules:
  • directive names are all-lowercase (which is why SMTP inside mail function is now smtp),
  • equals signs are surrounded by spaces,
  • string values are surrounded by double quotation marks (even if they are empty, i.e. url_rewriter.hosts = ""),
  • boolean values are written as On/Off,
  1. all section headers inside [] and ;; are written in all-lowercase convention,
  2. double spaces between sentences inside block comments are converted into single spaces.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure all the cosmetic changes make sense.

; https://php.net/fastcgi.impersonate
;fastcgi.impersonate = 1
;fastcgi.impersonate = "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a boolean INI setting or not? If not it may make sense to convert it to one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation this is string. Once it becomes bool I will fix this in the future PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation, especially for INI settings, is not the source of truth. The source code is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks for the input. I'm gonna look up all of the directives inside the source code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STD_PHP_INI_BOOLEAN("fastcgi.impersonate", "0", PHP_INI_SYSTEM, OnUpdateBool, impersonate, php_cgi_globals_struct, php_cgi_globals)

@@ -890,83 +893,83 @@ default_socket_timeout = 60
;auto_detect_line_endings = Off

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
; dynamic extensions ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get these changes, this is using Title Case for "section" titles, which seems adequate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I get the point. However in the curent master there is:

  • ; About this file ; (First letter of the first word is uppercase)
  • ; Quick Reference ; (First letter of each word is uppercase)
  • ; php.ini Options ; (First letter of the second word is uppercase – yes, I know php.ini is a file name)

What's the right convention then?

;;;;;;;;;;;;;;;;;;;

[CLI Server]
[cli server]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, these are "section" titles

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, in the current master we've got:

[intl]
[filter]
[mail function] – all lowercase
[Session] – first letter uppercase
[ODBC] – all caps
[MySQLi] but [mysqlnd]
[Pcre]
[bcmath]

Isn't it much simpler to go with lowercase all the way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are extension names so these are proper nouns. Having said that, some of them look incorrect.

Comment on lines -1124 to +1130
; Maximum number of links (persistent + non-persistent). -1 means no limit.
; Maximum number of links (persistent + non-persistent). -1 means no limit.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double space after a FULL STOP is a convention for English, it is not mandatory but I'm not sure I see the problem with it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the php.ini of the current master there are 169 situations where one sentence is followed by another one in the same line. In 44 cases they are separated by double space, in other 125 cases single space is used. Which is why I went for single space.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is worth standardizing. A lot of people (especially older generations) prefer double spaces. You're just going to start a debate on which way is more correct.

Comment on lines -1147 to +1152
;mysqli.allow_local_infile = On
;mysqli.allow_local_infile = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have more options than On/Off?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation this is int.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, documentation is not the source of truth.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STD_PHP_INI_BOOLEAN("mysqli.allow_local_infile", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_local_infile, zend_mysqli_globals, mysqli_globals)

Comment on lines -1155 to +1160
mysqli.allow_persistent = On
mysqli.allow_persistent = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Int again: documentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STD_PHP_INI_BOOLEAN("mysqli.allow_persistent", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_persistent, zend_mysqli_globals, mysqli_globals)

; Allow or prevent persistent links.
; https://php.net/pgsql.allow-persistent
pgsql.allow_persistent = On

; Detect broken persistent links always with pg_pconnect().
; Auto reset feature requires a little overheads.
; https://php.net/pgsql.auto-reset-persistent
pgsql.auto_reset_persistent = Off
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines 1256 to 1259
; Log PostgreSQL backends Notice message or not.
; Unless pgsql.ignore_notice=0, module cannot log notice message.
; Unless pgsql.ignore_notice = 0, module cannot log notice message.
; https://php.net/pgsql.log-notice
pgsql.log_notice = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean INI setting?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation this is int.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

@thg2k
Copy link
Contributor

thg2k commented Dec 27, 2024

I tried something similar few years ago in #7643 but was not successful. I still think a cleanup is due on these files but I don't like the changes in this particular PR.

@diceydust
Copy link
Author

I tried something similar few years ago in #7643 but was not successful. I still think a cleanup is due on these files but I don't like the changes in this particular PR.

Yeah, these things are difficult to standarize as – for instance – half of the people prefer double space between sentences and the other half – single space.

But the current situation is that there are multiple conventions used inside a single file, which I belive is even worse than having a bad standarization.

@kamil-tekiela
Copy link
Member

I would recommend splitting this into several PRs. There are several changes here that I would welcome but many that I disagree with. It would also be easier to review. For example, "equals signs are surrounded by spaces," could be a PR on its own.

@diceydust
Copy link
Author

I went through all all of the directives in the source code to check their data types. One thing I noticed is that I couldn't find declarations of the following ones:

  • url_rewriter.tags,
  • url_rewriter.hosts,
  • session.trans_sid_tags,
  • session.trans_sid_hosts.

Are they still part of PHP?

@devnexen
Copy link
Member

devnexen commented Dec 28, 2024

        STD_PHP_INI_ENTRY("session.trans_sid_tags", "a=href,area=href,frame=src,form=", PHP_INI_ALL, OnUpdateSessionTags, url_adapt_session_ex, php_basic_globals, basic_globals)
	STD_PHP_INI_ENTRY("session.trans_sid_hosts", "", PHP_INI_ALL, OnUpdateSessionHosts, url_adapt_session_hosts_ht, php_basic_globals, basic_globals)
	STD_PHP_INI_ENTRY("url_rewriter.tags", "form=", PHP_INI_ALL, OnUpdateOutputTags, url_adapt_session_ex, php_basic_globals, basic_globals)
	STD_PHP_INI_ENTRY("url_rewriter.hosts", "", PHP_INI_ALL, OnUpdateOutputHosts, url_adapt_session_hosts_ht, php_basic_globals, basic_globals)

I believe the two firsts are deprecated tough..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

php.ini directives – attempt to standarize notation
5 participants