php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23365 global twice causes problems
Submitted: 2003-04-26 15:35 UTC Modified: 2003-04-27 19:28 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: spagmoid at yahoo dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.3.1 OS: WinXP
Private report: No CVE-ID: None
 [2003-04-26 15:35 UTC] spagmoid at yahoo dot com
If you declare a variable global twice, it gives you garbage the second time. IE:

global $Bob;
global $Bob;

This was already reported, and sniper shot it down.  That's what he does apparently, shoots down valid bugs in the goal of keeping PHP as buggy as possible!  Maybe he works for Micro$oft?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-26 15:51 UTC] pollita@php.net
Or, perhaps sniper bogusified it because it's bogus.

Let's leave out for the moment the sheer wrongness of globalizing a variable twice in a row.  That's not even at issue at the moment.

What you descibe simply doesn't occur (in PHP4 or PHP5).

It may be that there are special circumstances causing it to happen in your script but since you failed to follow the instructions on how to report a bug I'm simply writting my own script to test it.

<?php
function foo() {
  global $bar;
  global $bar;

  echo $bar;
}

$bar = "baz";

foo();
?>

Outputs "baz" as expected.

If you decide to submit a proper bug report (with the minimally necessary information), please do so by reopening this bug with the updated information.  NOT by creating a new bug. (Again, following instructions is a good thing)

Oh, and on a personal note, insulting someone is not the best way to illicit their help.
 [2003-04-26 15:59 UTC] spagmoid at yahoo dot com
I used to give very specific repro's.  Now I don't bother spending 15 minutes to be precise because someone always comes along and spends a total of 5 seconds before lazily marking things bogus.  Maybe it's just with classes, maybe its something else.  Suffice it to say, problems occur with global when they shouldn't.  There's no reason to say:

$A = 1;
$A = 1;

either is there?  So if $A was 2 afterward, that wouldn't be a bug?  There are valid reasons.  Global should make something global period, not screw it up.  My reason is, I am requiring a file in 2 different places, once in the global scope and once in a function.  So I declare global $Object, and if we are already in the global scope things screw up.  Now this is a bug.  There are things called principles, like doing something the right way even when you don't readily see a reason for it.  

I still don't expect any action on this, but now whoever bogusifies it this time will at least have no Pontius Pilate excuse when you're brought before the God of programming.
 [2003-04-26 16:05 UTC] derick@php.net
Please provide a FULL script with which we can try to reproduce it.

Derick
 [2003-04-26 16:11 UTC] pollita@php.net
Nice, make it someone else's fault that you're not providing complete information.  I still don't see a reproducing script by the way.

It does NOT suffice to say that problems occur with globals when they shouldn't, because there is no presenting bug to identify as yet.  All I have is you saying "It's broke!"

Fine you have a reason for calling global in the global scope and for calling global twice, however AS I MENTIONED that is not even the core issue.  The core issue is that your bug IS NOT REPRODUCIBLE.

Your last comment mentioned classes.  That's a new piece of information.  *gasp* Maybe it's relevant!

So, rather than continue your childish tantrum of attacking blindly, why not grow up and submit a bug comment that contains useful information. m'kay?

P.S. - You're not Jesus.
 [2003-04-26 16:17 UTC] spagmoid at yahoo dot com
Actually here, the reproducible problem is NOT the core issue.  The core issue is whether anyone cares to admit there is a problem then fix it.  We have to cross that massive hurdle before I spend my valuable time.  This very issue itself, reproducible or not, has been shot down twice.  So what the hell is the point of giving you a repro?  Here's a repro you ungrateful little snit - the last time it was shot down.  

http://bugs.php.net/bug.php?id=23150&edit=2
 [2003-04-26 16:30 UTC] pollita@php.net
Thank you.  Now was that so hard?

I am marking *this* one bogus since it's duplicate of an already submitted bug.

However, the first one, while expected behavior, isn't actually 'Bogus'.  I'll update that one as well.
 [2003-04-27 04:06 UTC] sniper@php.net
Just for the record: I wish I worked for Microsoft, I propably would get PAID for doing this ungrateful work. :)

 [2003-04-27 19:28 UTC] spagmoid at yahoo dot com
You should apply; their concern for quality control is on a par with yours.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 21:01:32 2024 UTC