Disabling pipelines when only_allow_merge_if_pipeline_succeeds is true locks existing merge requests

Summary

Having a project with Pipelines enabled, project[only_allow_merge_if_pipeline_succeeds] set to true, and an existing merge request.

If the pipeline fails or is cancelled, disabling Pipelines will simply lock the merge requests, until the user re-enables Pipelines, and removes the check from project[only_allow_merge_if_pipeline_succeeds].

Steps to reproduce

  1. Create a new project
  2. Create first commit
  3. Create a new branch
  4. Commit a change to the new branch
  5. Create a merge request from the new branch to master
  6. Enable Pipelines [in Settings » Permissions] if not yet enabled
  7. Check "Only allow merge requests to be merged if the pipeline succeeds" [in Settings » Merge request]
  8. Enable Auto DevOps [in Settings » CI / CD » Auto DevOps] or setup the pipeline by adding .gitlab-ci.yml
  9. Cancel the pipeline or make it fail
  10. Disable Pipelines [in Settings » Permissions]
  11. The merge request will now require you to pass the pipeline, although Pipelines is disabled

Example Project

The bug first appeared on an old version of on-premise Gitlab, so I checked it on gitlab.com and it happened exactly the same way.

So I created a merge request that demonstrates the described state: uda/testing!1

What is the current bug behavior?

Merge requests get locked.

What is the expected correct behavior?

The value project[only_allow_merge_if_pipeline_succeeds] should not be checked on merge requests if Pipelines is disabled.

Possible fixes

Make checking only_allow_merge_if_pipeline_succeeds in merge requests based on pipelines, as it should.