friendica / friendica

Friendica Communications Platform
https://friendi.ca
GNU Affero General Public License v3.0
1.44k stars 341 forks source link

[2021.03] PHP Fatal Errors #9747

Closed MrPetovan closed 3 years ago

MrPetovan commented 3 years ago

Please report here any PHP Fatal error message obtained running the 2021.01 stable or 2021.03-dev versions.

Closes #9250

AlfredSK commented 3 years ago

Let's get started again. ;-)

2021.01 stable, PHP 7.4

Uncaught TypeError: Argument 4 passed to Friendica\Content\Text\BBCode::getShareOpeningTag() must be of the type string, null given, called in .../src/Protocol/Diaspora.php on line 2464 and defined in .../src/Content/Text/BBCode.php:2201
Stack trace:
#0 .../src/Protocol/Diaspora.php(2464): Friendica\Content\Text\BBCode::getShareOpeningTag()
#1 .../src/Protocol/Diaspora.php(570): Friendica\Protocol\Diaspora::receiveReshare()
#2 .../src/Protocol/Diaspora.php(473): Friendica\Protocol\Diaspora::dispatch()
#3 .../src/Module/Diaspora/Receive.php(86): Friendica\Protocol\Diaspora::dispatchPublic()
#4 .../src/Module/Diaspora/Receive.php(60): Friendica\Module\Diaspora\Receive::receivePublic()
#5 [internal function]: Friendica\Module\Diaspora\Receive::post()
#6 .../src/App/Module.php(281): call_user_func()
#7 .../src/App.php(557): Friendica\App\Module- in .../src/Content/Text/BBCode.php on line 2201

Addressed in #9780

tobiasd commented 3 years ago
Uncaught Error: Call to undefined method Friendica\Model\GServer::setProtocol() in /src/Worker/APDelivery.php:104
Stack trace:
#0 [internal function]: Friendica\Worker\APDelivery::execute()
#1 /src/Core/Worker.php(454): call_user_func_array()
#2 /src/Core/Worker.php(344): Friendica\Core\Worker::execFunction()
#3 /src/Core/Worker.php(111): Friendica\Core\Worker::execute()
#4 /bin/worker.php(83): Friendica\Core\Worker::processQueue()
#5 {main}
  thrown in /src/Worker/APDelivery.php on line 104

Self-addressed.

MrPetovan commented 3 years ago

Please pull develop again, I'm guessing this has to do with @annando 's work being spread between multiple PRs that got merged one by one instead of all at once which wouldn't have caused this error.

annando commented 3 years ago

@MrPetovan Yeah, in one of the PRs I forgot to push a commit that was then part of the following PR.

Extarys commented 3 years ago

Freshly cloned the repo and installed friendica (new database and same way of installing as a few days ago when I started working on the web UI).

After the installation process, all pages return 500 errors.

I get:

2021/01/21 10:35:10 [error] 1421501#1421501: *15428 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Object of class Friendica\Core\L10n could not be converted to string in /media/FastHDD/srv/http/friendica/src/Core/Update.php:79
Stack trace:
#0 /media/FastHDD/srv/http/friendica/src/App.php(506): Friendica\Core\Update::check()
#1 /media/FastHDD/srv/http/friendica/index.php(42): Friendica\App->runFrontend()
#2 {main}
  thrown in /media/FastHDD/srv/http/friendica/src/Core/Update.php on line 79" while reading response header from upstream, client: 127.0.0.1, server: friendica.local, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: ">

2021/01/21 10:31:09 [error] 1421501#1421501: *15428 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Object of class Friendica\Core\L10n could not be converted to string in /media/FastHDD/srv/http/friendica/src/Core/Update.php:79
Stack trace:
#0 /media/FastHDD/srv/http/friendica/src/App.php(506): Friendica\Core\Update::check()
#1 /media/FastHDD/srv/http/friendica/index.php(42): Friendica\App->runFrontend()
#2 {main}
  thrown in /media/FastHDD/srv/http/friendica/src/Core/Update.php on line 79" while reading response header from upstream, client: 127.0.0.1, server: friendica.local, request: "GET /ping?format=json&_=1611242869657 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "f>

Addressed in #9841

AlfredSK commented 3 years ago

2021.03-dev PHP 7.4

Uncaught Error: Call to undefined method Friendica\Model\Item::selectFirstThreadForUser() in .../src/Module/Item/Ignore.php:53
Stack trace:
#0 [internal function]: Friendica\Module\Item\Ignore::rawContent()
#1 .../src/App/Module.php(289): call_user_func()
#2 .../src/App.php(552): Friendica\App\Module->run()
#3 .../index.php(42): Friendica\App->runFrontend()
#4 {main}
  thrown in .../src/Module/Item/Ignore.php on line 53

I guess Item::selectFirstThreadForUser() has to be Post::selectFirstThreadForUser() instead.

Addressed in #9851

sunchaserinfo commented 3 years ago
PHP Fatal error:  Unparenthesized `a ? b : c ? d : e` is not supported.
Use either `(a ? b : c) ? d : e` or `a ? b : (c ? d : e)`
in .../view/lang/ru/strings.php on line 6

Addressed in #9882

MrPetovan commented 3 years ago

Thank you for the report, unfortunately we do not support PHP 8 at the moment. We are aware of this specific issue in the translation files but we do not have a good way to fix it yet.

sunchaserinfo commented 3 years ago

@MrPetovan that's PHP 7.4.14, not 8

MrPetovan commented 3 years ago

Thank you for the added detail, I knew this syntax was considered as deprecated in PHP 7.4 but I didn't expect it to throw a Fatal Error before PHP 8. I'm not sure if this is just oversight on my part or a specific behavior of PHP governed by a configuration value.

The issue with this specific error is that these strings.php files are generated automatically from the PO file format which still accepts unparenthesized ternary operators. So far we've copied the plural condition as is successfully, but I have no clear idea how to automatically transpose it to the format PHP now expects.

As a workaround you can edit the file(s) manually to lift the error, we may end up updating them manually if we don't find an automatic solution.

realkinetix commented 3 years ago

2021.01 php 7.4.14

[28-Jan-2021 21:26:37 UTC] PHP Fatal error:  Uncaught TypeError: Argument 2 passed to Friendica\Worker\APDelivery::execute() must be of the type int, string given in /home/friendica/friendica/src/Worker/APDelivery.php:45
Stack trace:
#0 [internal function]: Friendica\Worker\APDelivery::execute()
#1 /home/friendica/friendica/src/Core/Worker.php(444): call_user_func_array()
#2 /home/friendica/friendica/src/Core/Worker.php(334): Friendica\Core\Worker::execFunction()
#3 /home/friendica/friendica/src/Core/Worker.php(105): Friendica\Core\Worker::execute()
#4 /home/friendica/friendica/bin/worker.php(81): Friendica\Core\Worker::processQueue()
#5 {main}
  thrown in /home/friendica/friendica/src/Worker/APDelivery.php on line 45

These errors are causing some pretty big issues with my worker queue, so considering the discussion around develop's stability, I switched to 2020.03-dev. Still throwing these like crazy.

realkinetix commented 3 years ago

2021.01 php 7.4.14

[28-Jan-2021 21:26:36 UTC] PHP Fatal error:  Uncaught Friendica\Network\HTTPException\InternalServerErrorException: Item wasn't stored. in /home/friendica/friendica/mod/item.php:727
Stack trace:
#0 /home/friendica/friendica/src/Model/Post/Delayed.php(128): item_post()
#1 /home/friendica/friendica/src/Worker/DelayedPublish.php(42): Friendica\Model\Post\Delayed::publish()
#2 [internal function]: Friendica\Worker\DelayedPublish::execute()
#3 /home/friendica/friendica/src/Core/Worker.php(444): call_user_func_array()
#4 /home/friendica/friendica/src/Core/Worker.php(334): Friendica\Core\Worker::execFunction()
#5 /home/friendica/friendica/src/Core/Worker.php(105): Friendica\Core\Worker::execute()
#6 /home/friendica/friendica/bin/worker.php(81): Friendica\Core\Worker::processQueue()
#7 {main}
  thrown in /home/friendica/friendica/mod/item.php on line 727
sunchaserinfo commented 3 years ago

@MrPetovan It seems you try to use C-code for these translations that work incorrectly because of the wrong ternary association order in PHP, basically that's why they were forbidden

for example for Russian expression

n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2

you get 2 for 21 while the correct result is 0 so you need to add parser even for earlier PHP's

Here is my quick and dirty solution:

<?php

$cond = 'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2';
//$cond = '3';

$cond = str_replace('n', '$n', $cond);

function parse($string, &$node = [])
{
    $q = strpos($string, '?');
    $s = strpos($string, ':');

    if ($q === false && $s === false) {
        $node = $string;
        return;
    }

    if ($q === false || $s < $q) {
        [$then, $else] = explode(':', $string, 2);
        $node['then'] = $then;
        parse($else, $parsedElse);
        $node['else'] = $parsedElse;
    } else {
        [$if, $thenelse] = explode('?', $string, 2);
        $node['if'] = $if;
        parse($thenelse, $node);
    }
}

function render($tree)
{
    if (is_array($tree)) {
        $if = trim($tree['if']);
        $then = trim($tree['then']);
        $else = render($tree['else']);

        return "if ({$if}) { return {$then}; } else{$else}";
    }

    $tree = trim($tree);

    return " { return {$tree}; }";
}

parse($cond, $tree);

echo is_string($tree) ? " return intval({$tree}); " : render($tree);
// if ($n%10==1 && $n%100!=11) { return 0; } elseif ($n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20)) { return 1; } else { return 2; }
annando commented 3 years ago

@realkinetix please have a look for entries in your workerqueue with the "command" field set to "APDelivery" that isn't done. In "parameter" you should see a JSON construct like ["wall-new",35223440,"https:\/\/de.relay.friendi.ca\/inbox",1]. Please have a look for an entry where the second parameter (here 35223440) isn't numerical, but a string. Please post it here.

realkinetix commented 3 years ago

Hi @annando

Would it be considered a string if the field is ""? I checked a number of entries, and just showing id,parameter,created there's lots like:

| 87826822 | ["removeme","","https:\/\/social.mieth.net\/inbox",1725]                                                 | 2020-12-12 01:55:07 |

Sorry, I should mention that the actual query was: select id,parameter,created from workerqueue where command like '%apdelivery%' limit X;

Just want to be clear that I was checking for the right thing.

MrPetovan commented 3 years ago

@sunchaserinfo Thank you so much for the suggestion, we'll try to use it in our .po to .php file converter!

annando commented 3 years ago

@realkinetix Can you delete those entries by hand? This "" doesn't look good.

realkinetix commented 3 years ago

OK, have done so. It's stopped those specific errors, will have to see how the rest of the worker tasks go. Would you like me to provide any follow-up/checks on this?

annando commented 3 years ago

@realkinetix I guess this call had been generated by the previous version? I now added some additional checks.

realkinetix commented 3 years ago

I believe that these have been around for awhile based on the queue backlog - 2020.12, I believe. Unfortunately, I can't easily verify that now.

AlfredSK commented 3 years ago

2021-03-dev - 1395 / PHP 7.4

[31-Jan-2021 10:59:15 Europe/Moscow] PHP Fatal error:  Uncaught TypeError: Argument 1 passed to Friendica\Core\ACL::getMessageContactSelectHTML() must be of the type int or null, string given, called in .../mod/message.php on line 189 and defined in .../src/Core/ACL.php:42
Stack trace:
#0 .../mod/message.php(189): Friendica\Core\ACL::getMessageContactSelectHTML()
#1 .../src/LegacyModule.php(90): message_content()
#2 .../src/LegacyModule.php(64): Friendica\LegacyModule::runModuleFunction()
#3 [internal function]: Friendica\LegacyModule::content()
#4 .../src/App/Page.php(333): call_user_func()
#5 .../src/App/Page.php(390): Friendica\App\Page->initContent()
#6 .../src/App.php(557): Friendica\App\Page->run()
#7 .../index.php(42): Friendica\App->runFrontend()
#8 {main}
  thrown in .../src/Core/ACL.php on line 42

Still happens on current RC (2021-03-27)

blackandred commented 3 years ago
$ php bin/worker.php 

Fatal error: Uncaught TypeError: Argument 1 passed to Friendica\Util\Network::unparseURL() must be of the type array, bool given, called in /var/www/html/src/Model/GServer.php on line 268 and defined in /var/www/html/src/Util/Network.php:439
Stack trace:
#0 /var/www/html/src/Model/GServer.php(268): Friendica\Util\Network::unparseURL(false)
#1 /var/www/html/src/Worker/UpdateGServer.php(53): Friendica\Model\GServer::cleanURL('https://https:s...')
#2 [internal function]: Friendica\Worker\UpdateGServer::execute('https://https:s...')
#3 /var/www/html/src/Core/Worker.php(444): call_user_func_array('Friendica\\Worke...', Array)
#4 /var/www/html/src/Core/Worker.php(334): Friendica\Core\Worker::execFunction(Array, 'UpdateGServer', Array, true)
#5 /var/www/html/src/Core/Worker.php(105): Friendica\Core\Worker::execute(Array)
#6 /var/www/html/bin/worker.php(81): Friendica\Core\Worker::processQueue(true)
#7 {main}
  thrown in /var/www/html/src/Util/Network.php on line 439

And the debugging, the invalid url is:

string(34) "https://https:social.urspringer.de"

image

MrPetovan commented 3 years ago

Thank you for the detailed report, it looks like a duplicated protocol in the URL, see the truncated parameter to UpdateGServer::execute: 'https://https:s...'.

MrPetovan commented 3 years ago

In the meantime, please delete all the rows in your workerqueue database table where `command` = 'UpdateGServer'.

blackandred commented 3 years ago

In the meantime, please delete all the rows in your workerqueue database table where `command` = 'UpdateGServer'.

Now it does not throw any error. But also didn't resolve my issue #9899, the worker is still breaking the instance url :disappointed:

MrPetovan commented 3 years ago

Fair enough, let's take one thing at a time 😅

realkinetix commented 3 years ago

Updated to today's develop code, seeing:

[07-Feb-2021 17:18:15 UTC] PHP Fatal error:  Uncaught TypeError: Argument 5 passed to Friendica\Worker\APDelivery::execute() must be of the type array, string given in /home/friendica/friendica/src/Worker/APDelivery.php:46
Stack trace:
#0 [internal function]: Friendica\Worker\APDelivery::execute()
#1 /home/friendica/friendica/src/Core/Worker.php(454): call_user_func_array()
#2 /home/friendica/friendica/src/Core/Worker.php(344): Friendica\Core\Worker::execFunction()
#3 /home/friendica/friendica/src/Core/Worker.php(111): Friendica\Core\Worker::execute()
#4 /home/friendica/friendica/bin/worker.php(83): Friendica\Core\Worker::processQueue()
#5 {main}
  thrown in /home/friendica/friendica/src/Worker/APDelivery.php on line 46
tobiasd commented 3 years ago

9949 seems to have introduced the following fatal error on my node.

PHP Fatal error:  Uncaught TypeError: Argument 2 passed to conversation() must be of the type array, null given, called in /src/Module/Profile/Status.php on line 234 and defined in /include/conversation.php:360
Stack trace:
#0 /src/Module/Profile/Status.php(234): conversation()
#1 /src/Module/Profile/Index.php(44): Friendica\Module\Profile\Status::content()
#2 [internal function]: Friendica\Module\Profile\Index::content()
#3 /src/App/Page.php(333): call_user_func()
#4 /src/App/Page.php(390): Friendica\App\Page->initContent()
#5 /src/App.php(557): Friendica\App\Page->run()
#6 /index.php(42): Friendica\App->runFrontend()
#7 {main}  thrown in /include/conversation.php on line 360

With the result of no postings are shown in any timelines and single thread display. Going back to 574f7784113b3d4a7463cd0f0d84b8c74e7bbc26 (which is the PR before 9949) everything works again.

This one was fixed with #9951

AlfredSK commented 3 years ago

Looks similar but not identical to the predecessor:

[24-Feb-2021 17:10:14 UTC] PHP Fatal error:  Uncaught TypeError: Argument 2 passed to conversation() must be of the type array, bool given, called in .../src/Module/Update/Community.php on line 42 and defined in .../include/conversation.php:360
Stack trace:
#0 .../src/Module/Update/Community.php(42): conversation()
#1 [internal function]: Friendica\Module\Update\Community::rawContent()
#2 .../src/App/Module.php(289): call_user_func()
#3 .../src/App.php(552): Friendica\App\Module->run()
#4 .../index.php(42): Friendica\App->runFrontend()
#5 {main}
  thrown in .../include/conversation.php on line 360

2021.03-dev PHP 7.4

Addressed in #10139

ghost commented 3 years ago
PHP Fatal error:  Uncaught ImagickException: Unable to scale image in /src/Object/Image.php:544
Stack trace:
#0 src/Object/Image.php(544): Imagick->scaleimage()
#1 src/Object/Image.php(518): Friendica\Object\Image->scale()
#2 src/Model/Photo.php(461): Friendica\Object\Image->scaleToSquare()
#3 src/Model/Contact.php(1734): Friendica\Model\Photo::importProfilePhoto()
#4 src/Model/Contact.php(2021): Friendica\Model\Contact::updateAvatar()
#5 src/Model/Contact.php(1916): Friendica\Model\Contact::updateFromProbeArray()
#6 src/Worker/UpdateContact.php(35): Friendica\Model\Contact::updateFromProbe()
#7 [internal function]: Friendica\Worker\UpdateContact::execute()
#8 src/Core/Worker.php(454): call_user_func_array()
#9 ...
in src/Object/Image.php on line 544

Addressed in #10069

ghost commented 3 years ago

latest dev

PHP Fatal error:  Uncaught ImagickException: cache resources exhausted `' @ error/cache.c/OpenPixelCache/4083 in /src/Object/Image.php:680
Stack trace:
#0 /src/Object/Image.php(680): Imagick->deconstructimages()
#1 /src/Model/Photo.php(314): Friendica\Object\Image->asString()
#2 /src/Model/Photo.php(486): Friendica\Model\Photo::store()
#3 /src/Model/Contact.php(1734): Friendica\Model\Photo::importProfilePhoto()
#4 /src/Model/Contact.php(2021): Friendica\Model\Contact::updateAvatar()
#5 /src/Model/Contact.php(1916): Friendica\Model\Contact::updateFromProbeArray()
#6 /src/Worker/UpdateContact.php(35): Friendica\Model\Contact::updateFromProbe()
#7 [internal function]: Friendica\Worker\UpdateContact::execute()
#8 /src/Core/Worker. in /src/Object/Image.php on line 680

Addressed in #10144

annando commented 3 years ago

@copiis according to https://stackoverflow.com/questions/31407010/cache-resources-exhausted-imagemagick it seems to be a memory issue.

MrPetovan commented 3 years ago

Yes, but we still should handle the exception in Friendica.

Quix0r commented 1 year ago

2023-01-02T00:22:16Z index [ERROR]: Uncaught Exception Error: "Call to a member function deconstructImages() on null" at /var/www/.../src/Object/Image.php line 696 {"exception":"Error: Call to a member function deconstructImages() on null in /var/www/.../src/Object/Image.php:696\nStack trace:\n#0 /var/www/.../src/Object/Image.php(732): Friendica\Object\Image->asString()\n#1 /var/www/.../src/Model/Post/Link.php(140): Friendica\Object\Image->getBlurHash()\n#2 /var/www/.../src/Model/Post/Link.php(79): Friendica\Model\Post\Link::fetchMimeType()\n#3 /var/www/.../src/Protocol/ActivityPub/Processor.php(141): Friendica\Model\Post\Link::getByLink()\n#4 /var/www/.../src/Protocol/ActivityPub/Processor.php(825): Friendica\Protocol\ActivityPub\Processor::replaceEmojis()\n#5 /var/www/.../src/Protocol/ActivityPub/Processor.php(456): Friendica\Protocol\ActivityPub\Processor::processContent()\n#6 /var/www/.../src/Protocol/ActivityPub/Receiver.php(700): Friendica\Protocol\ActivityPub\Processor::createItem()\n#7 /var/www/.../src/Protocol/ActivityPub/Receiver.php(676): Friendica\Protocol\ActivityPub\Receiver::routeActivities()\n#8 /var/www/.../src/Protocol/ActivityPub/Processor.php(1558): Friendica\Protocol\ActivityPub\Receiver::processActivity()\n#9 /var/www/.../src/Model/Item.php(3699): Friendica\Protocol\ActivityPub\Processor::fetchMissingActivity()\n#10 /var/www/.../src/Module/Search/Index.php(297): Friendica\Model\Item::fetchByLink()\n#11 /var/www/.../src/Module/Search/Index.php(128): Friendica\Module\Search\Index::tryRedirectToPost()\n#12 /var/www/.../src/BaseModule.php(244): Friendica\Module\Search\Index->content()\n#13 /var/www/.../src/App.php(746): Friendica\BaseModule->run()\n#14 /var/www/.../index.php(44): Friendica\App->runFrontend()\n#15 {main}"} - {"file":null,"line":null,"function":null,"uid":"7bcf07","process_id":4518}

Just to document this one. Maybe invalid, then I remove it from here.

tobiasd commented 1 year ago

are you still running 2021.03 @Quix0r ? Current fatal errors should be collected in #12486

Quix0r commented 1 year ago

Oh, wrong thread. I use: This is Friendica, version 2023.03-dev that is running at the web location https://f.haeder.net. The database version is 1507/1507, the post update version is 1507/1507.