cuonOne reshared this.

[l] Franziska "Clankriminalität" Giffey stellt sich also genau so schlau wie angenommen raus, fällt auf einen Enkeltrick rein.

Wobei ich mir gar nicht sicher bin, ob sie wirklich reingefallen ist, oder ob ihr das einfach nur wirklich scheißegal ist, mit wem sie gesehen wird, solange sie neben dem wichtiger aussieht als sie ist.


3 word job challenge

#cartoon by Michael #Panteli https://conclave-brighton.co.uk/product-category/artist/mpa?v=7516fd43adaa

2 people reshared this
Pascal diaspora
it kinda should :)
Pascal diaspora
how specific it shall be..

i throw balls.
i perform movement.
i do art.

So schnell kann es gehen: Am Ort noch gestorben mit gerade mal 24 Jahren

So schnell kann es mal gehen, auch wenn es 1000x gut oder sehr knapp ausgeht. Einmal zu knapp und du stirbst. Viele wahre Worte gesprochen:


Bitte auch kein #Gaffen , der beste Gaffer ist der schlechteste Helfer.
Und nie und nimmer den #Sekundenschlaf unterschaetzen:

Es kann auch mal nicht dieser asozialer #Betrug an der #Landstrasse sein, sondern echt: Kein Bezin mehr und bietet Geld an, damit der Einsender es ihm davon kaufen kann:

PS: Letzter Beitrag!

Why I don't like/use PHP's empty() function

PHP has a function called empty() which can only return a boolean value, which is good at this point. The purpose of the function is to check if a variable "is empty" ...

You can check out it's documentation or try this example to see what is all considered as "empty".
echo 'empty(true):'       . (empty(true)       ? 'true': 'false') . PHP_EOL;
echo 'empty(false):'      . (empty(false)      ? 'true': 'false') . PHP_EOL;
echo 'empty(0):'          . (empty(0)          ? 'true': 'false') . PHP_EOL;
echo 'empty((float)0.0):' . (empty((float)0.0) ? 'true': 'false') . PHP_EOL;
echo 'empty(null):'       . (empty(null)       ? 'true': 'false') . PHP_EOL;
echo 'empty():'           . (empty('')         ? 'true': 'false') . PHP_EOL;
echo 'empty("foo"):'      . (empty('foo')      ? 'true': 'false') . PHP_EOL;
echo 'empty(object):'     . (empty(new stdclass()) ? 'true': 'false') . PHP_EOL;

With 7.4.21 I'm getting this result:

And hopefully with other versions of #PHP you get the same result. But if not, then there is the problem. Users can have a variety of versions installed, even those being marked as End-Of-Life (which as a software developer you should never support, get your system updated, lazy arse!!!).

So do you want ...
1) Your coder relies on a PHP function that has a change of behavior (other returned result than before updating PHP)?
2) Don't/Can't update PHP and get stuck with a EOL version?
3) Or maybe rewrite it in a way that when an incompatible update happens you only have to change a little bit?

Sure empty() is maybe not changing so fast in the near future, but who knows? Surely you and me don't have a magic orb at home where you can see it coming ... LOL

For the last option, I had introduced DBA::isResult() which does this exactly for you. It keeps your code easily upgradeable because you might only have to change that method (if properly used everywhere). But there is a drawback in Friendica's code:

- If a boolean is present in $array (mixed type parameter of it), it simply returns it (even when it is true, so your code "thinks" that the record is found ...
- On successful retrieval of the record either an object or array can be present in $array. So they both need to be checked individually.

What I found troubling (confusing) here is that why so many different types can be returned from the DAL (the class Database/Database|DBA is some kind of DAL) and not always a single result class, e.g. QueryResult which contains the whole result, how many records have been found or being affected and so on.

This is a WAY much cleaner approach and you are more object-oriented and not lesser. If it was me, I would rewrite the entire code of #Friendica around this issue towards that class.

And if it was me, I would make sure that (no matter how important the table is) method invocations are correct, means e.g. no null for an id column or valid id number (you can always call DBA::exists() before!). And if this causes to much redundant queries, you can always cache the result and just return the cache instead.

Sure this increases memory footprint, that's the deal you have to make: More cache or more SQL queries.
For the said "Result class" I recommend at least these values:
- SQL query itself
- affected rows
- number of found rows (SELECT)
- error code/message
- result array (or structures for a more SPL approach, see this Stackoverflow entry)
- any other meta data around the result

Just to give you an idea to go to. :-)
What I have seen here in #Friendica code is that returned values from DBA::select*() methods is often NOT checked with DBA::isResult() but with empty() or just e.g. if ($contact).

Later posts Earlier posts