{"action":"created","issue":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5245","repository_url":"https://api.github.com/repos/silverstripe/silverstripe-framework","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5245/labels{/name}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5245/comments","events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5245/events","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/5245","id":144252256,"number":5245,"title":"[3.1.18] Root-View of AssetAdmin broken ('numchildfolders' does not exist on 'File')","user":{"login":"th3hamm0r","id":468164,"avatar_url":"https://avatars.githubusercontent.com/u/468164?v=3","gravatar_id":"","url":"https://api.github.com/users/th3hamm0r","html_url":"https://github.com/th3hamm0r","followers_url":"https://api.github.com/users/th3hamm0r/followers","following_url":"https://api.github.com/users/th3hamm0r/following{/other_user}","gists_url":"https://api.github.com/users/th3hamm0r/gists{/gist_id}","starred_url":"https://api.github.com/users/th3hamm0r/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/th3hamm0r/subscriptions","organizations_url":"https://api.github.com/users/th3hamm0r/orgs","repos_url":"https://api.github.com/users/th3hamm0r/repos","events_url":"https://api.github.com/users/th3hamm0r/events{/privacy}","received_events_url":"https://api.github.com/users/th3hamm0r/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-03-29T12:36:17Z","updated_at":"2016-04-05T21:13:55Z","closed_at":null,"body":"I've tried to upgrade from 3.1.12 to 3.1.18 and now the assets admin is broken. I cannot open the root view anymore, only subfolders are viewable. The following error occurs (the full stack trace is appended below):\r\n\r\n    [User Error] Uncaught Exception: Object->__call(): the method 'numchildfolders' does not exist on 'File'\r\n\r\nIn my case I have more than 30 items in the root. Most of them are folders, but there are also some files which are at the top due to low ID values. If I remove those files, the error disappears. If I remove those files and add new ones (those files are appended and are not shown because there are more than 30 files and only 30 are shown per page) there is also no error.\r\n\r\nThere is an unanswered thread in the forum related to this issue: http://www.silverstripe.org/community/forums/upgrading-silverstripe/show/111621\r\n\r\nI've just replied to this thread, because I've found some code changes that seem to be related to this issue:\r\nhttps://github.com/silverstripe/silverstripe-framework/pull/4202\r\n\r\nHere the content of the error page:\r\n\r\n    [User Error] Uncaught Exception: Object->__call(): the method 'numchildfolders' does not exist on 'File'\r\n    GET /admin/assets/show/0\r\n\r\n    Line 763 in /vagrant/silverstripe/framework/core/Object.php\r\n    Source\r\n\r\n    754 \t\t\t\tdefault :\r\n    755 \t\t\t\t\tthrow new Exception (\r\n    756 \t\t\t\t\t\t\"Object->__call(): extra method $method is invalid on $this->class:\"\r\n    757 \t\t\t\t\t\t\t. var_export($config, true)\r\n    758 \t\t\t\t\t);\r\n    759 \t\t\t}\r\n    760 \t\t} else {\r\n    761 \t\t\t// Please do not change the exception code number below.\r\n    762 \t\t\t$class = get_class($this);\r\n    763 \t\t\tthrow new Exception(\"Object->__call(): the method '$method' does not exist on '$class'\", 2175);\r\n    764 \t\t}\r\n    765 \t}\r\n    766 \t\r\n    767 \t// --------------------------------------------------------------------------------------------------------------\r\n    768 \t\r\n    769 \t/**\r\n\r\n    Trace\r\n\r\n        Object->__call(numChildFolders,Array)\r\n        Hierarchy.php:307\r\n        File->numChildFolders()\r\n        Hierarchy.php:307\r\n        Hierarchy->markingFinished(numChildFolders)\r\n        Hierarchy.php:116\r\n        Hierarchy->getChildrenAsUL(,Closure,CMSPagesController,1,ChildFolders,numChildFolders,30,Closure)\r\n        call_user_func_array(Array,Array)\r\n        Object.php:731\r\n        Object->__call(getChildrenAsUL,Array)\r\n        LeftAndMain.php:895\r\n        Folder->getChildrenAsUL(,Closure,CMSPagesController,1,ChildFolders,numChildFolders,30,Closure)\r\n        LeftAndMain.php:895\r\n        LeftAndMain->getSiteTreeFor(Folder,,ChildFolders,numChildFolders,,30)\r\n        AssetAdmin.php:539\r\n        AssetAdmin->getSiteTreeFor(Folder,,ChildFolders,numChildFolders)\r\n        AssetAdmin.php:547\r\n        AssetAdmin->SiteTreeAsUL()\r\n        AssetAdmin.php:288\r\n        AssetAdmin->getEditForm()\r\n        LeftAndMain.php:1166\r\n        LeftAndMain->EditForm()\r\n        ViewableData.php:361\r\n        ViewableData->obj(EditForm,,1,,)\r\n        SSViewer.php:91\r\n        SSViewer_Scope->getObj(EditForm,,1,,)\r\n        SSViewer.php:513\r\n        SSViewer_DataPresenter->getObj(EditForm,,1,,)\r\n        SSViewer.php:111\r\n        SSViewer_Scope->obj(EditForm,,1)\r\n        .cache.cms.templates.Includes.AssetAdmin_Content.ss:9\r\n        include(/tmp/kronehit/silverstripe/.cache.cms.templates.Includes.AssetAdmin_Content.ss)\r\n        SSViewer.php:1033\r\n        SSViewer->includeGeneratedTemplate(/tmp/kronehit/silverstripe/.cache.cms.templates.Includes.AssetAdmin_Content.ss,AssetAdmin,,Array,)\r\n        SSViewer.php:1100\r\n        SSViewer->process(AssetAdmin,)\r\n        ViewableData.php:334\r\n        ViewableData->renderWith(Array)\r\n        LeftAndMain.php:720\r\n        LeftAndMain->Content()\r\n        ViewableData.php:361\r\n        ViewableData->obj(Content,,,1)\r\n        ViewableData.php:436\r\n        ViewableData->XML_val(Content,,1)\r\n        call_user_func_array(Array,Array)\r\n        SSViewer.php:179\r\n        SSViewer_Scope->__call(XML_val,Array)\r\n        SSViewer.php:538\r\n        SSViewer_DataPresenter->__call(XML_val,Array)\r\n        .cache.framework.admin.templates.LeftAndMain.ss:41\r\n        SSViewer_DataPresenter->XML_val(Content,,1)\r\n        .cache.framework.admin.templates.LeftAndMain.ss:41\r\n        include(/tmp/kronehit/silverstripe/.cache.framework.admin.templates.LeftAndMain.ss)\r\n        SSViewer.php:1033\r\n        SSViewer->includeGeneratedTemplate(/tmp/kronehit/silverstripe/.cache.framework.admin.templates.LeftAndMain.ss,AssetAdmin,,Array,)\r\n        SSViewer.php:1100\r\n        SSViewer->process(AssetAdmin,)\r\n        ViewableData.php:334\r\n        ViewableData->renderWith(SSViewer)\r\n        LeftAndMain.php:597\r\n        {closure}()\r\n        call_user_func(Closure)\r\n        PjaxResponseNegotiator.php:82\r\n        PjaxResponseNegotiator->respond(SS_HTTPRequest)\r\n        LeftAndMain.php:574\r\n        LeftAndMain->show(SS_HTTPRequest)\r\n        RequestHandler.php:288\r\n        RequestHandler->handleAction(SS_HTTPRequest,show)\r\n        Controller.php:194\r\n        Controller->handleAction(SS_HTTPRequest,show)\r\n        RequestHandler.php:200\r\n        RequestHandler->handleRequest(SS_HTTPRequest,DataModel)\r\n        Controller.php:153\r\n        Controller->handleRequest(SS_HTTPRequest,DataModel)\r\n        LeftAndMain.php:449\r\n        LeftAndMain->handleRequest(SS_HTTPRequest,DataModel)\r\n        AdminRootController.php:93\r\n        AdminRootController->handleRequest(SS_HTTPRequest,DataModel)\r\n        Director.php:370\r\n        Director::handleRequest(SS_HTTPRequest,Session,DataModel)\r\n        Director.php:153\r\n        Director::direct(/admin/assets/show/0,DataModel)\r\n        main.php:184"},"comment":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/comments/205986318","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/5245#issuecomment-205986318","issue_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5245","id":205986318,"user":{"login":"tractorcow","id":936064,"avatar_url":"https://avatars.githubusercontent.com/u/936064?v=3","gravatar_id":"","url":"https://api.github.com/users/tractorcow","html_url":"https://github.com/tractorcow","followers_url":"https://api.github.com/users/tractorcow/followers","following_url":"https://api.github.com/users/tractorcow/following{/other_user}","gists_url":"https://api.github.com/users/tractorcow/gists{/gist_id}","starred_url":"https://api.github.com/users/tractorcow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tractorcow/subscriptions","organizations_url":"https://api.github.com/users/tractorcow/orgs","repos_url":"https://api.github.com/users/tractorcow/repos","events_url":"https://api.github.com/users/tractorcow/events{/privacy}","received_events_url":"https://api.github.com/users/tractorcow/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T21:13:55Z","updated_at":"2016-04-05T21:13:55Z","body":">  Sounds like there is a piece of code somewhere that is assuming that if a File has children it must be a Folder and treating it as such\r\n\r\nI think the problem is that hierarchy is applied at the top level class, which in itself doesn't actually act in a hierarchal manner. Parent classes shouldn't rely on the implementation of certain subclasses in order for it to meet the requirements of its api.\r\n\r\nI think I would rather than File and Folder didn't have the same class hierarchy; Files should be only files, Folders are only folders, and are not substitutable for File.\r\n\r\nIn 4.x we version files also, but have the undesirable effect of having to version Folders too. I would rather something like this;\r\n\r\n```php\r\n\r\nclass File extends DataObject {\r\n\tprivate static $extensions = [\r\n\t\t'Versioned'\r\n\t];\r\n}\r\n\r\nclass Folder extends DataObject {\r\n\tprivate static $extensions = [\r\n\t\t'Hierarchy'\r\n\t];\r\n}\r\n```\r\n\r\nWhere currently we have this.\r\n\r\n\r\n```php\r\n\r\nclass File extends DataObject {\r\n\tprivate static $extensions = [\r\n\t\t'Versioned',\r\n\t\t'Hierarchy'\r\n\t];\r\n}\r\n\r\nclass Folder extends File {}\r\n```"}}