We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13218
    • 134 Posts
    After creating a resource in the manager via ’Create > Create a document here’ i get this error when saving that document:
    ’An error occurred while duplicating the resource.’
    The error happens in the ’processors/resource/create.php’ where $search will be true
    /* check new resource token if posted from manager */
    if(isset($scriptProperties['create-resource-token'])) {
        $tokenFound = false;
        $tokenPassed = $scriptProperties['create-resource-token'];
    	$e = 'v';
        if(!is_null($tokenPassed)) {
            if(isset($_SESSION['newResourceTokens']) && !is_null($_SESSION['newResourceTokens'])) {
                $search = array_search($tokenPassed, $_SESSION['newResourceTokens']);
                if($search !== false) {
                    unset($_SESSION['newResourceTokens'][$search]);
                    $tokenFound = true;
                }
            }
        }
        if($tokenFound === false) {
            return $modx->error->failure('- '.($e).' - '.$modx->lexicon('resource_err_duplicate'));
        }
    }


    So the ’create-resource-token’ that is passed from the manager is found in the ’newResourceTokens’, which i’m thinking shouldn’t be the case. But then again i have no idea how they are generated and what they’re about.

    But here is what i can say to narrow down the problem:
    The error only happens when certain templates are involved (and these have a hand full or two of TVs, so i’m guessing it’s a TV thing?).
    When i create a document and the new document either inherits a certain template from the parent or i set it with a plugin onDocFormPrerender, that document can not be saved (and actually be created) but gives the error message.

    Anybody who has deeper understanding of these new token thingies has an idea if this might be a bug?
    I will make more experiments with the TVs involved, but maybe someone can point me in a direction before i keep poking around in the dark.

    Thanks,
    Marc
      @itWilllBeOK
      • 13218
      • 134 Posts
      Ok, sorry, i actually have been searching, but once again i have to post first and then find this:
      http://bugs.modx.com/issues/4642#change-10358
      Maybe that will answer something. So nevermind for now.
        @itWilllBeOK
        • 21395
        • 91 Posts
        This seems to be linked to templates with lots of TVs - I had >20, including the system ones. 15 seems to be the current limit.

        It’ s intermittent though.

        Handy work-around - duplicate an existing resource on the same template - as long as you’ve got one...


        My set-up

        CGI/FastCGI
        MODx Revo 2.1.1 (trad)
        PHP 5.3.6
        MySQL 5.1.56
        pdo-mysql installed
        ImageMagick 6.4.8 2010-01-07
        json version 1.2.1
        I browse in Firefox, Safari, IE and Chrome - latest non-Betas of each.
        I’m not opcode cacheing to my knowledge
          MODX Revolution 2.6.5-pl (traditional)

          Hosted on MODX Cloud

          Skype: nicbaldeagle
          • 28000 ☆ A M B ☆
          • 397 Posts
          I am having the same problem suddenly with a Revo 2.1.2. I get the same error when creating a new document. The templates do not have too many TVs attached to them - maybe 5. I am hoping to solve it with an upgrade.
            Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
            • 28000 ☆ A M B ☆
            • 397 Posts
            The upgrade to Revo 2.1.3 did not solve the problem.
            I am running on mysql 5.1.54-log, PHP 5.3.6, Server API CGI/FastCGI, LInux server.

            What is strange is that it all of a sudden started happening after the website had been tested and launched in March.

              Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.
              • 28000 ☆ A M B ☆
              • 397 Posts
              Ok, it turns out that is a bug somehow related to database caching. I turned it off and now the error no longer appears! It is registered as a Bug.
                Benjamin Davis: American web designer living in Munich, Germany and a MODX Ambassador. I am also co-founder of SEDA.digital, a MODX Agency.