CarnetApp / CarnetNextcloud

GNU Affero General Public License v3.0
153 stars 28 forks source link

Carnet app broken in Nextcloud 28.0.1 #214

Closed goddib closed 4 months ago

goddib commented 6 months ago

Describe the bug After updating to Nextcloud 28.0.1 loading Carnet as usual via the menu results in internal server error.

{"reqId":"t8alleZTizGR0piQ7uop","level":3,"time":"2023-12-22T14:47:30+00:00","remoteAddr":"*IP*","user":"*USER*","app":"index","method":"GET","url":"/index.php/apps/carnet/","message":"Call to undefined method OC_App::getAppInfo() in file '/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/apps/carnet/lib/Controller/PageController.php' line 62","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","version":"28.0.1.1","exception":{"Exception":"Exception","Message":"Call to undefined method OC_App::getAppInfo() in file '/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/apps/carnet/lib/Controller/PageController.php' line 62","Code":0,"Trace":[{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/index.php","line":39,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/private/AppFramework/Http/Dispatcher.php","Line":169,"Previous":{"Exception":"Error","Message":"Call to undefined method OC_App::getAppInfo()","Code":0,"Trace":[{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"index","class":"OCA\\Carnet\\Controller\\PageController","type":"->"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/index.php","line":39,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/apps/carnet/lib/Controller/PageController.php","Line":62},"message":"Call to undefined method OC_App::getAppInfo() in file '/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/apps/carnet/lib/Controller/PageController.php' line 62","exception":[],"CustomMessage":"Call to undefined method OC_App::getAppInfo() in file '/var/www/vhosts/*DOMAIN*/cloud.*DOMAIN*/apps/carnet/lib/Controller/PageController.php' line 62"},"id":"6585a84768b28"}

To Reproduce Steps to reproduce the behavior:

  1. Update Nextcloud to 28.0.1
  2. Click on Carnet in menu bar ...
  3. See error

Expected behavior The Carnet UI loads as usual

Screenshots image

Desktop (please complete the following information):

kekePower commented 6 months ago

Hello.

I experience the same error and have had to disable Carnet for now.

CyberMinion commented 6 months ago

Same issue with the webUI here, unfortunately. I had the same issue on 28.0.0. Same details as @goddib

Just upgrade NC, Try opening Carnet from the top nav bar, and get an error.

image

joshua-schnabel commented 6 months ago

Here is a fix to at least be able to view the notes. Doesn't fix everything yet!

Edit the file "custom_apps/carnet/lib/Controller/PageController.php"

Replace Line 34, 62, 79, 107, 123 and 137 with:

                        'app_version' => $this->appManager->getAppInfo($this->appName)['version'],

Add between Line 5 and 6:

use OCP\App\IAppManager;

Replace Constructor (Line 15 - 19) with:

        private $appManager;
        public function __construct($AppName, IRequest $request,IAppManager $AppManager,  $UserId, $Config){
                parent::__construct($AppName, $request);
                $this->userId = $UserId;
                $this->config = $Config;
                $this->appManager = $AppManager;
        }

Edit the file "custom_apps/carnet/lib/Controller/NoteController.php"

Replace Line 244 with:

    $current = $this->appManager->getAppInfo($this->appName)['version'];

Add between Line 5 and 6:

use OCP\App\IAppManager;

Replace Constructor (Line 48-50) with:

        private $appManager;
    public function __construct($AppName, IRequest $request, IAppManager $AppManager, $UserId, $RootFolder, $Config,  IDBConnection $IDBConnection, IURLGenerator $urlGenerator){
        parent::__construct($AppName, $request);
        $this->userId = $UserId;
        $this->appManager = $AppManager;
kekePower commented 6 months ago

@joshua-schnabel This is an awesome start. I was, at least, able to see the notes as you mentioned which is better than the crash seen before.

Thanks for looking into this!

CyberMinion commented 6 months ago

Thank you @joshua-schnabel

Same here--this got it up and running. The "Latest" tab might be a little broken (no entries shown), but the "browser" tab works.

So don't take this the wrong way--I have a lot of respect for the devs running projects like this. A big thank you to those who have gotten Carnet this far! It's an involved and thankless job. And on top of that, life happens. But at this point, do you folks think I should be migrating my data and users away from Carnet? This is starting to look a little like abanbonware,

Thanks!

Edit: I can't even support the devs anymore. The donation link is broken. (see issue 138 under CarnetApp: https://github.com/CarnetApp/CarnetDocumentation/issues/138 )

goddib commented 6 months ago

Thank you @joshua-schnabel - I had also started looking into updating the code but I am inexperienced so I had not gotten as far as you to get it running again. For me all tabs work now.

@CyberMinion I am also wondering, but there seems to be no alternative out there.

demuxer86 commented 5 months ago

Here is a fix to at least be able to view the notes. Doesn't fix everything yet!

My config file only has about 180 lines. I applied as many of these fixes as I could but it didnt allow me to see my notes :/

demuxer86 commented 5 months ago

Edit: I can't even support the devs anymore. The donation link is broken. (see issue 138 under CarnetApp: CarnetApp/CarnetDocumentation#138 )

Last summer, the dev didn't even want donations. He was certain to continue the project though. I really wish we could get this app up to date with everything because it absolutely blows the stock notes app out of the water.

Playnary commented 5 months ago

Here is a fix to at least be able to view the notes. Doesn't fix everything yet!

Edit the file "custom_apps/carnet/lib/Controller/PageController.php" ...

I can confirm this renders the Carnet overview page again in NC 28.0.1. But this fixes only the previews of the notes, opening them in full or editing them results in a loading-loop.

Thanks @joshua-schnabel for highlighting this promising start! Can you elaborate what you think is happening here? I may want to dive in for a proper fix at a later time.

goddib commented 5 months ago

@Playnary I can confirm that with the above mentioned fix Carnet loads in Nextcloud. The overview as well as the individual notes.

May I ask if you have the Markdown editor enabled?

Playnary commented 5 months ago

@goddib Bullseye! I had the (beta) Markdown editor enabled (completely forgot about that) and after deactivation the notes load. Thank you!

Also working: Sorting by folders.

Not working though: Sorting by keywords. Selecting a keywords triggers loading all notes indiscriminately like the browser tab.

goddib commented 5 months ago

@Playnary great to hear that helped!

As for the other issues, I can confirm that. It seems that the NoteController has a bunch more functions that need to be debugged to keep running properly. It might or might not make sense to open separate issues for those but without a developer looking into the issues I will just adding here.

LucioAlbenga commented 5 months ago

Edited because part of my changes are already in @joshua-schnabel comment.

In addition to the fix by @joshua-schnabel you should also add the following changes.

File: apps/carnet/lib/Controller/NoteController.php

Replace line 722 (original 719):

$mainFile = $_POST['isMarkdown'] ? "note.md" : "index.html";

with:

$mainFile = "index.html";
        if (isset($_POST['isMarkdown'])) {
            $mainFile = $_POST['isMarkdown'] ? "note.md" : "index.html";
        }

Replace line 773 (original 767):

if($this->shouldUseFolderNotes() || $_POST['isMarkdown']){

with:

if($this->shouldUseFolderNotes() || isset($_POST['isMarkdown']) && $_POST['isMarkDown']){

These last two fixes are to fix the error: Undefined array key "isMarkdown".

Now you should be able to edit, add, and remove notes.

CyberMinion commented 5 months ago

All but the last two I had already implemented based on previous recommendations. I've added these last two you suggested, for markdown, and it does seem that the "Latest" tab is working for now, although I observed it working a few times in the past since my previous post. I wasn't getting the error you mentioned, so perhaps this fixed something which did not affect me.

There's nothing sensitive in these "apps/carnet/lib/Controller" files, is there? Can I safely share these files for others, so we're all on the same page?

LucioAlbenga commented 5 months ago

There's nothing sensitive in these "apps/carnet/lib/Controller" files, is there? Can I safely share these files for others, so we're all on the same page?

I did not see anything sensitive inside those files.

Playnary commented 5 months ago

In addition to the fix by @joshua-schnabel you should also add the following changes.

File: apps/carnet/lib/Controller/NoteController.php

Between lines 5 and 6 before use OCP\AppFramework\Controller; add the following line:

use OCP\IRequest;

This was already included in the original file!?

Between lines 45 and 46, before public static $lastWrite = null; add the following line:

private $appManager;

Already included in @joshua-schnabel 's fix.

Replace line 49 (original 47)

public function __construct($AppName, IRequest $request, $UserId, $RootFolder, $Config,  IDBConnection $IDBConnection, IURLGenerator $urlGenerator){

with

public function __construct($AppName, IRequest $request, IAppManager $AppManager, $UserId, $RootFolder, $Config,  IDBConnection $IDBConnection, IURLGenerator $urlGenerator){

Already included in @joshua-schnabel 's fix.

Inside the constructor after line 53 (original 51), after $this->Config = $Config;, add the follwing line:

$this->appManager = $AppManager;

Already included in @joshua-schnabel 's fix.

Replace line 247 (original 244):

$current = OC_App::getAppInfo($this->appName)['version'];

with:

$current = $this->appManager->getAppInfo($this->appName)['version'];

Already included in @joshua-schnabel 's fix.

Only the two following edits are contributions additionally to @joshua-schnabel 's fix:

Replace line 722 (original 719):

$mainFile = $_POST['isMarkdown'] ? "note.md" : "index.html";

with:

$mainFile = "index.html";
        if (isset($_POST['isMarkdown'])) {
            $mainFile = $_POST['isMarkdown'] ? "note.md" : "index.html";
        }

Replace line 773 (original 767):

if($this->shouldUseFolderNotes() || $_POST['isMarkdown']){

with:

if($this->shouldUseFolderNotes() || isset($_POST['isMarkdown']) && $_POST['isMarkDown']){

These last two fixes are to fix the error: Undefined array key "isMarkdown".

Now you should be able to edit, add, and remove notes.

I can confirm that with the last two additions the 'markdown editor (beta)' option in the settings checked also results in loading notes and a functioning editor. Thank you @LucioAlbenga!

LucioAlbenga commented 5 months ago

I have to apologize guys because I did not notice that @joshua-schnabel already wrote the fixes for the NoteController.php. @Playnary thank you for pointing it out to me. I'm going to edit my original comment to reflect only the changes that are not already in Joshua's comment.

goddib commented 5 months ago

Thanks @LucioAlbenga! I am not sure if I would have been able to figure this out.

j-mcdougall commented 5 months ago

Thank you all. This is amazing. Is there somewhere that we can download these files? That is a lot of edits to try to make.

CyberMinion commented 5 months ago

Thank you all. This is amazing. Is there somewhere that we can download these files? That is a lot of edits to try to make.

Sure, here is a set of files I've modified as discussed here.

USE AT YOUR OWN RISK. These are for demonstration purposes only. If you import them into any functioning software, you are solely responsible for any detrimental results. If you were to install these, you would extract the two php files into "apps/carnet/lib/Controller/" (and always save the originals, just in case).

https://cloud.archnet.us/index.php/s/epGYeDMGwRB4mWY

Edit: in browser searching still doesn't seem to work for me, when using these fixes. However, the Android application's search still works, since it is independent code. Also, a recent bug report was posted indicating search issues on NC25. Interesting. (https://github.com/CarnetApp/CarnetNextcloud/issues/212)

CyberMinion commented 5 months ago

Same error here. Could this be because it use php 8.2

Interesting. I have it working on php 8.1. I have not tried upgrading.

Playnary commented 5 months ago

Same error here. Could this be because it use php 8.2

Interesting. I have it working on php 8.1. I have not tried upgrading.

I have, the error is neither caused nor fixed by the switch between 8.1 and 8.2. I have not tried other versions.

The fixes above seem related to other dependency changes within NC.

GTP95 commented 5 months ago

@joshua-schnabel @LucioAlbenga could you maybe make a pull request with your fixes? It would increase the chances that the fixes are merged in the official package, and in the meantime it would make it easier to have a partially working app for the users.

goddib commented 5 months ago

@Jordibgzashtita I have been on PHP 8.2.15 the whole time if that helps. First not working, now working.

I am still getting errors from the NoteController.php after the edits. Anyone else?

[index] Fehler: fclose(): supplied resource is not a valid stream resource in file '/var/www/vhosts/***domain***/apps/carnet/lib/Controller/NoteController.php' line 568 POST /index.php/apps/carnet/notes/metadata von ***IP*** von ***user*** um 26.01.2024, 10:53:50

alpapan commented 5 months ago

USE AT YOUR OWN RISK. These are for demonstration purposes only. If you import them into any functioning software, you are solely responsible for any detrimental results. If you were to install these, you would extract the two php files into "apps/carnet/lib/Controller/" (and always save the originals, just in case).

Maybe a pull request would be more useful?

Playnary commented 5 months ago

USE AT YOUR OWN RISK. These are for demonstration purposes only. If you import them into any functioning software, you are solely responsible for any detrimental results. If you were to install these, you would extract the two php files into "apps/carnet/lib/Controller/" (and always save the originals, just in case).

Maybe a pull request would be more useful?

Done.

I am still getting errors from the NoteController.php after the edits. Anyone else?

[index] Fehler: fclose(): supplied resource is not a valid stream resource in file '/var/www/vhosts/domain/apps/carnet/lib/Controller/NoteController.php' line 568 POST /index.php/apps/carnet/notes/metadata von IP von user um 26.01.2024, 10:53:50

This seems different. fclose is natlve PHP and the source is created bynew \PhpZip\ZipFile(). There are a few checks for the creation of the source before .. @alpapan did you get any other error before this one?

alpapan commented 5 months ago

I am still getting errors from the NoteController.php after the edits. Anyone else? [index] Fehler: fclose(): supplied resource is not a valid stream resource in file '/var/www/vhosts/domain/apps/carnet/lib/Controller/NoteController.php' line 568 POST /index.php/apps/carnet/notes/metadata von IP von user um 26.01.2024, 10:53:50

This seems different. fclose is natlve PHP and the source is created bynew \PhpZip\ZipFile(). There are a few checks for the creation of the source before .. @alpapan did you get any other error before this one?

Sorry this was from @goddib not me!

goddib commented 5 months ago

@Playnary It is the same error over the course of days. Not sure what to make of it

image

goddib commented 5 months ago

@alpapan now we have a pull request but I am not sure if there is anyone active who can merge it and create a new release...

alpapan commented 5 months ago

Worst case scenario is a fork and a new project :-) open source benefits

PhieF commented 5 months ago

I would be interested if someone wants to join me in carnet developpement, I'm on matrix and I would be more than happy to do it with you

@phie:lostpod.me

I'm quite overwhelmed which make dev difficult these times

These changes were merged thanks to @Playnary it doesn't fix everything though, will try to see what to do tonight

demuxer86 commented 5 months ago

Godspeed. Whatever you do, try to mimic google keep notes as much as possible. If you add the ability to upload videos and attach files, you'll be better than googles offering.

On Mon, Jan 29, 2024, 2:38 PM PhieF @.***> wrote:

I would be interested if someone wants to join me in carnet developpement, I'm on matrix and I would be more than happy to do it with you

@Phie https://github.com/Phie:lostpod.me

I'm quite overwhelmed which make dev difficult these times

These changes were merged thanks to @Playnary https://github.com/Playnary it doesn't fix everything though, will try to see what to do tonight

— Reply to this email directly, view it on GitHub https://github.com/CarnetApp/CarnetNextcloud/issues/214#issuecomment-1915521834, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5G64QBMB7BPJJ5SYEZBUFDYRACD3AVCNFSM6AAAAABA76XQVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJVGUZDCOBTGQ . You are receiving this because you commented.Message ID: @.***>

Playnary commented 5 months ago

@Playnary It is the same error over the course of days. Not sure what to make of it

Okay, @goddib, looks like a persistent but separate problem with no further errors. You can also check your browser console and to see if you have anything else appearing there.

But in any case: I suggest you open a new issue for this? The OP's problem seems to be fixed with the solutions found so far for most people.

PhieF commented 4 months ago

Closing this as releasing the fix ! thanks to you all, sorry for having been that slow to release the version

j-mcdougall commented 4 months ago

Thank you all. We appreciate your work on Carnet!