Prior to Emacs 24, toggle-read-only itself did much of what read-only-mode code does (make use of view-mode etc.).
From Emacs 24 until Emacs 29, toggle-read-only just used read-only-mode:
(defun toggle-read-only (&optional arg interactive) "Change whether this buffer is read-only." (declare (obsolete read-only-mode "24.3")) (interactive (list current-prefix-arg t)) (if interactive (call-interactively 'read-only-mode) (read-only-mode (or arg 'toggle))))
Starting with Emacs 29 they removed toggle-read-only altogether, presumably as being essentially redundant.
If you are only using toggle-read-only interactively then just switch to using read-only-mode. If you are using toggle-read-only in some Lisp code you have, and if you're using Emacs 29 or later, then you'll either need to adjust your Lisp code, to use read-only-mode, or add the old code (above) that defines toggle-read-only.