f.haeder.net

Hacking friendica code with trailing/leading white-spaces

When editing #Friendica code, I use a local commit hook, finding leading and trailing white-spaces. The hook itself is GIT's default pre-commit hook plus a few extra lines:

# Find bad scripts
./util/typo.php

# PHPUnit
if [ -x ./vendor/bin/phpunit ]
then
./vendor/bin/phpunit || exit 255
fi


So, please don't wonder when I touch "the whole file". Then I have just changed DOS -> Uni* line-break (CRLF to LF) as it was being detected as trailing white-space characters.
#Friendica code friendica white-space
js/country.js is indented with space and tabs, I fix that to tabs now. Plus I have fixed some JS warnings due to missing semicolon.
I would also recommend to start with #cache-busting which means, adding version numbers to JS/CSS files (and URLs).
Browsers (even #Firefox #Quantum) tend not to download CSS/JS when they have downloaded it already. This forces your users to press CTRL+F5 (under Firefox at least). The fix is to include a version number in the URL and always increment it when you change something.

Examples: /js/main.js?v=1.0.0 or /css/default.css?v=1.0.0

Static files normally ignore parameters so this is safe to do so. When you change that file, just increment the last patch number until you want it (I prefer to increment from 1.0.9 to 1.1.0 but that is up to the community (you should come up with a versioning convention). #cache-busting
Na, #quantum should be the correct hashtag. #bug

Fatal error: Call to a member function escape() on null

@Friendica Developers I get the following error after I updated to latest develop code:

Fatal error: Uncaught Error: Call to a member function escape() on null in /../friendica/include/dba.php on line 1104
Error: Call to a member function escape() on null in /../friendica/include/dba.php on line 1104

Call Stack:
 0.0036 371800 1. {main}() /../friendica/include/dbstructure.php:0
 0.0533 938728 2. dbstructure_run(array(2), long) /../friendica/include/dbstructure.php:1827
 0.0651 1037352 3. update_structure(true, true, ???, ???) /../friendica/include/dbstructure.php:1783
 0.0654 1038120 4. Friendica\Core\Config::set(string(6), string(11), long) /../friendica/include/dbstructure.php:207
 0.0655 1040408 5. dba::update(string(6), array(1), array(2), true) /../friendica/src/Core/Config.php:167

Variables in local scope (#5):
 $array_element = *uninitialized*
 $array_key = *uninitialized*
 $condition = array ('cat' => 'system', 'k' => 'maintenance')
 $condition_string = *uninitialized*
 $content = *uninitialized*
 $do_insert = *uninitialized*
 $do_update = *uninitialized*
 $fieldname = *uninitialized*
 $fields = array ('v' => '1')
 $old_fields = TRUE
 $params = *uninitialized*
 $params1 = *uninitialized*
 $params2 = *uninitialized*
 $sql = *uninitialized*
 $table = 'config'
 $values = *uninitialized*


Any idea how to fix this? Did I miss something to update on my .htconfig.php file?
@Friendica Developers code fatal-error friendica
I cannot reproduce, but have created some possible workaround: https://github.com/friendica/friendica/pull/3776
That error seem to be fixed but now only CREATE statements are being processed, nothing else. I have fixed all my parser errors which were caused by missing curly braces.
Added a late code-review pointing out some stuff that should be rewritten:

"dba" is now static by annando · Pull Request #3778 · friendica/friendica

Sorry, no progress here. Maybe next weekend, as I have 3 additional more days no work! #atwork
Re-tested it. And seems to be fixed. Need more testing at home before I update this instance.
hoergen GNU Social
@roland @heluecht btw danke für den Screenshot vom Psytrance Forum ;)

Coding convention rewrites 2-5-2 of 2-14-2

PR request 3469 is out which contains changes towards a Friendica-wide coding-convention. As requested earlier, I have splitted my 119 (!) files large PR into several small to make it easier for the reviewers (not to review tons of changes but small chunks then).

So as you (dear users) can see, #Friendica is being rewritten in many directions. No new stuff but more clear code where I hope to have later an even more clear code (better understandable by humans, a computer can read any badly formatted code as long as it is valid).

@Friendica Developers

Edit: Here is the link to the PR: https://github.com/friendica/friendica/pull/3469
#Friendica @Friendica Developers code coding-convention friendica php
PR 3473 is up: https://github.com/friendica/friendica/pull/3473 split 6 of 14 of 2nd wave.
Added some changes to include/text.php, in the start of the PR I just rebased the branch towards upstream/develop.
3588 is out and waits for a CR (with fixes).
I ran php util/typo.php again and it failed ????
:D I hope we can also solve that issue with ./vendor/ directory then. Because looked globally (PHP community) most projects using composer install will ignore it because it is considered as "build" (locally recreated) directory.
What is the issue with vendor?
It should be ignored entirely and not committed as it will be rebuild by composer install. If that is to hard/impossible for some users, then they should download pre-built "binary" packages (including vendor).
This is the end goal, however it is a gradual process. For now I believe we don't have a good enough routine to offer a pre-built archive of the latest version of Friendica, also not all the people using the dev branch are aware about the extra steps required to build the dependencies. I'm voluntarily not in the loop anymore so I couldn't give you a timetable, but I believe it is on track to remove vendor from version control eventually.
Sorry, had not continued on it. Maybe when time allows it. And then I have to rebase a lot.
newer older