When upgrading from before VaultWiki 4.1.3, you may encounter an error like this during the upgrade process:
Code:
ErrorException: Invalid argument supplied for foreach() src/addons/vw/vw/XF/Entity/EntityBase.php:358
#0 src/addons/vw/vw/XF/Entity/EntityBase.php(358): vw\vw\Setup\View->handle_php_error(2, 'Invalid argumen...', '...', 358, Array)
#1 src/addons/vw/vw/_core/controller/dm/xf2.php(138): vw\vw\XF\Entity\EntityBase->vwSetExisting('STRING')
#2 src/addons/vw/vw/_core/controller/dm/revision/vw.php(1096): vw_DM_Controller_XF2->set_existing('STRING')
#3 src/addons/vw/vw/_core/controller/dm/base/vw.php(785): vw_DM_Revision_Controller->set_existing_custom_field(Object(vw_DM_Controller_XF2), Array, Array, 1)
#4 src/addons/vw/vw/_core/controller/dm/revision/vw.php(999): vw_DM_Base_Controller->process_custom_fields()
#5 src/addons/vw/vw/_core/controller/dm/revision/vw.php(1644): vw_DM_Revision_Controller->process_custom_fields()
#6 src/addons/vw/vw/XF/Entity/EntityBase.php(513): vw_DM_Revision_Controller->pre_save(true)
#7 src/XF/Mvc/Entity/Entity.php(1355): vw\vw\XF\Entity\EntityBase->_preSave()
#8 src/addons/vw/vw/XF/Entity/EntityBase.php(504): XF\Mvc\Entity\Entity->preSave()
#9 src/addons/vw/vw/XF/Entity/EntityBase.php(571): vw\vw\XF\Entity\EntityBase->vwPreSave()
#10 src/addons/vw/vw/_core/controller/dm/xf2.php(401): vw\vw\XF\Entity\EntityBase->vwSave()
#11 src/addons/vw/vw/_install/lib/upgradepath/steps/4/1/3/base/vw.php(358): vw_DM_Controller_XF2->save()
#12 src/addons/vw/vw/Setup.php(333): vw_Install_UpgradePath_Steps_413_base_Controller->{closure}(Object(vw\vw\Setup\Caller\Upgrade), false)
#13 src/addons/vw/vw/Setup.php(1062): vw\vw\Setup->vwRunStep('upgrade', Object(vw_Install_UpgradePath_Steps_413_C_Controller_XF2), Array, 7)
#14 src/XF/Admin/Controller/AddOn.php(584): vw\vw\Setup->upgrade(Array)
#15 src/XF/Mvc/Dispatcher.php(350): XF\Admin\Controller\AddOn->actionUpgrade(Object(XF\Mvc\ParameterBag))
#16 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:AddOn', 'Upgrade', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\AddOn), NULL)
#17 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\AddOn), NULL)
#18 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#19 src/XF/App.php(2337): XF\Mvc\Dispatcher->run()
#20 src/XF.php(488): XF\App->run()
#21 admin.php(13): XF::runApp('XF\\Admin\\App')
#22 {main}
The error occurs during a step intended to fix any existing custom field values that have lost synchronization with the current version of the page they belong to. If you encounter this error, it means that some of the custom field values were found to be desynchronized (an issue that occurred in earlier releases), but the upgrade script was unable to resolve the issue.
To fix the error and hopefully succeed in fixing the affected custom fields, you must modify
src/addons/vw/vw/_install/lib/upgradepath/steps/4/1/3/base/vw.php. Find:
Code:
if ($is_template)
{
$alt_values["$fieldid"] = $value['field_value'];
}
else
{
$old_values["$fieldid"] = $value['field_value'];
}
Replace with (please mind the scrollbar):
Code:
$prep = vw_DB::get()->query()->prepare(array(
'r' => array(
'table' => 'vw_revision',
'alias' => 'r',
'fields' => array(
'pageid' => '',
'revisionid' => '',
'dateline' => ''
)
),
'e' => array(
'table' => 'vw_field_revision',
'alias' => 'e',
'fields' => array(
'revisionid' => '',
'fieldeditid' => '',
'field_value_id' => ''
)
)
));
$subedit = vw_DB::get()->query()->select(array(
'fields' => array(
$prep['e']['fields']['revisionid'],
$prep['e']['fields']['fieldeditid']
),
'table' => array('vw_field_revision' => 'e'),
'joins' => array(
array(
'table' => array('vw_revision' => 'r'),
'where' => vw_DB::get()->query()->eq($prep['r']['fields']['revisionid'], $prep['e']['fields']['revisionid'])
)
),
'where' => array(
vw_DB::get()->query()->eq($prep['e']['fields']['field_value_id'], $valueid),
vw_DB::get()->query()->eq($prep['r']['fields']['pageid'], $page['pageid'])
),
'order' => array($prep['r']['fields']['dateline'] => 'DESC'),
'first' => 1
));
if (!$subedit)
{
// last field edit is invalid
continue;
}
$value += array(
'fieldvalueid' => $valueid,
'field_value_id' => $valueid,
'fieldeditid' => $subedit['fieldeditid'],
'fieldid' => $vfieldid,
'template' => $is_template,
'revisionid' => $subedit['revisionid'],
'pageid' => $page['pageid']
);
if ($is_template)
{
$alt_values["$fieldid"] = $value;
}
else
{
$old_values["$fieldid"] = $value;
}