- moved constants GRAVITY_* from boot.php to Friendica\Model\Item
- also rewrote some array initialization:
From:
````
<?php
$arr = [];
$arr['foo'] = "FOO";
````
To:
````
<?php
$arr['foo'] = "FOO";
````
- added a few type-hints
- new "Definition" classes vor DB and Views
- new "Writer" classes to create SQL definitions for DB and Views
- DBStructure & View are responsible to execute DB-querys
- as @MrPetovan pointed out, $actor can be NULL earlier and used later as NULL
- added some missing type-hints
- added missing documentation
- the added @TODO points out to avoid true|false|null for a boolean
- changed back to 'return false;' as other methods heavily rely on false instead
of an empty array as pointed out by @heluecht@pirati.ca
- $fetched_contact should be initialized as an empty array, let's not make this
code more crazier than it already is (see APContact::getByURL())
1) The first change prevents "expensive" code in HTML::toBBcode() to be executed
just for an empty string which makes no sense.
2) The above change was maybe flawed as $apcontact['about'] would have never
been created, not even empty which could have side effects
Thanks to @annando to make me rethink this part of code.
- added more checked type-hints as they prevent bad method invocations
- fixed TypeError for HTML::toBBCode() invocations with NULL as first (wrong)
argument, thanks to @tobias@social.diekershoff.de pointing this out.
Similar to PR #10499, Mastodon apparently has some counting flaws and
can present a negative status count for a user, causing Friendica to
fail (at least under PHP 8) with:
[20-Jul-2021 16:35:18 UTC] PHP Fatal error: Uncaught PDOException: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'statuses_count' at row 1 in /home/friendicadev/friendica/src/Database/Database.php:560
Stack trace:
thrown in /home/friendicadev/friendica/src/Database/Database.php on line 560
This change prevents values lower than 0 from being assigned to
statuses_count.
Please see
https://github.com/friendica/friendica/issues/9498#issuecomment-818894106
and related discussion regarding this - it appears it's possible for AP
users, maybe just Mastodon users, to have a negative followers count.
This causes fatal errors in Friendica, so I think we should sanitize
this input.