We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Fixed Vars unpickle as stale
## Summary

I'm not sure if this is a bug, but it seems unexpected? Anyway, if you pickle a model that has a fixed variable (not stale), when you unpickle it, it comes back as stale.

### Steps to reproduce the issue

```
from pyomo.environ import *
import pickle

m = ConcreteModel()
m.x = Var(domain=Binary)
m.x.fix(1)

unpickle = pickle.loads(pickle.dumps(m))

m.x.pprint()
unpickle.x.pprint()
```

```
x : Size=1, Index=None
    Key  : Lower : Value : Upper : Fixed : Stale : Domain
    None :     0 :     1 :     1 :  True : False : Binary
x : Size=1, Index=None
    Key  : Lower : Value : Upper : Fixed : Stale : Domain
    None :     0 :     1 :     1 :  True :  True : Binary
```

### Error Message

It seems like these models should be identical, even up to stale-ness, right?

### Information on your system

Pyomo version: main
Python version: 3.8
Operating system: linux
How Pyomo was installed (PyPI, conda, source): source 
Solver (if applicable):

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyomo/core/staleflag.py`
Content:
```
1 #  ___________________________________________________________________________
2 #
3 #  Pyomo: Python Optimization Modeling Objects
4 #  Copyright (c) 2008-2022
5 #  National Technology and Engineering Solutions of Sandia, LLC
6 #  Under the terms of Contract DE-NA0003525 with National Technology and
7 #  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
8 #  rights in this software.
9 #  This software is distributed under the 3-clause BSD License.
10 #  ___________________________________________________________________________
11 
12 class _StaleFlagManager(object):
13     def __init__(self):
14         self._current = 0
15         self.mark_all_as_stale()
16 
17     def stale_mapper(self, encode, value):
18         if encode:
19             return self.is_stale(value)
20         else:
21             if value:
22                 return 0
23             else:
24                 self.get_flag(0)
25 
26     def _get_flag(self, current_flag):
27         """Return the current global stale flag value"""
28         return self._current
29 
30     def _get_flag_delayed(self, current_flag):
31         """Implement the "delayed" advancement of the global stale flag value
32 
33         This will continue to return the current value of the state flag
34         until the first non-stale variable is updated (that it, it is
35         passed the current stale flag when called).  This allows for
36         updating stale variable values without incrementing the global
37         stale flag, but will mark everything as stale as soon as a
38         non-stale variable value is changed.
39 
40         """
41         if current_flag == self._current:
42             self._current += 1
43             setattr(self, 'get_flag', getattr(self, '_get_flag'))
44         return self._current
45 
46     def is_stale(self, val):
47         """Return ``True`` if the passed value indicated a stale variable"""
48         return val != self._current
49 
50     def mark_all_as_stale(self, delayed=False):
51         """Advance the global stale flag, marking all variables as stale
52 
53         This is generally called immediately before and after a batch
54         variable update (i.e. loading values from a solver result or
55         stored solution).  Before the batch update
56         :meth:`mark_all_as_stale` is called with ``delayed=False``,
57         which immediately marks all variables as stale.  After the batch
58         update, :meth:`mark_all_as_stale` is typically called with
59         ``delayed=True``.  This allows additional stale variables to be
60         updated without advancing the global flag, but as soon as any
61         non-stale variable has its value changed, then the flag is
62         advanced and all other variables become stale.
63 
64         """
65         if delayed:
66             setattr(self, 'get_flag', getattr(self, '_get_flag_delayed'))
67         else:
68             setattr(self, 'get_flag', getattr(self, '_get_flag'))
69             self._current += 1
70 
71 StaleFlagManager = _StaleFlagManager()
72
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pyomo/core/staleflag.py b/pyomo/core/staleflag.py
--- a/pyomo/core/staleflag.py
+++ b/pyomo/core/staleflag.py
@@ -21,7 +21,7 @@
             if value:
                 return 0
             else:
-                self.get_flag(0)
+                return self.get_flag(0)
 
     def _get_flag(self, current_flag):
         """Return the current global stale flag value"""

{"golden_diff": "diff --git a/pyomo/core/staleflag.py b/pyomo/core/staleflag.py\n--- a/pyomo/core/staleflag.py\n+++ b/pyomo/core/staleflag.py\n@@ -21,7 +21,7 @@\n             if value:\n                 return 0\n             else:\n-                self.get_flag(0)\n+                return self.get_flag(0)\n \n     def _get_flag(self, current_flag):\n         \"\"\"Return the current global stale flag value\"\"\"\n", "issue": "Fixed Vars unpickle as stale\n## Summary\r\n\r\nI'm not sure if this is a bug, but it seems unexpected? Anyway, if you pickle a model that has a fixed variable (not stale), when you unpickle it, it comes back as stale.\r\n\r\n### Steps to reproduce the issue\r\n\r\n```\r\nfrom pyomo.environ import *\r\nimport pickle\r\n\r\nm = ConcreteModel()\r\nm.x = Var(domain=Binary)\r\nm.x.fix(1)\r\n\r\nunpickle = pickle.loads(pickle.dumps(m))\r\n\r\nm.x.pprint()\r\nunpickle.x.pprint()\r\n```\r\n\r\n```\r\nx : Size=1, Index=None\r\n    Key  : Lower : Value : Upper : Fixed : Stale : Domain\r\n    None :     0 :     1 :     1 :  True : False : Binary\r\nx : Size=1, Index=None\r\n    Key  : Lower : Value : Upper : Fixed : Stale : Domain\r\n    None :     0 :     1 :     1 :  True :  True : Binary\r\n```\r\n\r\n### Error Message\r\n\r\nIt seems like these models should be identical, even up to stale-ness, right?\r\n\r\n### Information on your system\r\n\r\nPyomo version: main\r\nPython version: 3.8\r\nOperating system: linux\r\nHow Pyomo was installed (PyPI, conda, source): source \r\nSolver (if applicable):\n", "before_files": [{"content": "#  ___________________________________________________________________________\n#\n#  Pyomo: Python Optimization Modeling Objects\n#  Copyright (c) 2008-2022\n#  National Technology and Engineering Solutions of Sandia, LLC\n#  Under the terms of Contract DE-NA0003525 with National Technology and\n#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain\n#  rights in this software.\n#  This software is distributed under the 3-clause BSD License.\n#  ___________________________________________________________________________\n\nclass _StaleFlagManager(object):\n    def __init__(self):\n        self._current = 0\n        self.mark_all_as_stale()\n\n    def stale_mapper(self, encode, value):\n        if encode:\n            return self.is_stale(value)\n        else:\n            if value:\n                return 0\n            else:\n                self.get_flag(0)\n\n    def _get_flag(self, current_flag):\n        \"\"\"Return the current global stale flag value\"\"\"\n        return self._current\n\n    def _get_flag_delayed(self, current_flag):\n        \"\"\"Implement the \"delayed\" advancement of the global stale flag value\n\n        This will continue to return the current value of the state flag\n        until the first non-stale variable is updated (that it, it is\n        passed the current stale flag when called).  This allows for\n        updating stale variable values without incrementing the global\n        stale flag, but will mark everything as stale as soon as a\n        non-stale variable value is changed.\n\n        \"\"\"\n        if current_flag == self._current:\n            self._current += 1\n            setattr(self, 'get_flag', getattr(self, '_get_flag'))\n        return self._current\n\n    def is_stale(self, val):\n        \"\"\"Return ``True`` if the passed value indicated a stale variable\"\"\"\n        return val != self._current\n\n    def mark_all_as_stale(self, delayed=False):\n        \"\"\"Advance the global stale flag, marking all variables as stale\n\n        This is generally called immediately before and after a batch\n        variable update (i.e. loading values from a solver result or\n        stored solution).  Before the batch update\n        :meth:`mark_all_as_stale` is called with ``delayed=False``,\n        which immediately marks all variables as stale.  After the batch\n        update, :meth:`mark_all_as_stale` is typically called with\n        ``delayed=True``.  This allows additional stale variables to be\n        updated without advancing the global flag, but as soon as any\n        non-stale variable has its value changed, then the flag is\n        advanced and all other variables become stale.\n\n        \"\"\"\n        if delayed:\n            setattr(self, 'get_flag', getattr(self, '_get_flag_delayed'))\n        else:\n            setattr(self, 'get_flag', getattr(self, '_get_flag'))\n            self._current += 1\n\nStaleFlagManager = _StaleFlagManager()\n", "path": "pyomo/core/staleflag.py"}], "after_files": [{"content": "#  ___________________________________________________________________________\n#\n#  Pyomo: Python Optimization Modeling Objects\n#  Copyright (c) 2008-2022\n#  National Technology and Engineering Solutions of Sandia, LLC\n#  Under the terms of Contract DE-NA0003525 with National Technology and\n#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain\n#  rights in this software.\n#  This software is distributed under the 3-clause BSD License.\n#  ___________________________________________________________________________\n\nclass _StaleFlagManager(object):\n    def __init__(self):\n        self._current = 0\n        self.mark_all_as_stale()\n\n    def stale_mapper(self, encode, value):\n        if encode:\n            return self.is_stale(value)\n        else:\n            if value:\n                return 0\n            else:\n                return self.get_flag(0)\n\n    def _get_flag(self, current_flag):\n        \"\"\"Return the current global stale flag value\"\"\"\n        return self._current\n\n    def _get_flag_delayed(self, current_flag):\n        \"\"\"Implement the \"delayed\" advancement of the global stale flag value\n\n        This will continue to return the current value of the state flag\n        until the first non-stale variable is updated (that it, it is\n        passed the current stale flag when called).  This allows for\n        updating stale variable values without incrementing the global\n        stale flag, but will mark everything as stale as soon as a\n        non-stale variable value is changed.\n\n        \"\"\"\n        if current_flag == self._current:\n            self._current += 1\n            setattr(self, 'get_flag', getattr(self, '_get_flag'))\n        return self._current\n\n    def is_stale(self, val):\n        \"\"\"Return ``True`` if the passed value indicated a stale variable\"\"\"\n        return val != self._current\n\n    def mark_all_as_stale(self, delayed=False):\n        \"\"\"Advance the global stale flag, marking all variables as stale\n\n        This is generally called immediately before and after a batch\n        variable update (i.e. loading values from a solver result or\n        stored solution).  Before the batch update\n        :meth:`mark_all_as_stale` is called with ``delayed=False``,\n        which immediately marks all variables as stale.  After the batch\n        update, :meth:`mark_all_as_stale` is typically called with\n        ``delayed=True``.  This allows additional stale variables to be\n        updated without advancing the global flag, but as soon as any\n        non-stale variable has its value changed, then the flag is\n        advanced and all other variables become stale.\n\n        \"\"\"\n        if delayed:\n            setattr(self, 'get_flag', getattr(self, '_get_flag_delayed'))\n        else:\n            setattr(self, 'get_flag', getattr(self, '_get_flag'))\n            self._current += 1\n\nStaleFlagManager = _StaleFlagManager()\n", "path": "pyomo/core/staleflag.py"}]}