1

Upgrading from 5.27.2 to 5.45.1 on Drupal 9.3.2, used civicrm_drush module, also tried with UI.

Getting following Error:

log file details

    [info] Running task: Update legacy prefix id token in greetings (use {contact.prefix_id:label})

    [info] Civi\API\Exception\NotImplementedException: "API (OptionValue, getFields) does not exist (join the API team and implement it!)"
    #0 PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractAction.php(437): Civi\API\Request::create("OptionValue", "getFields", (Array:4))
    #1 PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractGetAction.php(44): Civi\Api4\Generic\AbstractAction->entityFields()
    #2 PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/Api4/Generic/DAOGetAction.php(97): Civi\Api4\Generic\AbstractGetAction->setDefaultWhereClause()
    #3 PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/Api4/Provider/ActionObjectProvider.php(68): Civi\Api4\Generic\DAOGetAction->_run(Object(Civi\Api4\Generic\Result))
    #4 PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(149): Civi\Api4\Provider\ActionObjectProvider->invoke(Object(Civi\Api4\Generic\DAOGetAction))
    #5 PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractAction.php(234): Civi\API\Kernel->runRequest(Object(Civi\Api4\Generic\DAOGetAction))
    #6 PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Upgrade/Incremental/MessageTemplates.php(420): Civi\Api4\Generic\AbstractAction->execute()
    #7 PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Upgrade/Incremental/Base.php(320): CRM_Upgrade_Incremental_MessageTemplates->replaceTokenInGreetingOptions("contact.prefix_id", "contact.prefix_id:label")
    #8 PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Queue/Task.php(74): CRM_Upgrade_Incremental_Base::updateGreetingOptions(Object(CRM_Queue_TaskContext), "contact.prefix_id", "contact.prefix_id:label", "5.43.alpha1")
    #9 PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Queue/Runner.php(201): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
    #10 PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Queue/Runner.php(155): CRM_Queue_Runner->runNext()
    #11 PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Upgrade/Headless.php(49): CRM_Queue_Runner->runAll()
    #12 PATH/distro9.test/web/modules/contrib/civicrm_drush/src/Commands/CivicrmDrushCommands.php(435): CRM_Upgrade_Headless->run()
    #13 [internal function](): Drupal\civicrm_drush\Commands\CivicrmDrushCommands->drushCivicrmUpgradeDb((Array:20))
    #14 PATH/distro9.test/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array((Array:2), (Array:1))
    #15 PATH/distro9.test/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback((Array:2), Object(Consolidation\AnnotatedCommand\CommandData))
    #16 PATH/distro9.test/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter((Array:3), (Array:2), Object(Consolidation\AnnotatedCommand\CommandData))
    #17 PATH/distro9.test/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(350): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), (Array:3), (Array:2), Object(Consolidation\AnnotatedCommand\CommandData))
    #18 PATH/distro9.test/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #19 PATH/distro9.test/vendor/symfony/console/Application.php(1027): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #20 PATH/distro9.test/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #21 PATH/distro9.test/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

same issue with dashboard, look like its related getFields action.


i thought, lets try upto 5.41.2, Upgrade went smooth using drush.

While loading civicrm, i am getting Authorization failed error. (mostly on dashboard, api4 with permission check).

    $Fatal Error Details = array:3 [
      "message" => "Authorization failed"
      "code" => null
      "exception" => Civi\API\Exception\UnauthorizedException {#3157
        -extraParams: array:1 [
          "error_code" => "unauthorized"
        ]
        #message: "Authorization failed"
        #code: 0
        #file: "PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/API/Kernel.php"
        #line: 223
        trace: {
          PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/API/Kernel.php:223 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/API/Kernel.php:147 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/Civi/Api4/Generic/AbstractAction.php:234 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/api/api.php:85 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Core/BAO/Dashboard.php:69 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Contact/Page/DashBoard.php:52 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php:313 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php:69 { …}
          PATH/distro9.test/vendor/civicrm/civicrm-core/CRM/Core/Invoke.php:36 { …}
          PATH/distro9.test/web/modules/contrib/civicrm/src/Civicrm.php:88 {
            Drupal\civicrm\Civicrm->invoke($args)
            › ob_start();
            › $content = \CRM_Core_Invoke::invoke($args);
            › $output = ob_get_clean();
            arguments: {
              $args: array:1 [ …1]
            }
          }

e.g. Membership Tab

$membershipTypes = \Civi\Api4\MembershipType::get(TRUE)
      ->execute()
      ->indexBy('id')
      ->column('name');

Logged in user have 'administrator` role, and all permission of civicrm are checked.

Also how does https://distro9.test/civicrm/placeholder-url-path?civicrm-placeholder-url-query=1 url get resolved ? i did not see any class mapping.

1
  • For the very last part, the placeholder-url gets replaced in js/crm.ajax.js. For the first error, that's really strange because EVERY api4 entity has to have a getFields function. Api4 used to be a separate extension - does that site have the old extension installed? In any case it would be better if upgrade steps (i.e. replaceTokenInGreetingOptions()) didn't use api calls to avoid this type of thing. That should be improved in that core function I think.
    – Demerit
    Commented Jan 16, 2022 at 15:10

1 Answer 1

0

I noticed this error today, too. What happened?

  1. Upgrade Drupal & CiviCRM to newest version
  2. Deleted everything in /sites/default/files/civicrm/templates_c/
  3. Cleared Drupal cache
  4. But forgot to visit https://yourdomain.tld/civicrm/upgrade.php after all these steps.

Please do a database upgrade (/civicrm/upgrade.php) after you installed new code. I hope this will help you and everybody else with this error message after an upgrade.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.