Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when calling fetchCol() in new Backdrop core release, 1.30.0 #42

Closed
oriolroger opened this issue Feb 14, 2025 · 4 comments · Fixed by #43
Closed

Bug when calling fetchCol() in new Backdrop core release, 1.30.0 #42

oriolroger opened this issue Feb 14, 2025 · 4 comments · Fixed by #43

Comments

@oriolroger
Copy link

Hi all.

We've found a possible bug in the Profile module, when upgrading the Backdrop core to the latest release, 1.30.0

The function to fetch a column in the database (fetchCol) doesn't allow to send a string parameter with the name of the field anymore. It has to send an empty or an integer parameter, with the index of the field we want to fetch.

So in the function profile_generate_form_submit($form, &$form_state), we should replace this call:
$users = $query->execute()->fetchCol('uid');
with the correct one:
$users = $query->execute()->fetchCol();

Otherwise, when we try to generate profiles with the Devel module (can do it in the URL /admin/devel/generate/profile), we'll get an error:

PDOStatement::fetchAll(): Argument #2 must be of type int, string given

Thanks!

@bugfolder
Copy link
Collaborator

Interesting. This syntax is also used in the devel_generate submodule (in devel_generate.inc):

// TODO: use taxonomy_get_entries once that exists.
function devel_generate_get_terms($vocabulary_names) {
  return db_select('taxonomy_term_data', 'td')
           ->fields('td', array('tid'))
           ->condition('vocabulary', $vocabulary_names, 'IN')
           ->orderBy('tid', 'ASC')
           ->execute()
           ->fetchCol('tid');
}

@argiepiano
Copy link
Contributor

Hmm... the method fetchCol() has always required an int as parameter, even in D7.

I have no idea how fetchCol('uid') was working before. It probably has to do with your version of PHP, not Backdrop's.

@oriolroger
Copy link
Author

Correct, @argiepiano. This error has raised now that we've moved our server from php 7.4 to 8.3.

bugfolder added a commit to bugfolder/profile that referenced this issue Feb 17, 2025
bugfolder added a commit that referenced this issue Feb 17, 2025
Issue #42: Fix bug in profile generation.
@bugfolder
Copy link
Collaborator

Fix tested and merged in. Thanks @oriolroger and @argiepiano!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants