Closed Jones-S closed 3 years ago
Oh I see. I think I had to update that the old linkField type could not be found. I think I have to adjust all linkfield fields hoping the data would stay in place...:S
This was true for my local installation. For my remote I can't get it to work. I adapted every linkField locally (resaved the fieldtype as linkField) and pushed the project-config.
Now when ssh-ing into my server to run
Applying changes from your project config files ... error: Class 'typedlinkfield\fields\LinkField' not found```
Where else do I have to adjust things?...
Within the db? I'd rather not like to mess around in there... I don't care if some date get's lost, but I need a running installation again and I don't understand why I managed to do that locally but with the same project-config I can't do it remotely...
Hi @Jones-S, thanks for reporting this. I assume that something on the Craft side has changed in the latest versions as I am not aware of this issue on the upgrade path.
I unfortunately don't have anything to add about the source of this. But rebuilding the project config locally was a pretty easy fix for me.
For some reason the type key in project config was type: typedlinkfield\fields\LinkField
instead of type: lenz\linkfield\fields\LinkField
. Seemed like my project-config was for v1, even though in commits I can see it updated. 🤷
Okay, I've added a legacy class typedlinkfield\fields\LinkField
that extends lenz\linkfield\fields\LinkField
and generates a deprecation error.
@sebastian-lenz
Rebuilding the PC or going in the field and resaving doesn't change a thing... This update broke FeedMe imports
@sebastian-lenz any update to @michtio's report on FeedMe?
Getting the same error in feedme
@DynamiteGoesBoom @michtio you can hack around this by sticking this in project somewhere (eg config/app.php
):
class_alias(\lenz\linkfield\fields\LinkField::class, '\typedlinkfield\fields\LinkField');
…but this needs to be fixed in Feed Me.
@sebastian-lenz I'll try the latest…but it should really be fixed in feed-me anyhow… PR here: https://github.com/sebastian-lenz/craft-linkfield/issues/122
Okay, I've added support for FeedMe to the plugin, you'll now see more available field mappings when using the link field with FeedMe. I hope this resolves this issue, besides the already included dummy class.
As this issue already is quite long and discusses different problems, I'll close it for now. Thank you all for your help and please feel free to open a new issue should you run into any problems.
I still get an Deprecation Warning, Rebuilding Project Config did not solved this. Using 2.0.0-rc.1
With the following message:
Using of the legacy link field class is deprecated. The project configuration might need a rebuild, see https://github.com/sebastian-lenz/craft-linkfield/issues/122 | /var/www/virtual/kf/deploy/releases/3a894351b9ebaae214df2cef07621c5aaa6d7fae/vendor/composer/ClassLoader.php:480
Any suggestions how to fix the deprecation warning ↑ ? @sebastian-lenz ?
Also getting the deprecation warning on v2.
@sebastian-lenz ping
Getting deprecation warning on Craft 3.7.30.1, plugin 2.0.0-rc.1
Subscribing. Seeing this deprecation error in Craft 4 with Link Field 2.1.3-rc
@darylknight Same for me. Latest craft: 4.0.5.1
with linkfield: 2.1.3-rc
.
Something peculiar in my case - I have other projects that 'run' basically the same config and somehow there is no deprecation warning there. Trying to debug this. I'll try to post more info if I find something.
Ok - I am back with some information:
I managed to solve the deprecation error in my project. Here is what I did:
Now as to why the link fields were shown as assets - I have no idea what could've gone wrong at this point.
I migrated to Craft 4 about a month ago but for the life of me I cannot recall if that deprecation error was present since then or is it more recent...
P.S. I took the liberty of tagging people who recently encountered this issue - hoping that it'll help you out. @Jones-S @curtishenson @michtio @timkelty @darylknight @Maybach91 @wuhhh @jonathanmelville and of course @sebastian-lenz
I also managed to fix this on a site by rebuilding project config after updating to Craft 4.
Thank you @MateuszEckardt for taking the time :)
@MateuszEckardt you were spot on! I was just able to reproduce your steps. Except in my case, every single link field had changed to Assets. The plugin's link type field defaults to Assets, so maybe that has something to do with it??
But this really should get fixed, as it has pretty big ramifications and potential for data loss.
After updating to Craft 4 i got that error and link to that ticket... Using of the legacy link field class is deprecated. The project configuration might need a rebuild, see https://github.com/sebastian-lenz/craft-linkfield/issues/122
/var/www/craft/vendor/composer/ClassLoader.php:571
Rebuilding the project config does not solve it...
trying to save itself will cause that its set in my case to DropDown instead Linkfield, saving it a second time it kept the field type.
Getting the same issue as @DavidKabelitz when trying to update to Craft 4.
Tried rebuilding the config but then I get:
Rebuilding the project config from the current state ... error: Using of the legacy link field class is deprecated.
The project configuration might need a rebuild, see https://github.com/sebastian-lenz/craft-linkfield/issues/122
So the suggestion that we need to rebuild the config as the solution to the error while rebuilding the config is not too helpful.
Is there another way around this? I'm mid-way through a migration to Craft 4, so I can't even get into the admin area to check fields/settings in there.
Update: I worked around this issue by disabling the exceptions on deprecation warnings. In my case, it was in the config/app.php file - I had a deprecator running that I commented out:
"components" => [
"deprecator" => [
//"throwExceptions" => true,
],
],
Ran into this today on a site, this time it wouldn't go away just by rebuilding. Following the thread above, I did indeed find 4 fields that were listed as "Asset" that used to be link fields. They're all inside a Matrix block, and when I tried to change them back from Assets to Link fields, I got this error:
Can't find a way around it.
Ran into this today on a site, this time it wouldn't go away just by rebuilding. Following the thread above, I did indeed find 4 fields that were listed as "Asset" that used to be link fields. They're all inside a Matrix block, and when I tried to change them back from Assets to Link fields, I got this error:
Can't find a way around it.
Same, link field inside matrix block will change to assets, but it is linkField in the config file
Following up on this --
In our local development environment (Craft 4.x / plugin version 3.1) we also identified that our link fields were incorrectly set to Asset
type. This was observed during the process of updating from Craft 3.x to Craft 4.x.
Further digging into the .yaml
revealed that the type for these fields had not been reset. Immediately, we grew suspicious of the migration file m190417_202153_migrateDataToTable.php -- specifically lines 64
, 66
, and 72
.
Performing this query against our database (SELECT * from TABLE where type = 'typedlinkfield\fields\LinkField';
) returned 0 records as a result of the unescaped back slashes. Properly escaping the back slashes and performing the query again returned the correct / expected result.
After updating these lines in the migration file, and re-running the migration for this plugin, the deprecation warning in the Craft Admin UI is no longer present, and all .yaml
files have had their type properly reset.
This process was successfully tested against multiple developer's machines.
If you don't mind, would you be able to see if this fixes your issue as well, @darylknight?
If this is in fact the problem, I will be more than happy to open a new issue and submit a PR @sebastian-lenz
EDIT: Not to necro-post, but I figured some other people might want an update on this - hoping that it'll help you out. @michtio @Maybach91 @wuhhh @jonathanmelville @MateuszEckardt @jacksutherland
How do you re-run the migration after updating the PHP file?
@darylknight this will be unique by environment, but typically this can be done by restoring from a backup taken from before the migrations have been run.
In our instance, we are restoring from a production environment running an older version of Craft / link field. Once we have restored this data, we have to migrate forward in order to be compatible with Craft 4 (our own semantics 😅)
Additionally, specific Craft migrations can be run via the following pattern: ./craft migrate/up --plugin <plugin>
See their docs for more information.
I believe there may also be a command to re-run migrations which have been performed: ./craft migrate/redo
or something like this.
+1 to @ctangney-tulip's solution on the case of the incorrect field types. The craft docs explicitly say they'll escape the column names but say nothing about column values. The where
docs (the function that update
calls) also don't mention anything about value escaping.
Sorry, I don't have a backup of this site from Craft 3. I did try updating the migration and running it again with a backup from last month, which ran all the migrations, but the deprecation warning is still there and won't go away. This is what I updated those lines to before running it again:
@darylknight it will be necessary for you to clear your existing deprecation warnings after you have run the migration, then load the page on which the deprecation was occurring. Have you done this?
Yes. This deprecation has never happened on a traceable template for me. The location is this:
This is also the location which our error was stemming from. Would you be able to locate one of your link field .yaml
files and confirm that the type is correctly set to lenz\linkfield\fields\LinkField
?
These files would probably be in a location like ~/config/project/fields/
.
Eep! I misspoke previously. I've gone back and updated my comment to reflect the correct type (I have not yet had my coffee 😅) It looks to me like these .yaml
files are still reflecting the old name. I am wondering if the migration ran correctly. The correct type would be lenz\linkfield\fields\LinkField
.
I might try manually updating these types to be lenz\linkfield\fields\LinkField
then rebuilding your config from the yaml via the admin UI to see if this resolves your deprecation error.
Sorry I'm having too many issues trying to roll this site back to run those migrations again. It sounds like that solution would solve the problem, but only for sites that haven't already upgraded to Craft 4.
I ran into this just now. Editing the migration to double \\
, and running ./craft migrate/up --plugin typedlinkfield
before all other migrations worked
Excellent, thanks for confirming that worked for you @chrisrowe!
I'll see about opening a new issue and cutting a pull request at some point today 🤘
Also happening to me, I just successfully updated a client site to Craft CMS 4.4.5, and getting this error.
Can't seem to get it to go away. Anyone find a fix?
the same for me still on all projects!
Hyper is always an option if y’all are desperate
@chrisrowe can you explain hyper?
https://verbb.io/craft-plugins/hyper/features
It supports migrations from linkfield
I was getting the deprecation warning after upgrading to Craft 4 and nothing helped except performing the upgrade once again. The second time I upgraded from Craft 3 to Craft 4 the depreciation warning was gone.
I'm running into this issue on a craft 4.5.6.1 site. I've rebuilt project config but the deprecation warning continues to surface.
Please advise.
I was getting the deprecation warning after upgrading to Craft 4 and nothing helped except performing the upgrade once again. The second time I upgraded from Craft 3 to Craft 4 the depreciation warning was gone.
Same here, I got the warning after upgrading to 4.
How do you upgraded twice the same project? "the second time" I don't get it.
@estebancastro By going back to Craft 3 and upgrading to Craft 4 again. In my case, I went back to the branch with Craft 3, created a new branch and updated to Craft 4 there. And then the warning was gone.
I just migrated to another server and updated some dependencies. When running
/.craft project-config/apply
I get the following error:error: Class 'typedlinkfield\fields\LinkField' not found
Does that tell you anything? I am a bit lost how to debug that...
Thanks for any help. Cheers