We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34926
    • 87 Posts
    I have content that is automatically added to MODx directly to the database (and not with the API). Since updating to 2.2.2 I keep getting "Resource URI already exists for resource 521..." etc which is resulting in these generated pages throwing 404 errors.

    The script does use the MODx API to refresh the cache but that isn't helping. The only way to resolve this issue so far is to set the friendly_urls system setting to 'no' and then back to 'yes' in the Manager.

    Basically I am trying to duplicate whatever is happening when you enable/disable friendly_urls. In the part where I refresh the cache I have this:

    $friendly_urls = $modx->getObject('modSystemSetting', 'friendly_urls');
    $friendly_urls->set('value', FALSE);
    $friendly_urls->save();
    
    refreshCache();
    
    $friendly_urls = $modx->getObject('modSystemSetting', 'friendly_urls');
    $friendly_urls->set('value', TRUE);
    $friendly_urls->save();


    I know what I am doing in the first place is 'hacky' at best but changing the friendly URLs setting via the API doesn't work. Any suggestions?
    • Your a bit off with the API calls here, and I really don't think you want to do this in the first place to be honest. If you are trying to avoid the Resource URI already exists warning, then make sure it is getting a unique URI. That is the real problem here. Whatever code is adding the Resource needs to be corrected to ensure this occurs.
        • 34926
        • 87 Posts
        The confusing part is that there are not any duplicate URIs when this happens.

        I think I will modify the script and add the documents using the API, that would have probably avoided this mess anyway.

        Cheers
          • 3749
          • 24,544 Posts
          If you use the Resource/Create processor to add the documents, it should help you avoid a number of problems.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting