Attaching a patch to fix deprecation errors upon updating to D9.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thebumik created an issue. See original summary.

nicrodgers’s picture

Status: Needs review » Needs work

Patch applies successfully and after applying upgrade_status reports just one warning:
Add core_version_requirement: ^8 || ^9 to designate that the module is compatible with Drupal 9.

karishmaamin’s picture

FileSize
2.26 KB

Here is the patch which adds core_version_requirement: ^8 || ^9 to .info.yml file

Suresh Prabhu Parkala’s picture

Status: Needs work » Needs review
Dom.’s picture

Thanks for previous patch.
Unfortunately, I found that SocialPostEntityDeleteForm.php ultimately extends ContentEntityForm which have more injected services than that.

Here is a patch that fixes social_post on Drupal 9 as of today, as far as I went so far to configuration.

Dom.’s picture

Pushing my usage of social_post and social_post_twitter for Drupal 9 to production.
I ended up with a little addition to patch #5, so here it is for review.

Rar9’s picture

Patch 6 doesnt apply with Drupal 9.14

- Installing drupal/social_post (2.0.0-beta3): Loading from cache
- Applying patches for drupal/social_post
https://www.drupal.org/files/issues/2020-11-06/prepare_for_d9--3156341-6... (Drupal 9 Compatibility)
Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-11-06/prepare_for_d9--3156341-6...

Dom.’s picture

@Rar9: the patch applies on social_post module itself not on Drupal. So if the patch does not apply this is because of the version of social_post you use, not the Drupal one.
Maybe I did not mentionned it clearly enough, but the version in this issue is 8.x-2.x-dev so the patch applies not to the 8.0.0-beta3 but on the dev version (the upmost updated codebase) which you can get via composer or git.

I am not the module maintainer so I can help better than with patches. It is true that the whole Social API suite is promising but completely broken at the moment, at least on D9.
I managed to get it working properly on production for twitter auto-posting on an up-to-date D9. It required a lot of patching and I made a blog post about how to get it done : https://freelance-drupal.com/en/blog/automatically-tweet-published-content
You will see this patch #6 is part of the process and applies on dev.

Rar9’s picture

δm using composer workflow

"drupal/social_post": {
"Drupal 9 Compatibility": "https://www.drupal.org/files/issues/2020-11-06/prepare_for_d9--3156341-6..."
},

Composer update

Removing package drupal/social_post so that it can be re-installed and re-patched.
  - Removing drupal/social_post (2.0.0-beta3)
Deleting web/modules/contrib/social_post - deleted
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing drupal/social_post (2.0.0-beta3): Loading from cache
  - Applying patches for drupal/social_post
    https://www.drupal.org/files/issues/2020-11-06/prepare_for_d9--3156341-6.patch (Drupal 9 Compatibility)
   Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2020-11-06/prepare_for_d9--3156341-6.patch
Dom.’s picture

That is exactly what I explained :

the patch does not apply to the 2.0.0-beta3 but on the dev version

If using composer workflow, you have to require the dev version with your composer, not the beta3 !

Something like you do it:
composer require drupal/social_post:2.x-dev

Or even better as a best practice, by fixing it at a given commit, for instance :
composer require drupal/social_post:2.x-dev#53b58f3

Rar9’s picture

Dom thanks it seams to partially work.

Removing drupal/social_post (2.0.0-beta3)
- Installing drupal/social_post (dev-2.x 53b58f3): Cloning 53b58f3 from cache

please explain where the #53b58f3 comes from.

If i then check status page i still get

The following modules are installed, but they are incompatible with Drupal 9.1.4:

Social Post
Social Post Twitter

Dom.’s picture

Hi ! I suggest you to read the whole blog post I made to understand all modifications you have to do and follow them in details. It is not that easy to follow the whole process since D9 does not seem to be the module's author priority at the moment.

The issue with using composer is that the module as to be compatible with the version you want to actually patch it. Otherwise, you will need to apply the patch via git. Also the #53b58f3 is a specific commit on the dev branch. If you don't, every composer install will retry to install the dev branch with all it's new commit. Hence, it may break in the future if you don't fix to "sometimes in the timeline when it works" at least until the D9 patch is merged by the module maintainer.
You can find the commits on the module homepage click on 'commits'. For this module, it give you this page : https://www.drupal.org/node/2714419/commits where you will find the commit I mentionned.

Rar9’s picture

After Having applied your patch composer require drupal/social_post:2.x-dev#53b58f3
I still get

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Social Post

The Link field needs to be installed.

The following modules are installed, but they are incompatible with Drupal 9.1.4:

Social Post
Social Post Twitter

Rar9’s picture

I cant believe NOBODY is using the AUTOPOST from Drupal.

THis MODULE is Simply not working do drupal 9
There is no Guide how to actually post ANYTHING

Under Drupal 6 the user got a TICKBOX when wanting to post to social twitter/facebook.

Dom.’s picture

Hi !

I am using this on various D9 websites. You are totally right that the modules don't work "as-is". Plus, because the maintainer is not active, the patches we contribute are not getting reviewed / integrated which makes it kinda hard to use it.

In my comment #8 I have pointed to a how-to I have written. It is "hard to follow" in the sense that you have to precisely follow each steps which are important and will require a bit of glue-code (or the use of Rules module). But in the end, it's will works.

I wish you good luck with this :)

Rar9’s picture

we might need another patch for drupal 9.2.x

Problem 1
- drupal/social_post 2.0.0-beta1 requires drupal/core ^2 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev, 9.0.0-alpha1, ..., 9.3.x-dev] but it does not match the constraint.
- drupal/social_post[2.0.0-beta2, ..., 2.0.0-beta3] require drupal/core ~8.0 -> found drupal/core[8.0.0-beta6, ..., 8.9.x-dev] but the package is fixed to 9.2.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- Root composer.json requires drupal/social_post ^2.0@beta -> satisfiable by drupal/social_post[2.0.0-beta1, 2.0.0-beta2, 2.0.0-beta3].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

Rar9’s picture

Using this to get this installed under drupal 9.2

https://www.computerminds.co.uk/articles/apply-drupal-9-compatibility-pa... helps to install

              {
        "type": "package",
        "package": {
            "name": "drupal/social_post",
            "type": "drupal-module",
            "version": "dev-8.x-2.x",
            "source": {
                "type": "git",
                "url": "https://git.drupalcode.org/project/social_post",
                "reference": "8.x-2.x"
                }
            }
        },  
 {
        "type": "composer",
        "url": "https://packages.drupal.org/8"
        },

nicrodgers’s picture

I've updated the forked version to include the changes from patch #6.

wells’s picture

Version: 8.x-2.x-dev » 3.x-dev
Status: Needs review » Fixed

MR changes here are merged in to the 3.0.0-beta1 release as future development will happen on the 3.x branch. Please test there. Thanks, all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.