I was trying to write code to check if a site was verified, but it turns out $node->verified is set to "0" as a string, not an integer.

The problem with that is...


if ($node->verified) {
  print '$node->verified always returns true, even when it is 0, because it's a string.';
) 

I patched hook_load for site, platform, server, and task modules to set the value to an integer if it is numeric.

CommentFileSizeAuthor
#3 2944853-hook-load-integer.patch1.76 KBJon Pugh
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jon Pugh created an issue. See original summary.

  • Jon Pugh committed acfea2c on 2944853-hook-load-integer
    Issue #2944853: hook_load() implementations load integers as strings
    
Jon Pugh’s picture

Jon Pugh’s picture

Issue summary: View changes

  • Jon Pugh committed acfea2c on 7.x-3.x
    Issue #2944853: hook_load() implementations load integers as strings
    
  • helmo committed f204d2c on 7.x-3.x
    Issue #2944853 by helmo: codestyle
    
helmo’s picture

Status: Needs review » Fixed

Thanks, I've merged this with only a few extra spaces that phpcs was complianing about.

Status: Fixed » Closed (fixed)

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

Jon Pugh’s picture

Not sure what I was thinking, changed it to just cast to (int)!.

Branch deleted.