Skip to content

Restoring database wipes all plugins #49

@Lefthandmedia

Description

@Lefthandmedia

Hi,
After the upgrade to BU 3.0.1 all my plugins are deleted when i do a restore.
I use BU to update the DB on a local MAMP from a production ENV. this worked fine in the past but since the upgrade something goes wrong while restoring the DB (i don't use it to backup files). I get a warning after restore saying 'PDO Exeption! Please read the BackupMODX errorlog for more information.
the error log says

[2019-11-05 16:28:04] (ERROR in BackupMODX @ /Users/xxx/Documents/REPOSITORY/uvaweb/clickmodel/core_uva/components/backupmodx/src/Backup/Restore.php : 49) PDO Exeption HY000 1366 Incorrect string value: '\x90fI\x02\x00\x00...' for column 'plugincode' at row 2
SQL Query: INSERT INTO `modx_site_plugins` VALUES (1,1,0,'register elements','',0,0,0,'/**\n * Created by JetBrains PhpStorm.\n * User: ralph\n * Date: 30/04/18\n * Time: 11:12 AM\n * To change this template use File | Settings | File Templates.\n *\n * DESCRIPTION\n * creates MODX elements based on text inside static files.\n * it looks trough the filesystem, finds static files and registers them as element in Modx\n * no need for a fixed file struture. the static files can be placed anywhere.\n * within the $baseDir\n *\n * PARAMETERS:\n * type:\n *      chunk\n *      snippet\n *      template\n *      plugin\n *\n * add delete:true to remove a snippet form modx based on the snippet name\n * add once:true to perform the action only once. Effectively the string SEARCHSTRING will be emptied to prevent the file from being processed each time. only with a fresh upload to server will the element be created again\n *\n *\n * USAGE in the static files:\n * <!-- YOUR SEARCHSTRING HERE{\"type\":\"chunk\",\"name\":\"TEST CHUNK\", \"categorie\":\"pinkribbon.test2.test3\"}; -->\n * <!-- YOUR SEARCHSTRING HERE{\"type\":\"chunk\",\"name\":\"TEST CHUNK\", \"categorie\":\"pinkribbon.test2.test3\", \"delete\":\"true\"}; -->\n * <!-- YOUR SEARCHSTRING HERE{\"type\":\"chunk\",\"name\":\"TEST CHUNK\", \"categorie\":\"pinkribbon.test2.test3\", \"once\":\"true\"}; -->\n *\n * So for a snippet it\'s <?php // YOUR SEARCHSTRING HERE{\"type\":\"snippet\",\"name\":\"TEST SNIPPET\", \"categorie\":\"test.test2.test3\"};\n *\n * USAGE as a snippet\n * [!register_elements]\n *\n */\n\n\n$searchstring = \'@modx-\' . \'element:\'; //the string is split to prevent THIS file from being processed by the register plugin\n$baseDir = $modx->getOption(\'register-elements-path\', null, \"staticScripts/\");\n$dir = $modx->config[\'base_path\'] . $baseDir;\n$debug = true;\n//$safetodelete = true;\n$o = \'\';\n\n\nif($debug){\n    $modx->setLogLevel(modX::LOG_LEVEL_INFO);\n}\n\nif(!$modx){\n    define(\'MODX_API_MODE\', true);\n    require_once dirname(__FILE__) . \'/config.core.php\';\n    require_once MODX_CORE_PATH . \'model/modx/modx.class.php\';\n    $modx = new modX();\n    $modx->initialize(\'web\');\n    $modx->getService(\'error\', \'error.modError\', \'\', \'\');\n}\n\n//------  Return if the user isn\'t part of one of the allowed usergroups\n$usergroups = explode(\',\', $modx->getOption(\'elementhelper.usergroups\', null, \'Administrator\'));\nif(!$modx->user->isMember($usergroups)){\n    if($debug){\n        $modx->log(xPDO::LOG_LEVEL_INFO, \'Not permitted\');\n    }\n    return;\n}\n\n$files = getFiles($dir);\n\n\nforeach ($files as $file) {\n\n    $f = fopen($file, \"r\");\n    if($f){\n        while (($buffer = fgets($f, 1024)) !== false) {\n            preg_match(\'/\' . $searchstring . \'(.*?);/\', $buffer, $display);\n            if(isset($display[1])){\n                $data = json_decode($display[1], true);\n                if($debug){\n                   // $modx->log(xPDO::LOG_LEVEL_INFO, \'process \' . $data[\"name\"]);\n                }\n                if(!isLocal() && !$data[\"once\"] == false){\n                    removeCodeline($file, $searchstring);\n                }\n                // prep categories\n                if(isset($data[\"categorie\"])){\n                    $category_names = explode(\'.\', $data[\'categorie\']);\n                    setCategories($category_names);\n                    $data[\"cat\"] = get_category_id(end($category_names));\n                } else {\n                    $data[\"cat\"] = 0;\n                }\n                if(isset($data[\"delete\"]) && $data[\"delete\"] == true){\n                    $o .= deleteElement($data);\n                } else {\n                    $data[\"file\"] = $file;\n                    $o .= createElement($data);\n                }\n            }\n        }\n\n    }\n    fclose($f);\n}\n$modx->log(xPDO::LOG_LEVEL_INFO, \'Finished processing elements!\');\n\n$modx->setLogLevel(modX::LOG_LEVEL_ERROR);\n\n\n//=============================================\n\nfunction isLocal(){\n    $is = false;\n    $locallist = array(\n            \'127.0.0.1\',\n            \'::1\'\n    );\n    if(strpos(strtolower($_SERVER[\'SERVER_NAME\']), \'dev\') === true){\n        $is = true;\n    }\n    if(strpos(strtolower($_SERVER[\'SERVER_NAME\']), \'test\') === true){\n        $is = true;\n    }\n    if(strpos(strtolower($_SERVER[\'SERVER_NAME\']), \'local\') === true){\n        $is = true;\n    }\n    if(in_array($_SERVER[\'REMOTE_ADDR\'], $locallist)){\n        $is = true;\n    }\n    return $is;\n}\n\n\nfunction removeCodeline($filename, $hit){\n    $file = file($filename);\n    $output = $file[0];\n    $lineNumber = 0;\n    foreach ($file as $lineNumber => $line) {\n        if(strpos($line, $hit) !== false){\n            unset($file[$lineNumber]);\n            break;\n        }\n    }\n    file_put_contents($filename, $file);\n    return $output;\n}\n\nfunction get_category_id($name){\n    global $modx;\n    $category = $modx->getObject(\'modCategory\', array(\'category\' => $name));\n    $category_id = isset($category) ? $category->get(\'id\') : 0;\n    return $category_id;\n}\n\nfunction create_category($name, $parent_id = 0){\n    global $modx;\n    $category = $modx->getObject(\'modCategory\', array(\'category\' => $name));\n    // If the category doesn\'t exist create it\n    if(!isset($category)){\n        $category = $modx->newObject(\'modCategory\');\n        $category->set(\'category\', $name);\n    }\n    $category->set(\'parent\', $parent_id);\n    $category->save();\n    return $category;\n}\n\nfunction setCategories($cats){\n    $parentcat = 0;\n    foreach ($cats as $cat) {\n        $newcat = create_category($cat, $parentcat);\n        $parentcat = $newcat->get(\'id\');\n    }\n}\n\nfunction getFiles($directory, $exempt = array(\'.\', \'..\', \'.ds_store\', \'.svn\'), &$files = array()){\n    $handle = opendir($directory);\n    while (false !== ($resource = readdir($handle))) {\n        if(!in_array(strtolower($resource), $exempt)){\n            if(is_dir($directory . $resource)){\n                array_merge($files, getFiles($directory . $resource . \'/\', $exempt, $files));\n            } else {\n                $files[] = $directory . $resource;\n            }\n        }\n    }\n    closedir($handle);\n    return $files;\n}\n\nfunction getDescriptionTime($desc){\n    $l = strrpos($desc, \"-\");\n    if($l > 0){\n        return substr($desc, $l + 2);\n    } else {\n        return false;\n    }\n}\n\nfunction getDescription($desc){\n    $l = strrpos($desc, \"-\");\n    if($l > 0){\n        return substr($desc, 0, $l);\n    } else {\n        return $desc;\n    }\n}\n\nfunction createElement($data){\n    global $modx;\n    global $debug;\n\n    if($debug){\n        $modx->log(xPDO::LOG_LEVEL_INFO, \'createElement=> \' . $data[\"name\"] . \' ,type= \' . $data[\"type\"] . \' ,categorie= \' . $data[\"categorie\"]);\n    }\n    switch (strtolower($data[\"type\"])) {\n        case \'chunk\':\n            $obj = $modx->getObject(\'modChunk\', array(\'name\' => $data[\"name\"]));\n            if($obj){\n                $obj = (getDescriptionTime($obj->get(\'description\')) == filemtime($data[\'file\'])) ? NULL : $obj;\n            } else {\n                $obj = $modx->newObject(\'modChunk\');\n                $obj->set(\'name\', $data[\"name\"]);\n            }\n            break;\n        case \'snippet\':\n            $obj = $modx->getObject(\'modSnippet\', array(\'name\' => $data[\"name\"]));\n            if($obj){\n                $obj = (getDescriptionTime($obj->get(\'description\')) == filemtime($data[\'file\'])) ? NULL : $obj;\n\n            } else {\n                $obj = $modx->newObject(\'modSnippet\');\n                $obj->set(\'name\', $data[\"name\"]);\n            }\n            break;\n        case \'template\':\n            $obj = $modx->getObject(\'modTemplate\', array(\'templatename\' => $data[\"name\"]));\n            if($obj){\n                $obj = (getDescriptionTime($obj->get(\'description\')) == filemtime($data[\'file\'])) ? NULL : $obj;\n            } else {\n                $obj = $modx->newObject(\'modTemplate\');\n                $obj->set(\'templatename\', $data[\"name\"]);\n            }\n            break;\n        case \'plugin\':\n            $obj = $modx->getObject(\'modPlugin\', array(\'name\' => $data[\"name\"]));\n            if($obj){\n                $obj = (getDescriptionTime($obj->get(\'description\')) == filemtime($data[\'file\'])) ? NULL : $obj;\n            } else {\n                $obj = $modx->newObject(\'modPlugin\');\n                $obj->set(\'name\', $data[\"name\"]);\n            }\n            break;\n    }\n\n    if($obj){\n        $f = str_replace($modx->config[\'base_path\'], \"\", $data[\"file\"]);\n        $obj->set(\'static\', 1);\n        $obj->set(\'source\', 0);\n        $obj->set(\'static_file\', $f);\n        $obj->set(\'category\', $data[\'cat\']);\n        $desc = getDescription($obj->get(\'description\'));\n\n        if(isset($data[\'description\'])){\n            $obj->set(\'description\', $data[\'description\'] . \" - \" . filemtime($data[\'file\']));\n        } else {\n            $obj->set(\'description\', $desc . \" - \" . filemtime($data[\'file\']));\n        }\n\n        $modx->log(xPDO::LOG_LEVEL_INFO, \'--- Save \' . $data[\"name\"]);\n\n        $obj->setContent(file_get_contents($data[\"file\"]));\n        if($obj->save()){\n            // $modx->cacheManager->refresh();\n            return $data[\"type\"] . \": \" . $data[\"name\"] . \' created <br>\';\n        } else {\n            if($debug){\n                $modx->log(xPDO::LOG_LEVEL_INFO, \'FAIL Element=> \' . $data[\"name\"]);\n            }\n            return \'fail\';\n        }\n    }\n}\n\n//==============================================\nfunction deleteElement($data){\n    global $modx;\n    switch ($data[\"type\"]) {\n        case \'chunk\':\n            $obj = $modx->getObject(\'modChunk\', array(\'name\' => $data[\"name\"]));\n            break;\n        case \'snippet\':\n            $obj = $modx->getObject(\'modSnippet\', array(\'name\' => $data[\"name\"]));\n            break;\n        case \'template\':\n            $obj = $modx->getObject(\'modTemplate\', array(\'templatename\' => $data[\"name\"]));\n            break;\n    }\n    if($obj){\n        if($obj->remove() == false){\n            return \'An error occurred while trying to remove \' . $data[\"name\"];\n        } else {\n            return $data[\"name\"] . \' DELETED <br>\';\n        }\n    }\n}',0,'a:0:{}',0,'',1,'staticScripts/plugins/registerElements.php'),(2,0,0,'TinyMCERTE','',0,1,0,'/**\n * Tiny�fI������fI���������������������`,A�������������0*A������fI��������������fI������@�������fI�������������tion(\'core_path\', null, MODX_CORE_PATH) . \'components/tinymcerte/\');\n/** @var TinyMCERTE $tinymcerte */\n$tinymcerte = $modx->getService(\n    \'tinymcerte\',\n    \'TinyMCERTE\',\n    $corePath . \'model/tinymcerte/\',\n    array(\n        \'core_path\' => $corePath\n    )\n);\n\n$className = \'TinyMCERTE\' . $modx->event->name;\n$modx->loadClass(\'TinyMCERTEPlugin\', $tinymcerte->getOption(\'modelPath\') . \'tinymcerte/events/\', true, true);\n$modx->loadClass($className, $tinymcerte->getOption(\'modelPath\') . \'tinymcerte/events/\', true, true);\nif (class_exists($className)) {\n    /** @var TinyMCERTEPlugin $handler */\n    $handler = new $className($modx, $scriptProperties);\n    $handler->run();\n}\nreturn;',0,'a:0:{}',0,'',0,''),(3,0,0,'Collections','',0,4,0,'/**\n * Collections\n *\n * DESCRIPTION\n *\n * This plugin inject JS to handle proper working of close buttons in Resource\'s panel (OnDocFormPrerender)\n * This plugin handles setting proper show_in_tree parameter (OnBeforeDocFormSave, OnResourceSort)\n *\n * @var modX $modx\n * @var array $scriptProperties\n */\n$corePath = $modx->getOption(\'collections.core_path\', null, $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/collections/\');\n/** @var Collections $collections */\n$collections = $modx->getService(\n    \'collections\',\n    \'Collections\',\n    $corePath . \'model/collections/\',\n    array(\n        \'core_path\' => $corePath\n    )\n);\n\nif (!($collections instanceof Collections)) return \'\';\n\n$className = \"\\\\Collections\\\\Events\\\\{$modx->event->name}\";\nif (class_exists($className)) {\n    /** @var \\Collections\\Events\\Event $handler */\n    $handler = new $className($modx, $scriptProperties);\n    $handler->run();\n}\n\nreturn;',0,'a:0:{}',0,'',0,''),(4,0,0,'ImagePlus','Image+ runtime hooks - registers custom TV input & output types and includes javascripts on document edit pages.',0,7,0,'/**\n * Image+ runtime hooks\n * Registers custom TV input & output types and includes javascripts on document\n * edit pages so that the TV can be used from within other extras (i.e. MIGX,\n * Collections)\n *\n * Copyright 2013-2015 by Alan Pich <alan.pich@gmail.com>\n * Copyright 2015-2018 by Thomas Jakobi <thomas.jakobi@partout.info>\n *\n * @package imageplus\n * @subpackage plugin\n *\n * @author Alan Pich <alan.pich@gmail.com>\n * @author Thomas Jakobi <thomas.jakobi@partout.info>\n * @copyright Alan Pich 2013-2015\n * @copyright Thomas Jakobi 2015-2018\n *\n * @event OnManagerPageBeforeRender\n * @event OnTVInputRenderList\n * @event OnTVOutputRenderList\n * @event OnTVInputPropertiesList\n * @event OnTVOutputRenderPropertiesList\n * @event OnDocFormRender\n *\n * @var modX $modx\n */\n\n$eventName = $modx->event->name;\n\n$corePath = $modx->getOption(\'imageplus.core_path\', null, $modx->getOption(\'core_path\') . \'components/imageplus/\');\n/** @var ImagePlus $imageplus */\n$imageplus = $modx->getService(\'imageplus\', \'ImagePlus\', $corePath . \'model/imageplus/\', array(\n    \'core_path\' => $corePath\n));\n\nswitch ($eventName) {\n    case \'OnManagerPageBeforeRender\':\n        $modx->controller->addLexiconTopic(\'imageplus:default\');\n        $imageplus->includeScriptAssets();\n        break;\n    case \'OnTVInputRenderList\':\n        $modx->event->output($corePath . \'elements/tv/input/\');\n        break;\n    case \'OnTVOutputRenderList\':\n        $modx->event->output($corePath . \'elements/tv/output/\');\n        break;\n    case \'OnTVInputPropertiesList\':\n        $modx->event->output($corePath . \'elements/tv/input/options/\');\n        break;\n    case \'OnTVOutputRenderPropertiesList\':\n        $modx->event->output($corePath . \'elements/tv/output/options/\');\n        break;\n    case \'OnDocFormRender\':\n        $imageplus->includeScriptAssets();\n        break;\n};',0,'a:0:{}',0,'',0,''),(5,0,0,'phpThumbOfCacheManager','Handles cache cleaning when clearing the Site Cache.',0,8,0,'/*\n * Handles cache cleanup\n * pThumb\n * Copyright 2013 Jason Grant\n *\n * Please see the GitHub page for documentation or to report bugs:\n * https://github.com/oo12/phpThumbOf\n *\n * pThumb is free software; you can redistribute it and/or modify it\n * under the terms of the GNU General Public License as published by the Free\n * Software Foundation; either version 2 of the License, or (at your option) any\n * later version.\n *\n * pThumb is distributed in the hope that it will be useful, but WITHOUT ANY\n * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n * A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License along with\n * phpThumbOf; if not, write to the Free Software Foundation, Inc., 59 Temple\n * Place, Suite 330, Boston, MA 02111-1307 USA\n */\n\nif ($modx->event->name === \'OnSiteRefresh\') {\n	if (!$modx->loadClass(\'pThumbCacheCleaner\', MODX_CORE_PATH . \'components/phpthumbof/model/\', true, true)) {\n		$modx->log(modX::LOG_LEVEL_ERROR, \'[pThumb] Could not load pThumbCacheCleaner class.\');\n		return;\n	}\n	static $pt_settings = array();\n	$pThumb = new pThumbCacheCleaner($modx, $pt_settings, array(), true);\n	$pThumb->cleanCache();\n}',0,NULL,0,'',0,''),(6,0,0,'ContentBlocks','The main plugin for ContentBlocks, responsible for handling generating the form as well as saving the resource. (Part of ContentBlocks)',0,12,0,'/**\n * ContentBlocks\n *\n * Events: OnDocFormRender, OnDocFormSave\n *\n * @package contentblocks\n */\n\n$corePath = $modx->getOption(\'contentblocks.core_path\', null, $modx->getOption(\'core_path\') . \'components/contentblocks/\');\n$assetsUrl = $modx->getOption(\'contentblocks.assets_url\', null, $modx->getOption(\'assets_url\') . \'components/contentblocks/\');\n\n/**\n * @var ContentBlocks $ContentBlocks\n * @var modResource $resource\n * @var modX $modx\n * @var array $scriptProperties\n */\n$ContentBlocks = $modx->getService(\'contentblocks\', \'ContentBlocks\', $corePath . \'model/contentblocks/\');\n\nswitch ($modx->event->name) {\n    case \'OnDocFormPrerender\':\n        if ($modx->controller && isset($modx->controller->resource) && $modx->controller->resource instanceof modResource) {\n            $resource = $modx->controller->resource;\n            $ContentBlocks->setResource($modx->controller->resource);\n        }\n        else {\n            return;\n        }\n\n        // Default settings\n        $disabled = (int)$modx->getOption(\'contentblocks.disabled\', null, false);\n        $acceptedResourceTypes = $modx->getOption(\'contentblocks.accepted_resource_types\', null, \'modDocument,mgResource\');\n\n        // Fake the wctx variable for loading the working context to get settings\n        if (!isset($_GET[\'wctx\'])) $_GET[\'wctx\'] = $resource->get(\'context_key\');\n\n        // If we got the working context, get some settings\n        if ($modx->controller->loadWorkingContext()) {\n            $disabled = (int)$modx->controller->workingContext->getOption(\'contentblocks.disabled\', $disabled);\n            $acceptedResourceTypes = $modx->controller->workingContext->getOption(\'contentblocks.accepted_resource_types\', $acceptedResourceTypes);\n        }\n\n        // Check if we\'re using an allowed resource type\n        $acceptedType = false;\n        $acceptedResourceTypes = explode(\',\', $acceptedResourceTypes);\n        foreach ($acceptedResourceTypes as $type) {\n            if ($resource instanceof $type) $acceptedType = true;\n        }\n\n        // If contentblocks is disabled or this is not an accepted resource, we can stop here.\n        if ($disabled || !$acceptedType) return;\n\n        // Load the lexicon\n        $modx->controller->addLexiconTopic(\'contentblocks:default\');\n        $isContentBlocks = $resource->getProperty(\'_isContentBlocks\', \'contentblocks\', null);\n\n        // Load the use_contentblocks setting\n        if ($ContentBlocks->getOption(\'contentblocks.show_resource_option\', null, true)) {\n            $modx->controller->addJavascript($assetsUrl . \'cmp/js/widgets/booleancombo.js\');\n            $settingChunk = $modx->newObject(\'modChunk\', array(\n                \'content\' => file_get_contents($corePath . \'templates/setting.tpl\')\n            ));\n\n            $modx->controller->addHtml($settingChunk->process(array(\n                \'value\' => ($isContentBlocks !== false) ? \'1\' : \'0\'\n            )));\n        }\n\n        // Halt if we\'re not using contentblocks here\n        if ($isContentBlocks === false) {\n            // we\'re done here\n            return;\n        }\n\n        // Prepare the content\n        $contents = array();\n        if ($isContentBlocks) {\n            // When reloading, the contentblocks field will contain the JSON data\n            $contents = $resource->get(\'contentblocks\');\n            if (empty($contents)) {\n                // If it\'s empty, we get the data from the resource property instead\n                $contents = $resource->getProperty(\'content\', \'contentblocks\');\n            }\n\n            // Try to decode the JSON\n            $contents = $modx->fromJSON($contents);\n        }\n\n        if (!is_array($contents) || empty($contents)) {\n            $content = $resource->get(\'content\');\n            $contents = $ContentBlocks->getDefaultCanvas(false, $content);\n        }\n\n        // Generate a wrapper class to apply, so we can target stuff in CSS\n        $wrapperCls = array();\n        $wrapperCls[] = \'type_\' . strtolower($resource->get(\'class_key\'));\n        $wrapperCls[] = \'position_\' . $ContentBlocks->config[\'canvas_position\'];\n        $modxVersion = $modx->getVersionData();\n        if (version_compare($modxVersion[\'full_version\'], \'2.3.0-dev\', \'>=\')) {\n            $wrapperCls[] = \'modx_v23\';\n        }\n        if (version_compare($modxVersion[\'full_version\'], \'3.0.0-dev\', \'>=\')) {\n            $wrapperCls[] = \'modx_v30\';\n        }\n        $wrapperCls = implode(\' \', $wrapperCls);\n\n        // Grab objects for building the canvas\n        $objects = $ContentBlocks->getObjectsForCanvas($resource);\n        $categories = $modx->toJSON($objects[\'categories\']);\n        $fields = $modx->toJSON($objects[\'fields\']);\n        $layouts = $modx->toJSON($objects[\'layouts\']);\n        $templates = $modx->toJSON($objects[\'templates\']);\n\n        $contents = $modx->toJSON($contents);\n        $resourceInfo = $modx->toJSON($resource->get(array(\'id\', \'pagetitle\', \'context_key\')));\n        $config = $modx->toJSON($ContentBlocks->config);\n\n        $modx->controller->addHtml(<<<HTML\n<script type=\"text/javascript\">\n    var ContentBlocksCategories = $categories,\n        ContentBlocksFields = $fields,\n        ContentBlocksLayouts = $layouts,\n        ContentBlocksTemplates = $templates,\n        ContentBlocksContents = $contents,\n        ContentBlocksConfig = $config,\n        ContentBlocksWrapperCls = \"$wrapperCls\",\n        ContentBlocksResource = $resourceInfo;\n\n    var cbGenerated = false,\n        ContentBlocksWillRenderContent = true;\n    MODx.on(\'ready\', function () {\n        // Prevent double-generation\n        if (cbGenerated) return;\n        cbGenerated = true;\n\n        ContentBlocks.render();\n\n        // Hook up to beforesubmit to fetch the values and fetch the content blocks\n        Ext.getCmp(\'modx-panel-resource\').on(\'beforesubmit\', function(o) {\n            o.form.baseParams[\'contentblocks\'] = ContentBlocks.getData();\n        });\n    });\n</script>\nHTML\n        );\n        $scriptTags = $ContentBlocks->getAssets();\n        $modx->controller->addHtml($scriptTags);\n\n        break;\n\n    case \'OnDocFormSave\':\n        $ContentBlocks->setResource($resource);\n        $modx->resource = $resource;\n\n        $cbJson = $resource->get(\'contentblocks\');\n\n        $cbContent = $modx->fromJSON($cbJson);\n\n        // RenderContent Event\n        $response = $modx->invokeEvent(\'ContentBlocks_RenderContent\', array(\n            \'cbContent\' => $cbContent,\n            \'cbJson\' => $cbJson,\n            \'resource\' => $resource\n        ));\n        // check if customized content was returned\n        if (!empty($response) && is_array($response) && json_encode($response) !== \'[\"\"]\') {\n            $cbContent = $response[0][\'cbContent\'];\n            $cbJson = $response[0][\'cbJson\'];\n        }\n\n        if (!empty($cbJson) && $cbContent !== false && is_array($cbContent)) {\n            $summary = $ContentBlocks->summarizeContent($cbContent);\n            $resource->setProperties(array(\n                \'content\' => $cbJson,\n                \'linear\' => $summary[\'linear\'],\n                \'fieldcounts\' => $summary[\'fieldcounts\'],\n                \'_isContentBlocks\' => true,\n            ), \'contentblocks\', true);\n\n            // We save the CB data as soon as possible ...\n            $resource->save();\n            // ... then we parse it to HTML which is stored in the content ...\n            try {\n                $ContentBlocks->loadParser();\n                $resource->setContent($ContentBlocks->generateHtml($cbContent));\n                $ContentBlocks->restoreParser();\n            } catch (Exception $e) {\n                $modx->log(modX::LOG_LEVEL_ERROR, \'Exception while trying to parse the content of resource \' . $resource->id . \': \' . $e->getMessage());\n            }\n            // ... to make sure parse errors don\'t lose the content.\n        }\n        $resource->set(\'contentblocks\', \'\');\n\n        // Make sure we need to continue to use contentblocks\n        $useCb = $resource->get(\'use_contentblocks\');\n        if (in_array($useCb, array(\'0\', \'1\'), true)) {\n            $resource->setProperty(\'_isContentBlocks\', (bool)$useCb, \'contentblocks\');\n        }\n        $resource->save();\n        break;\n\n    /**\n     * @var string $path\n     */\n    case \'OnFileManagerFileRename\':\n        $ContentBlocks->renames[] = $path;\n        break;\n}\n\nreturn;',0,NULL,0,'',0,''),(7,1,0,'pdoTools','',0,17,0,'/** @var modX $modx */\nswitch ($modx->event->name) {\n\n    case \'OnMODXInit\':\n        $fqn = $modx->getOption(\'pdoTools.class\', null, \'pdotools.pdotools\', true);\n        $path = $modx->getOption(\'pdotools_class_path\', null, MODX_CORE_PATH . \'components/pdotools/model/\', true);\n        $modx->loadClass($fqn, $path, false, true);\n\n        $fqn = $modx->getOption(\'pdoFetch.class\', null, \'pdotools.pdofetch\', true);\n        $path = $modx->getOption(\'pdofetch_class_path\', null, MODX_CORE_PATH . \'components/pdotools/model/\', true);\n        $modx->loadClass($fqn, $path, false, true);\n        break;\n\n    case \'OnSiteRefresh\':\n        /** @var pdoTools $pdoTools */\n        if ($pdoTools = $modx->getService(\'pdoTools\')) {\n            if ($pdoTools->clearFileCache()) {\n                $modx->log(modX::LOG_LEVEL_INFO, $modx->lexicon(\'refresh_default\') . \': pdoTools\');\n            }\n        }\n        break;\n\n    case \'OnWebPagePrerender\':\n        $parser = $modx->getParser();\n        if ($parser instanceof pdoParser) {\n            foreach ($parser->pdoTools->ignores as $key => $val) {\n                $modx->resource->_output = str_replace($key, $val, $modx->resource->_output);\n            }\n        }\n        break;\n}',0,NULL,0,'',0,'core/components/pdotools/elements/plugins/plugin.pdotools.php'),(8,1,0,'turnoff CB','',0,0,0,'$eventName = $modx->event->name;\nswitch($eventName) {\n    case \'OnDocFormPrerender\':\n        $resource = $modx->controller->resource;\n        $disabled = false;\n        $disabledTemplates = array(6);\n        if (in_array($resource->get(\'template\'), $disabledTemplates)) {\n            $disabled = true;\n        }\n        if ($disabled) {\n            $resource->setProperty(\'_isContentBlocks\', false, \'contentblocks\');\n        }\n    break; \n}',0,'a:0:{}',0,'',0,''),(9,0,0,'Tagger','',0,24,0,'/**\n * Tagger\n *\n * DESCRIPTION\n *\n * This plugin inject JS to add Tab with tag groups into Resource panel\n */\n\n$corePath = $modx->getOption(\'tagger.core_path\', null, $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/tagger/\');\n/** @var Tagger $tagger */\n$tagger = $modx->getService(\n    \'tagger\',\n    \'Tagger\',\n    $corePath . \'model/tagger/\',\n    array(\n        \'core_path\' => $corePath\n    )\n);\n\n$className = \'Tagger\' . $modx->event->name;\n$modx->loadClass(\'TaggerPlugin\', $tagger->getOption(\'modelPath\') . \'tagger/events/\', true, true);\n$modx->loadClass($className, $tagger->getOption(\'modelPath\') . \'tagger/events/\', true, true);\n\nif (class_exists($className)) {\n    /** @var TaggerPlugin $handler */\n    $handler = new $className($modx, $scriptProperties);\n    $handler->run();\n}\n\nreturn;',0,'a:0:{}',0,'',0,''),(10,0,0,'XRouting','XRouting is a simple plugin that handles requests for different contexts. It automatically switches the context based on a (sub)domain AND/OR subfolder.',0,0,0,'switch ($modx->event->name) {\n\n    // \"refresh cache\" part\n    case \'OnContextSave\':\n    case \'OnContextRemove\':\n    case \'OnSiteRefresh\':\n        \n        $contexts = array();\n        $cacheKey = \'xrouting_contextmap\';\n        $cacheOptions = array();\n        \n        // build context array\n        $query = $modx->newQuery(\'modContext\');\n        $query->where(array(\'modContext.key:NOT IN\' => array(\'mgr\')));\n        $query->sortby($modx->escape(\'modContext\') . \'.\' . $modx->escape(\'key\'), \'DESC\');\n        $contextsGraph = $modx->getCollectionGraph(\'modContext\', \'{\"ContextSettings\":{}}\', $query);\n        \n        foreach ($contextsGraph as $context) {\n            $contextSettings = array();\n            foreach ($context->ContextSettings as $cSetting) {\n                $contextSettings[$cSetting->get(\'key\')] = $cSetting->get(\'value\');\n            }\n            \n            if (!empty($contextSettings[\'http_host\']) && !empty($contextSettings[\'base_url\'])) {\n                \n                // add http_host to hosts list\n                $contexts[\'_hosts\'][$contextSettings[\'http_host\']][] = $context->get(\'key\');\n                \n                // add alias hosts to host list\n                if (!empty($contextSettings[\'http_host_aliases\'])) {\n                    foreach (explode(\',\',$contextSettings[\'http_host_aliases\']) as $alias) {\n                        $contexts[\'_hosts\'][$alias][] = $context->get(\'key\');\n                    }\n                }\n                \n                // add context settings\n                $contexts[$context->get(\'key\')] = $contextSettings;\n            }\n        }\n         \n        unset($contextsGraph);\n        $modx->cacheManager->set($cacheKey, $contexts, 0, $cacheOptions);\n    break;\n    \n    \n    // \"routing\" part\n    default:\n    case \'OnHandleRequest\':\n        if ($modx->context->get(\'key\') == \'mgr\') return;\n            \n        $contexts = array();\n        \n        $cacheKey = \'xrouting_contextmap\';\n        $cacheOptions = array();\n        $contexts = $modx->cacheManager->get($cacheKey, $cacheOptions);\n        \n        if (empty($contexts)) {\n        // build context array\n            $query = $modx->newQuery(\'modContext\');\n            $query->where(array(\'modContext.key:NOT IN\' => array(\'mgr\')));\n            $query->sortby($modx->escape(\'modContext\') . \'.\' . $modx->escape(\'key\'), \'DESC\');\n            $contextsGraph = $modx->getCollectionGraph(\'modContext\', \'{\"ContextSettings\":{}}\', $query);\n            \n            foreach ($contextsGraph as $context) {\n                $contextSettings = array();\n                foreach ($context->ContextSettings as $cSetting) {\n                    $contextSettings[$cSetting->get(\'key\')] = $cSetting->get(\'value\');\n                }\n                \n                if (!empty($contextSettings[\'http_host\']) && !empty($contextSettings[\'base_url\'])) {\n                    \n                    // add http_host to hosts list\n                    $contexts[\'_hosts\'][$contextSettings[\'http_host\']][] = $context->get(\'key\');\n                    \n                    // add alias hosts to host list\n                    if (!empty($contextSettings[\'http_host_aliases\'])) {\n                        foreach (explode(\',\',$contextSettings[\'http_host_aliases\']) as $alias) {\n                            $contexts[\'_hosts\'][$alias][] = $context->get(\'key\');\n                        }\n                    }\n                    \n                    // add context settings\n                    $contexts[$context->get(\'key\')] = $contextSettings;\n                }\n            }\n                         \n            unset($contextsGraph);\n            $modx->cacheManager->set($cacheKey, $contexts, 0, $cacheOptions);\n        }\n\n\n        if (!empty($contexts)) {\n            $http_host = $_SERVER[\'HTTP_HOST\'];\n            if ($modx->getOption(\'xrouting.include_www\', null, true)) {\n                $http_host = str_replace(\'www.\',\'\',$http_host);\n            }\n            \n            $modx_base_url = $modx->getOption(\'base_url\', null, MODX_BASE_URL);\n            $requestUrl = str_replace(\'//\',\'/\',$modx_base_url.$_REQUEST[$modx->getOption(\'request_param_alias\', null, \'q\')]);\n            $matches = array();\n            \n            \n        // find matching hosts\n            $matched_contexts = $contexts[\'_hosts\'][$http_host];\n            \n            \n            foreach ((array) $matched_contexts as $index => $ckey) {\n                \n                $context = $contexts[$ckey];\n                $strpos = strpos($requestUrl, $contexts[$ckey][\'base_url\']);\n                if ($strpos === 0) {\n                    $matches[strlen($contexts[$ckey][\'base_url\'])] = $ckey;\n                }\n            }\n\n        // modify request for the matched context\n            if (!empty($matches)) {\n                \n                $cSettings = $contexts[$matches[max(array_keys($matches))]];\n                $cKey = $matches[max(array_keys($matches))];\n                \n                // do we need to switch the context?\n                if ($modx->context->get(\'key\') != $cKey) {\n                    $modx->switchContext($cKey);\n                }\n                \n                // remove base_url from request query\n                if ($cSettings[\'base_url\'] != $modx_base_url) {\n                    $newRequestUrl = str_replace($cSettings[\'base_url\'],\'\',$requestUrl);\n                    $_REQUEST[$modx->getOption(\'request_param_alias\', null, \'q\')] = $newRequestUrl;\n                }\n                \n                \n            } else if ($_REQUEST[\'xrouting-debug\'] != \'1\' || !$modx->getOption(\'xrouting.allow_debug_info\', null, false)) {\n                // if no match found\n                if ($modx->getOption(\'xrouting.show_no_match_error\', null, true)) {\n                    $modx->sendErrorPage();\n                } else {\n                    $modx->switchContext($modx->getOption(\'xrouting.default_context\', null, \'web\'));\n                }\n                \n            }\n        \n        // output debug info\n            if ($_REQUEST[\'xrouting-debug\'] == \'1\' && $modx->getOption(\'xrouting.allow_debug_info\', null, false)) {\n                $debuginfo = \'<pre>\';\n                $debuginfo .= \"## MODX context map:\\n\\n\" . print_r($contexts,true) . \"\\n\\n\\n\";\n                $debuginfo .= \"## Requested URL: \" . $_REQUEST[$modx->getOption(\'request_param_alias\', null, \'q\')] . \"\\n\\n\\n\";\n                $debuginfo .= \"## Requested URL with base_url: \". $requestUrl .\"\\n\\n\\n\";\n                $debuginfo .= \"## Matched context(s) (Array key defines match quality):\\n\\n\" . print_r($matches,true) . \"\\n\\n\\n\";\n                $debuginfo .= \"## Request will go to context: \" . $matches[max(array_keys($matches))] . \"\\n\\n\\n\";\n                $debuginfo .= \"## Modified request URL: \" . $newRequestUrl . \"\\n\\n\\n\";\n                die($debuginfo);\n            }\n        }\n    break;\n}',0,NULL,0,'',0,''),(12,0,0,'ClientConfig','Sets system settings from the Client Config CMP.',0,0,0,'/**\n * ClientConfig\n *\n * Copyright 2011-2014 by Mark Hamstra <hello@markhamstra.com>\n *\n * ClientConfig is free software; you can redistribute it and/or modify it under the\n * terms of the GNU General Public License as published by the Free Software\n * Foundation; either version 2 of the License, or (at your option) any later\n * version.\n *\n * ClientConfig is distributed in the hope that it will be useful, but WITHOUT ANY\n * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n * A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License along with\n * ClientConfig; if not, write to the Free Software Foundation, Inc., 59 Temple\n * Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * @package clientconfig\n *\n * @var modX $modx\n * @var int $id\n * @var string $mode\n * @var modResource $resource\n * @var modTemplate $template\n * @var modTemplateVar $tv\n * @var modChunk $chunk\n * @var modSnippet $snippet\n * @var modPlugin $plugin\n*/\n\n$eventName = $modx->event->name;\n\nswitch($eventName) {\n    case \'OnMODXInit\':\n    case \'OnHandleRequest\':\n    case \'pdoToolsOnFenomInit\':\n        /* Grab the class */\n        $path = $modx->getOption(\'clientconfig.core_path\', null, $modx->getOption(\'core_path\') . \'components/clientconfig/\');\n        $path .= \'model/clientconfig/\';\n        $clientConfig = $modx->getService(\'clientconfig\',\'ClientConfig\', $path);\n\n        /* If we got the class (gotta be careful of failed migrations), grab settings and go! */\n        if ($clientConfig instanceof ClientConfig) {\n            $contextKey = $modx->context instanceof modContext ? $modx->context->get(\'key\') : \'web\';\n            $settings = $clientConfig->getSettings($contextKey);\n\n            /* Make settings available as [[++tags]] */\n            $modx->setPlaceholders($settings, \'+\');\n\n            /* Make settings available for $modx->getOption() */\n            foreach ($settings as $key => $value) {\n                $modx->setOption($key, $value);\n            }\n        }\n        break;\n}\n\nreturn;',0,NULL,0,'',0,'');

Any idea why?

tnx
RDG

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions