<commit_before><?php

namespace controllers;

class Payment {

	function pay($f3, $args) {
		if (!is_string($args['registrationHash']) && 40 != strlen($args['registrationHash'] + 0))
			$f3->error(404);

		$registrationDao = new \models\RegistrationDao();
		$form = $registrationDao->readRegistrationFormByHash($args['registrationHash']);

		if ('PENDING_PAYMENT' !== $form->getStatus()) {
			\models\MessageManager::addMessage(
				'warning',
				$f3->get(
						'lang.PaymentCannotProceed-' . $form->getStatus(),
						strftime('%c', strtotime($form->getDatePaid()))
					)
			);
			$f3->reroute('@registration_review(@registrationHash=' . $form->getHash() . ')');
		}

		$priceCalculator = \models\PriceCalculatorFactory::newInstance();
		$totalPrice = $priceCalculator->calculateSummary($form)['total'];
<commit_msg>404 error if form hash not found<commit_after><?php

namespace controllers;

class Payment {

	function pay($f3, $args) {
		if (!is_string($args['registrationHash']) && 40 != strlen($args['registrationHash'] + 0))
			$f3->error(404);

		$registrationDao = new \models\RegistrationDao();
		$form = $registrationDao->readRegistrationFormByHash($args['registrationHash']);

		if (!$form)
			$f3->error(404);

		if ('PENDING_PAYMENT' !== $form->getStatus()) {
			\models\MessageManager::addMessage(
				'warning',
				$f3->get(
						'lang.PaymentCannotProceed-' . $form->getStatus(),
						strftime('%c', strtotime($form->getDatePaid()))
					)
			);
			$f3->reroute('@registration_review(@registrationHash=' . $form->getHash() . ')');
		}

		$priceCalculator = \models\PriceCalculatorFactory::newInstance();
		$totalPrice = $priceCalculator->calculateSummary($form)['total'];

{'fraction_non_alphanumeric': 0.19244391971664698, 'fraction_numerical': 0.015938606847697757, 'mean_word_length': 5.075268817204301, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1177813', 'n_tokens_mistral': 653, 'n_tokens_neox': 541, 'n_words': 79}