Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 403]

url_finder class definition.

Copyright: Copyright (c) 2016 Blackboard Inc. (http://www.blackboard.com)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 264 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

url_finder:: (6 methods):
  http_link_stats()
  upgrade_http_links()
  domain_swap()
  get_select_search_in_column()
  process()
  check_domain_availability()


Class: url_finder  - X-Ref

Examines DB for non-https src or data links

http_link_stats($progress = null)   X-Ref
Returns a hash of what hosts are referred to over http and would need to be changed.

param: progress_bar $progress Progress bar keeping track of this process.
return: array Hash of domains with number of references as the value.

upgrade_http_links($progress = null)   X-Ref
Changes all resources referred to over http to https.

param: progress_bar $progress Progress bar keeping track of this process.
return: bool True upon success

domain_swap($table, $column, $domain, $search)   X-Ref
Replace http domains with https equivalent, with two types of exceptions
for less straightforward swaps.

param: string $table
param: database_column_info $column
param: string $domain
param: string $search search string that has prefix, protocol, domain name and one extra character,
return: void

get_select_search_in_column($columnname)   X-Ref
Returns SQL to be used to match embedded http links in the given column

param: string $columnname name of the column (ready to be used in the SQL query)
return: array

process($replacing = false, $progress = null)   X-Ref
Originally forked from core function db_search().

param: bool $replacing Whether or not to replace the found urls.
param: progress_bar $progress Progress bar keeping track of this process.
return: bool|array If $replacing, return true on success. If not, return hash of http urls to number of times used.

check_domain_availability($url)   X-Ref
Check if url is available (GET request returns 200)

param: string $url
return: bool