Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carnet app broken in Nextcloud 28.0.1 #214

Closed
goddib opened this issue Dec 22, 2023 · 37 comments
Closed

Carnet app broken in Nextcloud 28.0.1 #214

goddib opened this issue Dec 22, 2023 · 37 comments

Comments

@goddib
Copy link

goddib commented Dec 22, 2023

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):

  • OS: Windows 10
  • Browser: Vivaldi
  • Version: 6.5.3206.39
@goddib goddib changed the title Carnet app not loading in Nextcloud 28.0.1 Carnet app broken in Nextcloud 28.0.1 Dec 22, 2023
@kekePower
Copy link

Hello.

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

@CyberMinion
Copy link

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
Copy link

joshua-schnabel commented Jan 5, 2024

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
Copy link

@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
Copy link

CyberMinion commented Jan 7, 2024

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: CarnetApp/CarnetDocumentation#138 )

@goddib
Copy link
Author

goddib commented Jan 7, 2024

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
Copy link

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
Copy link

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
Copy link
Contributor

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
Copy link
Author

goddib commented Jan 12, 2024

@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
Copy link
Contributor

Playnary commented Jan 12, 2024

@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
Copy link
Author

goddib commented Jan 12, 2024

@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
Copy link

LucioAlbenga commented Jan 15, 2024

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
Copy link

CyberMinion commented Jan 16, 2024

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
Copy link

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
Copy link
Contributor

Playnary commented Jan 16, 2024

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
Copy link

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
Copy link
Author

goddib commented Jan 17, 2024

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

@j-mcdougall
Copy link

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
Copy link

CyberMinion commented Jan 19, 2024

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. (#212)

@CyberMinion
Copy link

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
Copy link
Contributor

Playnary commented Jan 23, 2024

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
Copy link

GTP95 commented Jan 26, 2024

@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
Copy link
Author

goddib commented Jan 26, 2024

@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
Copy link

alpapan commented Jan 27, 2024

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
Copy link
Contributor

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 by new \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
Copy link

alpapan commented Jan 29, 2024

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 by new \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
Copy link
Author

goddib commented Jan 29, 2024

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

image

@goddib
Copy link
Author

goddib commented Jan 29, 2024

@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
Copy link

alpapan commented Jan 29, 2024

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

@PhieF
Copy link
Collaborator

PhieF commented Jan 29, 2024

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
Copy link

demuxer86 commented Jan 29, 2024 via email

@Playnary
Copy link
Contributor

Playnary commented Jan 30, 2024

@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
Copy link
Collaborator

PhieF commented Feb 18, 2024

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

@PhieF PhieF closed this as completed Feb 18, 2024
@j-mcdougall
Copy link

Thank you all. We appreciate your work on Carnet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

12 participants