Problem/Motivation

After upgrading the site to 8.9.13 any new content creation gives an error and doesn't complete. Editing content is ok. I updated to latest version to resolve FontYourFace module not working, giving ajax errors. The upgrade didn't resolve the FontYourFace issues and resulted in this critical error that has crippled my site.

Steps to reproduce

The issue seems to be with the path_alias table. Creating any content after upgrading core to 8.9.13 errors out on new content save. Preview works, but not save. The logged error is:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'legionofmary.url_alias' doesn't exist: SELECT pid FROM {url_alias} WHERE alias = :alias AND source != :source; Array ( [:alias] => /page/ministry [:source] => /node/36 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 846 of /home/mediaq/legionofmarysac.dreamhosters.com/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Proposed resolution

None of the solutions provided for this error in general Drupal support chatter (all dated end of 2019) seem to work to resolve this. None of the database update suggestions resolved this for me.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#10 3203893-10.patch629 bytesdrupalninja99

Comments

hondaman900 created an issue. See original summary.

Code Monkey’s picture

You didn't state which version you were upgrading from. I'm not sure if it matters though. See the patch here to see if it resolves this issue.

hondaman900’s picture

Thanks Code Monkey, I didn't explicitly mention the version because I had selected the version of OpenChurch as part of the post profile (8.x-2.3).

I applied this patch and it seems to have resolved the issue in that I can save new content and am not getting the error - many thanks!

I would advocate that this patch be implemented in the distribution code.

Code Monkey’s picture

My mistake on the versioning. I hadn't looked at this in a while.

hondaman900’s picture

Unfortunately, this issue is not quite resolved. While I can save new content, updating existing content and adding any form of relative link causes the same issue. For example, when I change the OpenChurch Homepage Featured block and add links, it bombs with the same "The website encountered an unexpected error. Please try again later." message. No relative link at all will work, only a full path or a blank field works. The logs show the following error:

InvalidArgumentException: The URI '<front>' is invalid. You must use a valid URI scheme. in Drupal\Core\Url::fromUri() (line 290 of /home/mediaq/legionofmarysac.dreamhosters.com/core/lib/Drupal/Core/Url.php).

Is there an additional patch for the url.php file perhaps?

Please advise

Code Monkey’s picture

I'm not certain this is it , but it is worth a look.

In your settings.php file, what is this setting set to? $settings['file_public_base_url']

I do not need to know the answer. However, is it set correctly?

warped’s picture

Applied to 9.4.5 and updated existing content. Messages from watchdog:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "path.alias_storage". in Drupal\Component\DependencyInjection\Container-

Drupal\Core\Entity\EntityStorageException: You have requested a non-existent service "path.alias_storage". in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 811 of /var/www/h

warped’s picture

Here is the quick change I did when 8.0.0 url_alias to path_alias broke my site.
I understand the need for using proper abstraction thru APIs, Dependency Injection, etc.
This is posted to add to the discussion.
It worked in D8. I have not tested it in D9 yet.
When searching for a solution I came across this:
https://www.drupal.org/project/entity_legal/issues/3182420

< $alias_exists = db_query('SELECT pid FROM {url_alias}
< WHERE alias = :alias AND source != :source',
---
> $alias_exists = db_query('SELECT id FROM {path_alias}
> WHERE alias = :alias AND path != :source',

warped’s picture

A few lines under the patch there was another deprecated section:

$path = \Drupal::service('path.alias_storage')
        ->save('/node/' . $nid, $node_alias_path . $alias);

That needed to be replaced. I used the following:

$path = \Drupal::entityTypeManager()->getStorage('path_alias')->create([
  'path' => '/node/' . $nid,
  'alias' => $node_alias_path . $alias,
  'langcode' => 'en,
]);
$path->save();

Drupal v9.4.7 PHP v7.4.32 Comments? Language code should probably reflect the node.

drupalninja99’s picture

StatusFileSize
new629 bytes

This patch fixes the issue

  • drupalninja99 authored 7fc9917a on 8.x-2.x
    Issue #3203893 by drupalninja99, hondaman900, Code Monkey, Warped: Error...
drupalninja99’s picture

Added a new release, thanks for your help! I was able to install successfully after applying this fix.