Repository: Qiskit/qiskit (python)

Issue:
Parameter cache is preserved after copy_empty_like
### Environment

- **Qiskit version**: main
- **Python version**: 
- **Operating system**: 


### What is happening?

Parameter appears in empty circuit after copy

### How can we reproduce the issue?

```python
p1 = Parameter("P1")
qc = QuantumCircuit(1)
qc.rz(p1, 0)
qc.parameters  # dummy call to fill cache

cpy = qc.copy_empty_like()
cpy.parameters
```
I see
```
ParameterView([Parameter(P1)])
```
which should not exist.

### What should happen?

Parameter should be empty

### Any suggestions?

Nullify `_parameters` after copy

Pull request description:
Invalidate `parameters` cache on circuit copy (backport #12619)
### Summary

Previously, the caching of the parameter view could persist between copies of the circuit because it was part of the `copy.copy`.




### Details and comments

Fix #12617.

I verified that this is present in 1.1.0 as well.<hr>This is an automatic backport of pull request #12619 done by [Mergify](https://mergify.com).

Patch:
diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py
index 0b492801b..4ddae5496 100644
--- a/qiskit/circuit/quantumcircuit.py
+++ b/qiskit/circuit/quantumcircuit.py
@@ -2147,6 +2147,8 @@ class QuantumCircuit:
 
         cpy._calibrations = copy.deepcopy(self._calibrations)
         cpy._metadata = copy.deepcopy(self._metadata)
+        # Invalidate parameters caching.
+        cpy._parameters = None
 
         if name:
             cpy.name = name
diff --git a/releasenotes/notes/fix-parameter-cache-05eac2f24477ccb8.yaml b/releasenotes/notes/fix-parameter-cache-05eac2f24477ccb8.yaml
new file mode 100644
index 000000000..05ac75956
--- /dev/null
+++ b/releasenotes/notes/fix-parameter-cache-05eac2f24477ccb8.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    The :attr:`.QuantumCircuit.parameters` attribute will now correctly be empty
+    when using :meth:`.QuantumCircuit.copy_empty_like` on a parametric circuit.
+    Previously, an internal cache would be copied over without invalidation.
+    Fix `#12617 <https://github.com/Qiskit/qiskit/issues/12617>`__.


Test patch:
diff --git a/test/python/circuit/test_parameters.py b/test/python/circuit/test_parameters.py
index 80c26b5b5..4aff0c9de 100644
--- a/test/python/circuit/test_parameters.py
+++ b/test/python/circuit/test_parameters.py
@@ -176,6 +176,29 @@ class TestParameters(QiskitTestCase):
         for i, vi in enumerate(v):
             self.assertEqual(vi, qc.parameters[i])
 
+    def test_parameters_property_independent_after_copy(self):
+        """Test that any `parameters` property caching is invalidated after a copy operation."""
+        a = Parameter("a")
+        b = Parameter("b")
+        c = Parameter("c")
+
+        qc1 = QuantumCircuit(1)
+        qc1.rz(a, 0)
+        self.assertEqual(set(qc1.parameters), {a})
+
+        qc2 = qc1.copy_empty_like()
+        self.assertEqual(set(qc2.parameters), set())
+
+        qc3 = qc1.copy()
+        self.assertEqual(set(qc3.parameters), {a})
+        qc3.rz(b, 0)
+        self.assertEqual(set(qc3.parameters), {a, b})
+        self.assertEqual(set(qc1.parameters), {a})
+
+        qc1.rz(c, 0)
+        self.assertEqual(set(qc1.parameters), {a, c})
+        self.assertEqual(set(qc3.parameters), {a, b})
+
     def test_bind_parameters_anonymously(self):
         """Test setting parameters by insertion order anonymously"""
         phase = Parameter("phase")