Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Using latest .dev and clearing cache I got:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_weblinks_tid' in 'where clause': SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {field_data_taxonomy_weblinks} t INNER JOIN {node} n ON t.entity_id = n.nid WHERE (taxonomy_weblinks_tid IN (:db_condition_placeholder_0)) AND (n.status = :db_condition_placeholder_1) AND (n.type = :db_condition_placeholder_2) AND (n.language IN (:db_condition_placeholder_3, :db_condition_placeholder_4)) ) subquery; Array ( [:db_condition_placeholder_0] => 3128 [:db_condition_placeholder_1] => 1 [:db_condition_placeholder_2] => weblinks [:db_condition_placeholder_3] => nl [:db_condition_placeholder_4] => und ) in weblinks_term_node_count() (regel 167 van /sites/all/modules/weblinks/weblinks.module).
The problem is the column field in field_data_taxonomy_weblinks
It should be field_weblinks_tid instead of taxonomy_weblinks_tid
See improved code line 159 -167:
$query = db_select('field_data_taxonomy_weblinks', 't');
$query->condition('field_weblinks_tid', $tids, 'IN');
$query->join('node', 'n', 't.entity_id = n.nid');
$query->condition('n.status', 1);
$query->condition('n.type', 'weblinks');
// Use 'language' from the node table not field_data_taxonomy_weblinks.
$query->condition('n.language', $langs, 'IN');
$count = $query->countQuery()->execute()->fetchField();
return $count;
}
Greetings, Martijn
Comment | File | Size | Author |
---|---|---|---|
#38 | weblinks_categories_nohits.jpg | 111.88 KB | Summit |
#33 | weblinks.user_.inc_.txt | 5.98 KB | jonathan1055 |
#33 | weblinks.module.txt | 62.42 KB | jonathan1055 |
#30 | 2468615_30.non_weblinks_vocab_info.patch | 5.41 KB | jonathan1055 |
Comments
Comment #1
Summit CreditAttribution: Summit commentedComment #2
GStegemann CreditAttribution: GStegemann commentedSorry, but at all my D7 test sites the column is named 'taxonomy_weblinks_tid'. And I guess also at Jonathans sites. See attached screen shot.
I assume your Web Links content type was tampered somehow. Due to whatsoever reason your Web Links Taxonomy Reference field became named 'field_weblinks'. And that is wrong.
When I changed the Web Links content type the field name 'taxonomy_weblinks' was automatically proposed by Drupal. Did you modify the content type manually? And what field type did you choose? However, it its important to select 'Add existing field' and not 'Add new field'. But in case you have upgraded your D6 site to D7 the Web Links update function takes care of the creating the correct Taxonomy Reference field.
Comment #3
Summit CreditAttribution: Summit commentedMmm.. I do not use the weblinks vocabulary, but use two other ones for the weblinks related terms; Region and Category.
May be that is why this happened with me.
Sorry for reporting this then. But may be it shouldn't be hardcoded, becauase may be also others will use other vocabularies instead of the weblinks vocabulary?
greetings, Martijn
Comment #4
GStegemann CreditAttribution: GStegemann commentedYes, very likely.
Regarding the Web Links navigation vocabulary expecting this field if fully OK. However, when only other vocabularies are used a check is needed whether the Web Links specific taxonomy reference field really does exist. Thanks for reporting this since we havn't considered this kind of usage.
I will check that with Jonathan.
Comment #5
GStegemann CreditAttribution: GStegemann commentedComment #6
jonathan1055 CreditAttribution: jonathan1055 commentedThanks for discovering this. That column is hard-coded in three functions. You had the problem in weblinks_term_node_count() but it is also in _weblinks_get_query() and weblinks_user_form(). Yes, I will work on replicating the problem and I am sure we can fix it.
Comment #7
GStegemann CreditAttribution: GStegemann commentedMaybe the information in comment #2210683-42: 6.x to 7.x migration based on Drupal-to-Drupal Migrate is helpful for you.
Comment #8
jonathan1055 CreditAttribution: jonathan1055 commentedI've done some testing and discovered that Web Links does not work for any vocabs other than our standard weblinks vocabulary. If you select a non-weblinks vocab the main links page is empty. Even if you have added terms to the nodes, they still do not show, we just get empty group fieldsets. This is due to the use of 'taxonomy_weblinks_tid' in _weblinks_get_query()
I think this needs to be fixed before we release 7.x
Comment #9
jonathan1055 CreditAttribution: jonathan1055 commentedI've been working on a solution to find the table name and field name for the vocabulary used for weblinks. Before I code the changes to .module and .user.inc I would like you to test the following function which will be used in the real code.
I am assuming you have the devel module so just paste this into the execute textarea, run it then post back the dd() output. Hopefully the returned values will be the ones which we need to use in our code.
Comment #10
GStegemann CreditAttribution: GStegemann commentedTried it. But this line fails to execute:
Parse error: syntax error, unexpected '[' in /var/www/html/cm7/sites/all/modules/devel/devel.module(1415) : eval()'d code on line 29
I'm still running PHP 5.3.3.
Comment #11
jonathan1055 CreditAttribution: jonathan1055 commentedI am using php 5.4 so I did not spot this. Thanks for testing! Yes, according to this discussion on stackoverflow array dereferencing (a term I had not heard of, but useful to know it now) is new to php 5.4. Try the following:
I am surprised how tedious it is to get this info. But maybe not many contrib modules need the table name and field name? If this works, it might be useful to search core code for some of these items to see if there are functions which already do this.
Comment #12
GStegemann CreditAttribution: GStegemann commentedMost probably you are right. Did you already check the code of module Taxonomy Manager? Or all the migration modules?
Here is the dd() output:
Comment #13
jonathan1055 CreditAttribution: jonathan1055 commentedThanks. This is the important bit:
So, it works for you. I have also tested it on a non-weblinks vocabulary assigned to the weblinks content type and a field added. It would be good if Martijn could also do this test, as he discovered the problem in the first place. I will now implement the use of this function in the .module and .user.inc code and make a proper patch.
I will have a look, but really I wanted functions built in core. If core does not provide them I am confident that this function I have written will do the job.
Comment #14
Summit CreditAttribution: Summit commentedHi Jonathan,
I will do the test with the .dev version when it comes out with this. Just set here that it is implemented and I will test it.
greetings, Martijn
Comment #15
GStegemann CreditAttribution: GStegemann commentedNo, I don't know of any applicable core functions neither. The core Forum module also assumes that its Navigation vocabulary is assigned with a fixed name.
Comment #16
GStegemann CreditAttribution: GStegemann commentedHi Martijn,
regarding #13: Jonathan asked if you could run his test function from comment #11 before he has finished the full implementation. That would be of great help to verify his assumptions about how Taxonomy term reference fields are handled in a module like Web Links. However, to run his test you have to have the Devel module installed.
Gerhard
Comment #17
Summit CreditAttribution: Summit commentedHi Gerhard, Jonathan, I am ok to do the test.
But I do not know what to do. Do I need to add Devel to the live site, and than add some code? What code please?
Greetings, Martijn
Comment #18
GStegemann CreditAttribution: GStegemann commentedHi Martijn,
yes.
The PHP code posted in comment #11. Every line between the PHP tags. After you have executed the test Jonathan needs the output of the dd() calls which you will find in your sites /tmp folder in the file named drupal_debug.txt.
Comment #19
Summit CreditAttribution: Summit commentedSo I take latest weblinks.dev and add this code to weblinks.module?
greetings, Martijn
Comment #20
GStegemann CreditAttribution: GStegemann commentedNo.
You just install and enable the Devel Module from https://www.drupal.org/project/devel (when not already done). Then next you select from your admin menu "Development | Execute PHP code". On that page a window is displayed in which you paste the code from comment #11. To execute the code you click on button Execute. After the function completes you look up the file drupal_debug.txt and post its content. That's all.
Comment #21
Summit CreditAttribution: Summit commentedHi Gerhard,
I did as you asked. I click on execute...and then drupal_debug.txt should be somewhere....but where?
greetings, Martijn
Comment #22
GStegemann CreditAttribution: GStegemann commentedIn your sites /tmp folder. Check your site settings.
Comment #23
Summit CreditAttribution: Summit commentedHi, I had to build my tmp again..
There you go:
Greetings, Martijn
Comment #24
GStegemann CreditAttribution: GStegemann commentedMany thanks.
But surprising is that the field 'field_weblinks_tid' does not appear. Did you remove the Web Links navigation vocabulary completely?
Comment #25
Summit CreditAttribution: Summit commentedHi Gerhard, yes I think more than two years ago or so...it had to do with the fact that then a weblinks url would show all connected weblinks, which would break my site...
greetings, Martijn
Comment #26
GStegemann CreditAttribution: GStegemann commentedI see. But the problem is already fixed a while ago, see #2413339: Taxonomy links for non-weblinks vocabs are altered to weblinks/x .
Comment #27
Summit CreditAttribution: Summit commentedHi Gerhard, Yes but then I had already hunderds of weblinks in...so didn't go back anymore..
gr, Martijn
Comment #28
jonathan1055 CreditAttribution: jonathan1055 commentedExcellent, thank you Martijn. Now you have learned about Devel module and executing php directly. It can be very helpful, and Devel has lots of useful stuff for testers too.
The very top and very end of the debug output tell what we want to see. From:
... we get
I will now make the full changes and produce a proper patch.
Comment #29
GStegemann CreditAttribution: GStegemann commentedBut why is vocabulary 'Prijs-indeling' the first one and the applicable one? I thought that all other vocabularies Martijn uses are also somehow related to his Web Links.
But anyway, when $vocabulary->module has the value 'weblinks' then that must be the navigation vocabulary, correct?
Comment #30
jonathan1055 CreditAttribution: jonathan1055 commentedIt is not the 'first' one, as that field appeared half way down the debug. The info right at the top of the output shows that vocab 12 is the one being used for weblinks navigation. This is the only one which gets
$vocab_name_match
and so it is the one which is stored and returned.I have added defaults to the return array so that if anything does not match we at least end up with the standard fields (that had been previously hardcoded in .module and .user.inc)
Here's a patch for proper tetsing. Martijn, are you ok with applying a patch? If not, let us know and I will add here the two changed files in the entirety for you to use.
Jonathan
Comment #31
Summit CreditAttribution: Summit commentedI Jonathan,
Yes please place here the two changed files and I will use them thursdayevening. I am not good in patching. And I am this evening not at home.
Greetings, Martijn
Comment #32
GStegemann CreditAttribution: GStegemann commentedTested and works for me. I have not marked as RTBC since we should wait for Martijns tests.
@Martijn: do you havel shell access at your site? If yes patching is quite simple. Possibly simpler than sending you the modified files. To send you the files we have to know which version of Web Links you have installed.
Comment #33
jonathan1055 CreditAttribution: jonathan1055 commentedBased on Martijn's comment from #14 "I will do the test with the .dev version when it comes out with this" here are the two files from the latest dev, with the changes added. I had to add .txt to upload them, and then an extra _ was added to .user.inc, so you need to rename these as they are direct replacements for the original files. I suggest you keep copies of your originals in case these fail for some unexpected reason.
But also, yes respond to Gerhard's question about shell access. It's useful for maintainers to have knowledge of our users systems and background.
Comment #34
Summit CreditAttribution: Summit commentedHi Jonathan,
nope no shell access. My site is on a hosting machine. If I understand the question correctly.
it is correct I use the latest Weblinks .dev. So tomorrow evening I will test the files, thanks for uploading them!
Greetings, Martijn
Comment #35
jonathan1055 CreditAttribution: jonathan1055 commentedHi Martijn,
Yes use the latest .dev then download those two files I posted, and use them to replace the existing .module and .user.inc
To test the .module changes, just visit your Web Links main page. You should no longer get the SQL errors, and the number of links should be shown in the fieldset title (if your theme does this). To check the .user change you need to have authority to view other users account pages and go to /user/x/weblinks to see the links added by that user. However, if you cannot test this, don't worry because if the main page works it proves the new function is returning the correct data for your site.
Jonathan
Comment #36
Summit CreditAttribution: Summit commentedHi Jonathan,
I will test this tomorrow. I can test it in D7 thanks to the great work of Gerhard with migration Weblinks :)
Greetings, Martijn
Comment #37
Summit CreditAttribution: Summit commentedHi Jonathan,
I see under /user/x/weblinks now the weblinks per user with adding of this code. I do not know if this is new functionality though..
I also see no SQL error, great!
But when I select another vocabulary as weblinks default. The /weblinks page doesn't give the underneath weblinks.
But may be this is another issue...
Greetings, Martijn
Comment #38
Summit CreditAttribution: Summit commentedHi Jonathan,
Screenshot of weblinks with choosing of category as weblinks Vocabulary.
The categories are certainly not empty.
Greetings, Martijn
Comment #39
jonathan1055 CreditAttribution: jonathan1055 commentedI've tested it when switching between two vocabularies and it worked ok for me. First I also had blank groups like you, but then I added the new vocab as a field to the weblinks content type, editted some links to set some of the new categories and then the links showed up.
Could you also set unclassified links to be shown on your page, as they might be in there instead.
Thanks for testing
Jonathan
Comment #40
Summit CreditAttribution: Summit commentedHi Jonathan,
This will not work for me, because the vocabulary now used as weblinks-vocabulary IS already used within the contenttype Weblinks...but may be add this as another issue for you?
greetings, Martijn
Comment #41
jonathan1055 CreditAttribution: jonathan1055 commentedThis is not new functionality, but it would have failed had you tried it before this patch. Your testing has shown that my use of the new vocab function within weblinks_user_form() is working correctly.
This shows that the problem has been solved, and since Gerhard has also tested in #32 I am marking this RTBC and will commit the changes. Then if there are further problems to solve we can work on them, but this main issue is ready.
Can you check your 'unclassified links' fieldset to see if the missing nodes you were expecting are shown there?
Comment #44
jonathan1055 CreditAttribution: jonathan1055 commentedMarking this as fixed, because the original problem is now corrected.
If you still have difficulties, it is probably best to open a new issue, and list the steps required to reproduce the error, starting with a clean D7 install.
Thank you both for your help on this - good to get it fixed.
Jonathan
Comment #45
Summit CreditAttribution: Summit commentedHi Jonathan,
I will look into your question soon. it is not part of the original issue, so when I find strange things, I will report this as a separate issue than. Thanks for fixing this!
Gre
Greetings, Martijn
Comment #46
jonathan1055 CreditAttribution: jonathan1055 commentedI have added #2481521: Expand the information returned by _weblinks_vocabulary_field_info() which will be used to assist in problem like this.
Comment #48
Summit CreditAttribution: Summit commentedHi Jonathan,
About your open question: Can you check your 'unclassified links' fieldset to see if the missing nodes you were expecting are shown there?
Yes the links show now all under "/weblinks". Thanks!
Greetings, Martijn