Commit Graph

6101 Commits

Author SHA1 Message Date
Alexei Sorokin
ebfc248ff6 Various fixes
Fix OAuth and Realtime issues introduced in 9a515b9234

[DATABASE] Fix an empty default value mistake introduced in
fde929b151

[DATABASE][PostgreSQL] Avoid use of pg_constraint.consrc, which was removed in
PostgreSQL 12.

[DATABASE][MariaDB] Fix a typo introduced in aed2344bd4

[DAEMON] Wrap an assignment inside "switch":
a follow-up to adc689cb15
2021-07-16 19:44:41 +01:00
Alexei Sorokin
8181b28441 Clear out potential duplicates when semi-joining a union
Using a left outer join as a semi-join is not a valid approach.
Can still be used for an anti-semi-join.
2021-07-16 19:44:41 +01:00
Alexei Sorokin
318d2cb6ca Set the character set before making a connection
Ideally the character set should be set with the connection, and so this is
exactly what's being done now.

And now the character set code is attempted to be generalised.
2021-07-16 19:44:41 +01:00
SENOO, Ken
0b4a49d262 Change required MySQL database character set variable
Changing `character_set_server` requires root permissions and rebooting
the server.

Which is impossible on shared web hosting services.

So use `character_set_database`. This variable can be changed with
user permissions using `ALTER DATABASE`.
2021-07-16 19:44:41 +01:00
Alexei Sorokin
a0f72fe5c6 Avoid ordering just by a timestamp
Try to also employ an id when possible.
Involves reworking some of the indices.
2021-07-16 19:44:41 +01:00
Alexei Sorokin
ae4f3176b1 Remove "magic quotes" code and avoid wrong order implode
"Magic quotes" were removed in PHP 5.4, no need to mitigate it anymore.

Avoid implode() with the join()-like order of arguments which was deprecated
since PHP 7.4 and implicitly since PHP 5.3.
Also avoid implode() with an implicit separator for stylistic reasons.

mktime() with no arguments has been deprecated since PHP 5.1.
2021-07-16 19:44:41 +01:00
Alexei Sorokin
22f6d3ce14 [UTIL] Sanitise instead of validate in common_copy_args()
And remove common_validate_utf8() which is now unused.
2021-07-16 19:44:41 +01:00
Alexei Sorokin
9e94b7f145 [DATABASE] Switch from PEAR DB to MDB2 2021-07-16 19:44:41 +01:00
Alexei Sorokin
160b6ccd94 Fix "Implement a class for automatic temporary file handling"
TemporaryFile::commit throws instead of returning a bool.
2021-07-16 19:44:41 +01:00
Alexei Sorokin
7e1091eb8c [DATABASE] Make sure the session always uses UTF-8 and UTC 2021-07-16 19:44:41 +01:00
Alexei Sorokin
4e02cb437a [API] Fix /api/statuses/update reporting a failure 2021-07-16 19:44:41 +01:00
Alexei Sorokin
9efbef720d Avoid use of assignments bare inside statements
Either use them in a subroutine call or put parentheses around the assignment.
2021-07-16 19:44:41 +01:00
Alexei Sorokin
7fa4d56f05 Implement a class for automatic temporary file handling
And adopt it all over the code.
2021-07-16 19:44:41 +01:00
Diogo Cordeiro
82f1fc7ca2 [ActivityPub] Implement Failed Queue 2021-07-16 19:44:41 +01:00
Diogo Cordeiro
c834d27dd6 [TheFreeNetwork] Do not allow lower priority protocols to handle remote actors already handled by the higher ones 2021-07-16 19:44:41 +01:00
Alexei Sorokin
681aa5b326 [NOTICES] Condition pushdown in the subquery in inboxnoticestream
This improves performance on PostgreSQL.
2021-07-16 19:44:40 +01:00
Alexei Sorokin
47c9bea46f [DATABASE][PostgreSQL] Ignore index prefix length 2021-07-16 19:44:40 +01:00
Alexei Sorokin
1f3edd8fdf Rename the mysql_foreign_keys option to foreign_keys
And apply it universally.
2021-07-16 19:44:40 +01:00
Alexei Sorokin
3075cffcd7 [DATABASE] Change collation handling
Before now table definitions could define collations only for MariaDB using the
MariaDB's collation names directly.
Now instead definitions get a slightly more abstract collation name syntax, but
only supporting the collations utf8mb4_bin and utf8mb4_unicode_(cs|ci) (wrapped
as utf8_bin, utf8_general_(cs|ci)), because those are the ones that have
practical use for GNU social.

Which also means that on MariaDB the formerly used utf8mb4_general_(cs|ci) have
been superseded by utf8mb4_unicode_(cs|ci), as they are the more modern
replacement.

Introduce collation support on PostgreSQL which results in use of the C (POSIX)
collation as utf8_bin and the und-x-icu collation as utf8_general_cs.
utf8_general_ci is also mapped to und-x-icu, which makes it case-sensitive,
unfortunately.
2021-07-16 19:44:40 +01:00
Alexei Sorokin
86826a1a68 [SEARCH][PostgreSQL] Make LIKE search case-insensitive 2021-07-16 19:44:40 +01:00
Alexei Sorokin
c11629035b [SEARCH][MariaDB] Change user-facing fulltext search syntax
Now analogous to the simple and safe PostgreSQL's websearch_to_tsquery syntax.
MariaDB's full-text boolean search queries will fail on input such as "@user"
(unquoted) which is particularly noticeable to the user.
2021-07-16 19:44:40 +01:00
Alexei Sorokin
2d6e4e3912 [SEARCH] Exclude message scope 2021-07-16 19:44:40 +01:00
tenma
4a50579ef1 [MEDIA] Add WebP support
WebP format is now the default image format for anything that
is not an animated GIF. Image Intervention doesn't support
animated WebPs so we don't convert animated GIFs.

ImageFile:
MediaFile:
default:
- Add WebP support
2021-07-16 19:44:40 +01:00
Alexei Sorokin
01093e3583 [DATABASE][MariaDB] Always use LONGBLOB for "blob"
"blob" is practically used with the expectation of unlimited length, which is
true with PostgreSQL's bytea, but not with MariaDB's BLOB, which is limited to
64KiB.
So instead use LONGBLOB, which has a maximum of 4GiB, effectively unlimited.
2021-07-16 19:44:40 +01:00
Alexei Sorokin
03e69e8c31 [DATABASE] Fix remaining misuses of SQL's GROUP BY 2021-07-16 19:44:40 +01:00
Alexei Sorokin
e8f5e34202 Revert "[CORE] Avoid the old "reply" relation in inboxnoticestream"
It is needed for mentions.
2021-07-16 19:44:40 +01:00
Alexei Sorokin
2de195d20c [NOTICES] Restore FullNoticeStream
But only allow a select number of verbs.
This is to display optional subscription notices.
2021-07-16 19:44:40 +01:00
Alexei Sorokin
6d203d42e9 [DATABASE] Enable fulltext search by default
Also rename fulltext indices to more fitting names
and move the check from classes into database/schema.php
2021-07-16 19:44:40 +01:00
Alexei Sorokin
974404bcfd [DATABASE][PostgreSQL] Add fulltext search support 2021-07-16 19:44:40 +01:00
Alexei Sorokin
8c939b70cc [UTIL] Fix up common_ensure_session()
Give priority to cookies over GET.

Make sure session ids have only expected characters
(PHP file session handler's limitation).

Replace a mostly useless log warning with a debug message.
2021-07-16 19:44:38 +01:00
Alexei Sorokin
881ea12f3f [EXCEPTIONS] Inherit the Previous Exception parameter 2021-07-16 19:44:38 +01:00
Diogo Cordeiro
4c92cc967b [MEDIA] fromUrl now supports using original file name 2021-07-16 19:44:38 +01:00
Alexei Sorokin
1667d727b4 Set HTTP status codes with http_​response_​code() 2021-07-16 19:44:38 +01:00
Diogo Cordeiro
10f0a15614 [VersionBump] 2.0.0alpha0
Ran composer update and locale updater
2021-07-16 19:44:38 +01:00
Diogo Cordeiro
2a863ba746 [MODULES] Make default loading attributes available in global config 2021-07-16 19:44:38 +01:00
Alexei Sorokin
caac2cea44 [SCHEMA] Better DBMS information fetching
On PostgreSQL:
  - Parse defaults for strings and booleans properly.
  - Parse the "serial" definition type properly.
  - Get information on the "enum" definition type.
  - Re-work getting information about keys/indices.

On MariaDB:
  - Get information about lengths in indices.
  - Get foreign key information separately from the rest as they can have
    colliding names.
2021-07-16 19:44:38 +01:00
Alexei Sorokin
573cd7d450 [SCHEMA] Fix a few mistakes 2021-07-16 19:44:38 +01:00
Alexei Sorokin
bee3dea9c2 [DATABASE] Add explicit indices for all foreign keys
This adds a requirement for all definitions that have foreign keys to also
require indices for all source (local) attributes mentioned in foreign keys.

MariaDB/MySQL creates indices for source attributes automatically, so this
serves as a way to get rid of those automatic indices and create clean explicit
ones instead.

In PostgreSQL, most of the time, indices on the source are necessary to
decrease performance penalty of foreign keys (like in MariaDB), but they aren't
created automatically, so this serves to remove that difference between
PostgreSQL and MariaDB.
2021-07-16 19:44:38 +01:00
Alexei Sorokin
665e4574da [DATABASE] Fix index identifiers and clean up redundant ones 2021-07-16 19:44:38 +01:00
Alexei Sorokin
b1b1d2af93 [DATABASE] Update "modified" in Managed_DataObject instead of a DBMS trigger
Instead of relying on the MariaDB's ON UPDATE CURRENT_TIMESTAMP trigger update
"modified" attributes in Managed_DataObject. Every raw query that needs
adjusting is adjusted, as they won't update "modified" automatically anymore.

The main goal behind this change is to fix "modified" updates on PostgreSQL.
2021-07-16 19:44:37 +01:00
Diogo Cordeiro
c85feeaa1f [AuthCrypt] Update README and fix formatting 2021-07-16 19:44:37 +01:00
Diogo Cordeiro
360fc0262b [MODULES] Make settings great again
Plugin main class doesn't use this construct despite extending this class.
2021-07-16 19:44:37 +01:00
Alexei Sorokin
182f94cf6f [DATABASE][MariaDB] Fix index changes with foreign keys enabled 2021-07-16 19:44:37 +01:00
Alexei Sorokin
9ec1b667c0 [DATABASE][Schema_version] Change the hashing algorithm to SHA3-512 2021-07-16 19:44:37 +01:00
Alexei Sorokin
65b6a924bd [DATABASE] Make unprefixed schema.php a bit more DBMS-neutral 2021-07-16 19:44:37 +01:00
Diogo Cordeiro
2894eb9ed2 [MEDIA] Fix headers when using x-static-delivery 2021-07-16 19:44:37 +01:00
Alexei Sorokin
e902a9bdfc [DATABASE] Check SQL boolean values with "IS TRUE"
This way UNKNOWN (NULL) explicitly turns to FALSE when three-valued logic is
reduced to binary.
In pgsqlschema, however, use "IS FALSE" as boolean attributes in pg_index are
non-nullable, there is no outer join and there's no clear preference for NULL
reduction.

Over-complicated constructions in TagCloud queries have been simplified, which
should not affect their performance.

Additionally, in TagCloud's lib/subscriptionspeopleselftagcloudsection.php
a typing mistake in an equi-join of "profile_tag" and "profile_list" on
"tagger" was fixed.
That regression was introduced in f446db8e2a
2021-07-16 19:44:37 +01:00
Hugo Sales
58af4799ee [NOTICE][UI] Fix bug: Option to message "Everyone at site" when using private instance 2021-07-16 19:44:37 +01:00
Alexei Sorokin
9ba9006014 [CORE] Avoid materialisation in the TaggedProfileNoticeStream query
This is analogous to c862589dcf
2021-07-16 19:44:37 +01:00
Alexei Sorokin
cbb83a9752 [NOTICES] Revert "We want the profile stream to be as raw as possible!"
There are only three possible visible notice verbs: POST, SHARE and DELETE.
What including all verbs does is it makes limiting (FETCH FIRST) unreliable as
the query will fetch invisible stuff (like favourites) and count it in, but
nothing will be displayed.
NoticeStream only allows POST and SHARE, so this effectively removes tombstones
from the profile page like in 78a111b57d
2021-07-16 19:44:37 +01:00