[GH-ISSUE #366] Exception when running sync in koel 2.2.1 #264

Closed
opened 2026-02-26 02:32:37 +03:00 by kerem · 7 comments
Owner

Originally created by @loop0 on GitHub (Jun 26, 2016).
Original GitHub issue: https://github.com/koel/koel/issues/366

Hi, I'm having some trouble running the sync command, it was working fine until I put more music in the folder and tried to run as stated in the upgrade guide:

php artisan koel:sync --tags=track --force

It gives me this error:

  [ErrorException]                      
  Trying to get property of non-object

And if I run without the --tags=track it gives me the following error:

  [Illuminate\Database\QueryException]                                                                                                               
  SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column "path" violates not-null constraint                                            
  DETAIL:  Failing row contains (455f2dec6e60a665ea499d13d7acdabc, 51, The Black And White, 216.5811875, , null, 1466186631, 2016-06-26 14:03:54, 2  
  016-06-26 14:03:54, 10). (SQL: insert into "songs" ("id", "title", "length", "track", "lyrics", "mtime", "album_id", "updated_at", "created_at")   
  values (455f2dec6e60a665ea499d13d7acdabc, The Black And White, 216.5811875, 10, , 1466186631, 51, 2016-06-26 14:03:54, 2016-06-26 14:03:54))       



  [PDOException]                                                                                                                                     
  SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column "path" violates not-null constraint                                            
  DETAIL:  Failing row contains (455f2dec6e60a665ea499d13d7acdabc, 51, The Black And White, 216.5811875, , null, 1466186631, 2016-06-26 14:03:54, 2  
  016-06-26 14:03:54, 10).                 

I couldn't figure out why the path is being set as null.

Originally created by @loop0 on GitHub (Jun 26, 2016). Original GitHub issue: https://github.com/koel/koel/issues/366 Hi, I'm having some trouble running the sync command, it was working fine until I put more music in the folder and tried to run as stated in the upgrade guide: ``` php artisan koel:sync --tags=track --force ``` It gives me this error: ``` [ErrorException] Trying to get property of non-object ``` And if I run without the `--tags=track` it gives me the following error: ``` [Illuminate\Database\QueryException] SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "path" violates not-null constraint DETAIL: Failing row contains (455f2dec6e60a665ea499d13d7acdabc, 51, The Black And White, 216.5811875, , null, 1466186631, 2016-06-26 14:03:54, 2 016-06-26 14:03:54, 10). (SQL: insert into "songs" ("id", "title", "length", "track", "lyrics", "mtime", "album_id", "updated_at", "created_at") values (455f2dec6e60a665ea499d13d7acdabc, The Black And White, 216.5811875, 10, , 1466186631, 51, 2016-06-26 14:03:54, 2016-06-26 14:03:54)) [PDOException] SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "path" violates not-null constraint DETAIL: Failing row contains (455f2dec6e60a665ea499d13d7acdabc, 51, The Black And White, 216.5811875, , null, 1466186631, 2016-06-26 14:03:54, 2 016-06-26 14:03:54, 10). ``` I couldn't figure out why the path is being set as null.
kerem 2026-02-26 02:32:37 +03:00
Author
Owner

@phanan commented on GitHub (Jun 27, 2016):

What happens if you remove the new media files and re-run sync?

<!-- gh-comment-id:228667867 --> @phanan commented on GitHub (Jun 27, 2016): What happens if you _remove_ the new media files and re-run `sync`?
Author
Owner

@loop0 commented on GitHub (Jun 28, 2016):

If I remove the new media it works. I noticed that some of the new media directories have ' and & on its names. Could this be the source of the problem?

<!-- gh-comment-id:229209158 --> @loop0 commented on GitHub (Jun 28, 2016): If I remove the new media it works. I noticed that some of the new media directories have `'` and `&` on its names. Could this be the source of the problem?
Author
Owner

@loop0 commented on GitHub (Jun 28, 2016):

I have managed to track down what line of code is causing the problem:
File: koel-2.2.1/app/Models/File.php

        if ($this->isChanged() || $force) {
            // This is a changed file, or the user is forcing updates.
            // We cater for the tags by removing those not specified.
            $info = array_intersect_key($info, array_flip($tags));

If I comment this array_intersect_key line the sync works, but I don't know if it has a side-effect.

<!-- gh-comment-id:229216531 --> @loop0 commented on GitHub (Jun 28, 2016): I have managed to track down what line of code is causing the problem: File: `koel-2.2.1/app/Models/File.php` ``` if ($this->isChanged() || $force) { // This is a changed file, or the user is forcing updates. // We cater for the tags by removing those not specified. $info = array_intersect_key($info, array_flip($tags)); ``` If I comment this `array_intersect_key` line the sync works, but I don't know if it has a side-effect.
Author
Owner

@phanan commented on GitHub (Jun 29, 2016):

Can you help var_dump() both $info and $tags before that line?

<!-- gh-comment-id:229224907 --> @phanan commented on GitHub (Jun 29, 2016): Can you help `var_dump()` both `$info` and `$tags` before that line?
Author
Owner

@loop0 commented on GitHub (Jun 29, 2016):

$info

array(9) {
  ["artist"]=>
  string(4) "NOFX"
  ["album"]=>
  string(32) "White Trash Two Heebs And A Bean"
  ["title"]=>
  string(16) "Johnny Appleseed"
  ["length"]=>
  float(157.9363125)
  ["track"]=>
  int(11)
  ["lyrics"]=>
  string(0) ""
  ["cover"]=>
  NULL
  ["path"]=>
  string(92) "/mnt/Music/NOFX Discography/NOFX - White Thash Two Heebs And A Bean/11. Johnny Appleseed.mp3"
  ["mtime"]=>
  int(1466184294)
}

$tags

array(2) {
  [0]=>
  string(5) "track"
  [1]=>
  string(5) "mtime"
}

Funny thing is that now it works, but the media is already in the database, so instead of insert is an update being made.

<!-- gh-comment-id:229364618 --> @loop0 commented on GitHub (Jun 29, 2016): `$info` ``` array(9) { ["artist"]=> string(4) "NOFX" ["album"]=> string(32) "White Trash Two Heebs And A Bean" ["title"]=> string(16) "Johnny Appleseed" ["length"]=> float(157.9363125) ["track"]=> int(11) ["lyrics"]=> string(0) "" ["cover"]=> NULL ["path"]=> string(92) "/mnt/Music/NOFX Discography/NOFX - White Thash Two Heebs And A Bean/11. Johnny Appleseed.mp3" ["mtime"]=> int(1466184294) } ``` `$tags` ``` array(2) { [0]=> string(5) "track" [1]=> string(5) "mtime" } ``` Funny thing is that now it works, but the media is already in the database, so instead of insert is an update being made.
Author
Owner

@loop0 commented on GitHub (Jun 30, 2016):

I do think the problem here is the if ($this->isChanged() || $force), because if it's a new file being created, using array_intersect_key you're losing a lot of required information. Probably if I run without --force it will work. I'm gonna try to have a more reproducible environment at home, and also give a shot using the master version.

<!-- gh-comment-id:229743182 --> @loop0 commented on GitHub (Jun 30, 2016): I do think the problem here is the `if ($this->isChanged() || $force)`, because if it's a new file being created, using `array_intersect_key` you're losing a lot of required information. Probably if I run without `--force` it will work. I'm gonna try to have a more reproducible environment at home, and also give a shot using the master version.
Author
Owner

@phanan commented on GitHub (Jul 1, 2016):

Hmm… I got what you mean. So this seems to be the case:

  1. New files are put into the directory
  2. php artisan koel:sync --tags=track --force is run
  3. Because you specify --tags as track, only track and mtime (required) are catered. This causes the problem with the files in step 1, as they are new and would require other tags as well.

I'll work on a fix. Meanwhile, I think it makes more sense if you don't force to sync only several tags if there are new files.

<!-- gh-comment-id:229831998 --> @phanan commented on GitHub (Jul 1, 2016): Hmm… I got what you mean. So this seems to be the case: 1. New files are put into the directory 2. `php artisan koel:sync --tags=track --force` is run 3. Because you specify `--tags` as `track`, only `track` and `mtime` (required) are catered. This causes the problem with the files in step 1, as they are new and would require other tags as well. I'll work on a fix. Meanwhile, I think it makes more sense if you don't force to sync only several tags if there are new files.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#264
No description provided.