• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 4.x Series
    • Bug
    • Problem Fixing Stale Custom Field Values in 4.1.3 Upgrade Script

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: Problem Fixing Stale Custom Field Values in 4.1.3 Upgrade Script

    • Issue Tools
      • View Comments
    1. issueid=6307 September 6, 2022 10:56 AM
      pegasus pegasus is offline
      VaultWiki Team
      Problem Fixing Stale Custom Field Values in 4.1.3 Upgrade Script

      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;
      								}
    Issue Details
    Issue Number 6307
    Issue Type Bug
    Project VaultWiki 4.x Series
    Category Install / Upgrade
    Status Fixed
    Priority 2 - Fatal / Database Errors
    Affected Version 4.1.3
    Fixed Version 4.1.6
    Milestone (none)
    Software DependencyXenForo 2.x
    License TypePaid
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. September 9, 2022 9:57 AM
      Issue Changed by pegasus
      • Issue marked as addressed
      • Status changed from In Progress to Fixed
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 4:23 AM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2025 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
    Copyright © 2008 - 2024 VaultWiki Team, Cracked Egg Studios, LLC.