The website encountered an unexpected error. Try again later

I’ve had farmos running in the past and have quite a bit of data in it. Something happened over the course of a few updates and now it’s not working. Now that it’s spring and calves are coming, I need to get it working again.

I first noticed I was getting the Access denied problem. When I added the /user to the URL and logged in, I saw this message:

The website encountered an unexpected error. Try again later.

On the console, I saw this error:

[Fri Mar 15 14:16:58.131592 2024] [php:notice] [pid 21] [client 192.168.254.119:55149] Uncaught PHP Exception TypeError: "Drupal\\Core\\Render\\Renderer::doRenderPlaceholder(): Return value must be of type Drupal\\Component\\Render\\MarkupInterface|string, null returned" at /opt/drupal/web/core/lib/Drupal/Core/Render/Renderer.php line 184

This is with a docker install. My compose looks like this:

version: "3"
services:
  www:
    # Update this to the latest stable version before deploying.
    # image: farmos/farmos:latest
    image: farmos/farmos:3.x
    volumes:
      - ./sites:/opt/drupal/web/sites
      - ./modules:/opt/drupal/web/modules/farmos
    ports:
      - 480:80
    restart: always
networks: {}

Modules in the modules directory:

farm_asset_termination
farm_eggs
farm_ledger
farm_nrcs
farm_profile
farm_project_plan
farm_weather
smtp

Suspecting a plugin in that plugin directory, I tried to delete them one at a time using the drush command. Now I’m stuck with this error:

[Fri Mar 15 16:00:56.255328 2024] [php:notice] [pid 19] [client 192.168.254.119:62316] Uncaught PHP Exception Drupal\\Component\\Plugin\\Exception\\PluginNotFoundException: "The "d7_farm_log" plugin does not exist. Valid plugin IDs for Drupal\\migrate\\Plugin\\MigrateSourcePluginManager are: csv_file, embedded_data, empty, url, table, csv" at /opt/drupal/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php line 53, referer: http://192.168.254.208:480/user/login

I need help knowing where to look, or where to go. The database is sqlite3.

1 Like

Hi @tlcarpenter69 - let’s see if we can figure it out…

First thing that jumps out to me is:

image: farmos/farmos:3.x

It’s dangerous to use the 3.x image directly (unless you’re doing development), because you might not know when an update occurs, and it is critical that you run database updates (eg: update.php or drush updb) and rebuild caches (eg: drush cr) when you update from one version of farmOS to the next.

We recommend using a specific version (eg: farmos/farmos:3.1.2) so that you can make your updates an intentional process.

If you haven’t already, please read the full “Updating farmOS” guide: Updating farmOS | farmOS

So maybe my first question is: have you been running drush updb + drush cr with every update?

(Also remember to take a database backup snapshot before each update!!)

Thanks for the feedback. I did switch to using 3.1.2 as part of the troubleshooting, but it didn’t really change. Also, I’ve totally missed the Updating guide. Let me look over that.

Also, if this install is totally borked, I’ve done a fresh install on another server. I’m not opposed to exporting the database from the old install and importing it into a new install.

1 Like

Ah yea… so it could very well be that the database needs to be updated.

You will need to run drush updb either way… because data or database schemas may need to be changed between versions, and that’s what drush updb does. So even if you export and reimport you will want to do that.

I would probably recommend taking a backup of your SQLite3 file right now, and then try running drush updb + drush cr. Maybe it will work smoothly!

Question: did you start on farmOS v3? Or do you think you may have missed the updates between v2 → v3 as well? Those are bigger.

PS: Once you do get it working again, check out the Birth Quick Form module… :wink:

Here is a blog post about it: Birth Quick Form | farmOS

I ran the update.php and I ran the drush commands, at the end I got this:

 [success] No pending updates.
 [notice] Reverted config: core.entity_view_display.asset.animal.map_popup
 [notice] Reverted config: core.entity_view_display.asset.equipment.map_popup
 [notice] Reverted config: core.entity_view_display.asset.land.map_popup
 [notice] Reverted config: core.entity_view_display.asset.plant.map_popup
 [notice] Reverted config: core.entity_view_display.asset.structure.map_popup
 [notice] Reverted config: core.entity_view_mode.asset.map_popup
 [notice] Reverted config: core.entity_view_mode.quantity.plain_text
 [notice] Reverted config: log.type.input
 [notice] Reverted config: log.type.lab_test
 [notice] Reverted config: migrate_plus.migration_group.farm_import_csv
 [notice] Reverted config: plan.type.project
 [notice] Reverted config: system.action.asset_assign_action
 [notice] Reverted config: system.action.asset_parent_action
 [notice] Reverted config: system.action.project_add_log_action
 [notice] Reverted config: user.role.farm_account_admin
 [notice] Reverted config: views.view.farm_asset
 [notice] Reverted config: views.view.farm_asset_geojson
 [notice] Reverted config: views.view.farm_group_members
 [notice] Reverted config: views.view.farm_import_csv_asset
 [notice] Reverted config: views.view.farm_import_csv_log
 [notice] Reverted config: views.view.farm_import_csv_taxonomy_term
 [notice] Reverted config: views.view.farm_inventory
 [notice] Reverted config: views.view.farm_log
 [notice] Reverted config: views.view.farm_people
 [notice] Reverted config: views.view.farm_plan
 [notice] Reverted config: views.view.farm_quantity
 [notice] Reverted config: views.view.log_admin
 [notice] Reverted config: views.view.project_logs
 [notice] Reverted config: views.view.project_plans
 [error]  Drupal\Component\Plugin\Exception\PluginNotFoundException: The "d7_farm_log" plugin does not exist. Valid plugin IDs for Drupal\migrate\Plugin\MigrateSourcePluginManager are: csv_file, embedded_data, empty, url, table, csv in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /opt/drupal/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php). 
 [success] Cache rebuild complete.

Note the d7_farm_log erorr is still there.

1 Like

Just read this… do you mean you ran drush pm-uninstall [module] to uninstall them? Or did you just delete them? Deleting them without installing would cause problems.

Yes, I used drush to delete them. I think I used the shortcut though.
drush pmu shortcut version.

1 Like

Oh OK! So actually maybe you are pretty up-to-date after all! Otherwise I would have seen a lot more updates in that log… but the fact that it says [success] No pending updates. is good!

As for that error specifically… yea that’s one that I can help you fix…

It may be related to farm_ledger… what version of that do you have? You need to be running version 2.1.2 of that module.

(And if you update it, you also need to run drush updb + drush cr again!)

I don’t know if it’s me or what…but I can’t find the current version in any of the farm_ledger files in the directory.

If you downloaded it from Drupal.org, then the farm_ledger.info.yml file would have the version inserted into it via Drupal.org packaging script. If you used git clone then it wouldn’t say, but you could check the commit you’re on.

If you don’t have any sale/purchase logs, you could also just uninstall that module and see if it fixes the error. But if you do have those logs, then updating it and running drush updb + drush cr should do the trick.

That said, it’s possible that the error you’re seeing is coming from another place too… but we’ll try farm_ledger first…

PS: Here is where we identified that issue originally… it was present in a number of modules… which is why I say it may be coming from elsewhere too…

Apparently I used git. I did a git pull and the drush commands. It did some upgrades.

AND…

That fixed it! I am able to login now.

and in the process learned the proper way to upgrade things,.

Thank you very much! You saved my bacon (well, we don’t have pigs we have cows).

Hooray! I love it when things work! :smile:

And yea, now that you know the process future upgrades should be straightforward. Just be sure to “pin” the version of farmOS you’re using in your docker-compose.yml file, so that you can make your updates intentionally. It’s also a good idea to update all your add-on modules at the same time, if there are new versions available. Sometimes they update to match changes in core farmOS.

If you want to take your self-hosting to the next level (using true dependency management tools), this is what I would recommend reading next: Building farmOS with Composer | farmOS

Thanks, I’ll be sure to check that out. I’ll admit to taking shortcuts on the upgrades, so now I’ll be doing it right going forward.

I’ve gone through the other plugins to be sure they are up-to-date.

1 Like