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

LogicException when clicking on a Tag #389

Closed
SchabrechtsK opened this issue Mar 24, 2016 · 5 comments
Closed

LogicException when clicking on a Tag #389

SchabrechtsK opened this issue Mar 24, 2016 · 5 comments

Comments

@SchabrechtsK
Copy link

When I click on a tag when I'm on a BlogEntry.ss page I get a LogicException error for the tag.

[User Error] Uncaught LogicException: Orphaned $belongs_many_many value for BlogHolder.Tag
GET /nl/blog/tag/post/

Now the only thing I added was an Extension:

class BlogEntryExtension extends \DataExtension
{


    private static $db = array(
        'Bio' => 'Text',
    );

    private static $has_one = [
        'Image' => 'Image'
    ];
...

But it was already broken before that.

The composer file:

"require": {
        "php": ">=5.3.2",
        "silverstripe/cms": "3.2.1",
        "silverstripe/framework": "3.2.1",
        "gdmedia/ss-auto-git-ignore": "dev-master",
        "tractorcow/silverstripe-fluent": "dev-master",
        "sheadawson/silverstripe-blocks": "dev-ss3.2",
            "sheadawson/silverstripe-linkable": "^1.2",
            "sheadawson/quickaddnew": "~1.1",
            "silverstripe-australia/gridfieldextensions": "~1.0",
            "silverstripe-australia/metadata": "dev-ss3.2",
            "unclecheese/betterbuttons": "~1.2.0",
            "undefinedoffset/sortablegridfield": "~0.4.0",
            "silverstripe/display-logic": "~1.0",
            "silverstripe/multivaluefield": "~2.0",
        "i-lateral/silverstripe-custommenus": "dev-master",
        "axllent/silverstripe-version-truncator": "dev-master",
        "jonom/focuspoint": "^2.0",
        "silverstripe/tagfield": "^1.2",
        "stevie-mayhew/trait-loader": "dev-master",
        "proj4php/proj4php": "^2.0",
        "guzzlehttp/guzzle": "^6.1",
        "micmania1/silverstripe-lumberjack": "^1.0",
        "silverstripe/blog": "1.0.0",
        "silverstripe/widgets": "^1.2",
        "silverstripe-australia/memberprofiles": "^1.1",
        "nadzweb/advancedfaq": "dev-master"
    },

Any ideas?

@dhensby
Copy link
Contributor

dhensby commented Mar 24, 2016

BlogHolder shouldn't be related to tags, should it? Are you sure you don't have some other kind of customisation?

@SchabrechtsK
Copy link
Author

This is in my extensions.yml:

BlogEntry:
  extensions:
    - 'MySite\Extension\BlogEntryExtension'
    - 'WidgetPageExtension'
BlogHolder:
  extensions:
    - 'WidgetPageExtension'

Now I did add the Image and the Image apparently has:

Image:
  extensions:
    - 'MySite\Extension\TagExtension'
    - 'MySite\Extension\ImageExtension'

Could that be the problem? I did try to remove the Image but still have the error.

@SchabrechtsK
Copy link
Author

This is the trace btw:

Trace
* DataObject->manyManyComponent(Tag) 
DataObject.php:1769
* DataObject->getManyManyComponents(Tag,SS_HTTPRequest) 
* call_user_func_array(Array,Array) 
Object.php:725
* Object->__call(tag,Array) 
* BlogHolder->tag(SS_HTTPRequest) 
* call_user_func_array(Array,Array) 
Object.php:707
* Object->__call(tag,Array) 
RequestHandler.php:288
* BlogHolder_Controller->tag(SS_HTTPRequest) 
RequestHandler.php:288
* RequestHandler->handleAction(SS_HTTPRequest,tag) 
Controller.php:200
* Controller->handleAction(SS_HTTPRequest,tag) 
RequestHandler.php:200
* RequestHandler->handleRequest(SS_HTTPRequest,DataModel) 
Controller.php:157
* Controller->handleRequest(SS_HTTPRequest,DataModel) 
ContentController.php:198
* ContentController->handleRequest(SS_HTTPRequest,DataModel) 
ModelAsController.php:78
* ModelAsController->handleRequest(SS_HTTPRequest,DataModel) 
Director.php:385
* Director::handleRequest(SS_HTTPRequest,Session,DataModel) 
Director.php:149
* Director::direct(/nl/blog/tag/post/,DataModel) 
main.php:184

@SchabrechtsK
Copy link
Author

Could this be the problem:

  * Blogposts that have a tag that is simular to the tags of this Entity
     *
     * @return \DataList
     */
    public function getBlogposts()
    {
        $Tags = $this->Species()->Tag();
        $tagsToCheck = array();
        foreach($Tags as $Tag) {
            array_push($tagsToCheck, $Tag->Name);
        }
        $returnedArticles = BlogEntry::get()->filter(array(
            'Tags:PartialMatch' => $tagsToCheck
        ))->sort('Date');
        return $returnedArticles;
    }

@tractorcow
Copy link

Please upgrade to blog 2. In blog 1.x, tags are not dataobjects, but are simply stored in comma-separated string values on BlogEntry.

It appears the code you have issues with is user-code not related to this module.

You can keep using 1.x if you like, but you're likely to not get much support sorry!

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

3 participants