Search the Community
Showing results for tags 'segmentation fault'.
-
Hi Guys, Im running a script to create a bunch of new pages, but I get a segmentation fault when trying to create/update around 400 pages. function importModels() { echo "Installing Models"; $seriesJson = json_decode(file_get_contents("./metadata/models/models.json")); $templateModel = wire("templates")->get("name=model"); $nodeModels = wire("pages")->get("name=Models, parent=/, include=all"); if (!$seriesJson) { throw new Exception("/metadata/pages/models/models-2.json not found"); } if (!$templateModel) { throw new Exception("Missing template"); } if (!$nodeModels) { throw new Exception("Missing Models node"); } foreach ($seriesJson->models as $modelData) { $modelName = $modelData->{KEY_BODY} . " " . $modelData->{KEY_MODEL_CODE}; $pageCarSelector = "has_parent=Series," . "has_parent!=Trash," . "body_style_id={$modelData->{KEY_BODY}}," . "include=all"; $pageCar = wire("pages")->get($pageCarSelector); if (is_a($pageCar, NullPage)) { throw new Exception("Car not found with body style ID: " . $modelData->{KEY_BODY}); } $pageModel = wire("pages")->get("parent=Models, has_parent!=Trash, template=model, name={$modelName}"); if (is_a($pageModel, NullPage)) { $pageModel = new Page(); $pageModel->set("name", $modelName); $pageModel->set("template", $templateModel); $pageModel->set("parent", $nodeModels); } $pageModel->set("title", $modelData->{KEY_MODEL}); $pageModel->set("mapped_car", $pageCar); $pageModel->set("car_identifier", $modelData->{KEY_MODEL_CODE}); wire("pages")->save($pageModel); echo "."; } echo "\n"; } The problem is not caused by the save, its like wire("pages")->get($pageCarSelector) is doing too much caching. If I add wire("pages")->uncacheAll(); just after the save then it runs a lot further, still eventually breaking. Do you guys have any ideas of any other caches I need to clear to get this working? Many thanks.